The next script executed on the sso service will update user with admin privileges.

from webpush.apps.users.constants import UserBillingTypes
from webpush.apps.users.models import CustomUser
 
from apps.billing.models import UserBilling
 
admins = ["lango.media.ads@gmail.com"]
 
 
for email in admins:
    user = CustomUser.objects.get(email=email)
    if not user.is_staff:
        print(f"{email} is not staff, lets change it...")
        user.is_staff = True
        user.save()
    try:
        user_billing = user.user_billing
    except Exception:
        print(f"{email} has no billing, lets create it with UNLIMITED type...")
        user_billing = UserBilling.objects.create(user=user, billing_type=UserBillingTypes.UNLIMITED)
    if user_billing.billing_type != UserBillingTypes.UNLIMITED:
        print(f"{email} is not admin, lets change it...")
        user_billing.billing_type = UserBillingTypes.UNLIMITED
        user_billing.save()

A script above will do the following:

  • get a user by email
  • update user’s is_staff field to True
  • create a UserBilling object if it doesn’t exist
  • update user’s billing type to UNLIMITED

A further action with setting subscribers limit to something big (unreachable) is also required to be done on a directory side:

 
from apps.subscribers.models import SubscribersUserSettings
	
# uid = <user_id>
SubscribersUserSettings.objects.create(
    owner_id=uid,
    limit=1000000,
)