Commit 718abab9 authored by fnux's avatar fnux

Add make-admin command to uncloud_auth

parent 268e08c4
Pipeline #1395 failed with stage
in 3 minutes and 10 seconds
......@@ -6,6 +6,11 @@ Cloud management platform, the ungleich way.
[![pipeline status](](
[![coverage report](](
## Useful commands
* `./ import-vat-rates path/to/csv`
* `./ make-admin username`
## Development setup
Install system dependencies:
......@@ -55,4 +60,3 @@ If you want to use Postgres:
* Install on configure PGSQL on your base system.
* OR use a container! `podman run --rm -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -it postgres:latest`
from import BaseCommand
from django.contrib.auth import get_user_model
import sys
class Command(BaseCommand):
help = 'Give Admin rights to existing user'
def add_arguments(self, parser):
parser.add_argument('username', type=str)
def handle(self, *args, **options):
user = get_user_model().objects.get(username=options['username'])
user.is_staff = True
print("{} is now admin.".format(user.username))
......@@ -243,7 +243,7 @@ class BillingAddressViewSet(mixins.CreateModelMixin,
return Response(
# Old admin stuff.
# Admin stuff.
class AdminPaymentViewSet(viewsets.ModelViewSet):
serializer_class = PaymentSerializer
......@@ -279,7 +279,7 @@ class AdminBillViewSet(viewsets.ModelViewSet):
return Response(, status=status.HTTP_201_CREATED, headers=headers)
class AdminOrderViewSet(viewsets.ModelViewSet):
permission_classes = [permissions.IsAuthenticated]
permission_classes = [permissions.IsAdminUser]
def get_serializer(self, *args, **kwargs):
return OrderSerializer(*args, **kwargs, admin=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment