Changes between Initial Version and Version 1 of Ticket #25009, comment 2


Ignore:
Timestamp:
Jun 19, 2015, 6:09:21 PM (9 years ago)
Author:
Coen van der Kamp

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25009, comment 2

    initial v1  
    11Seems like we can have a cheeseburger without cheese :). Forgiveness is cool. But we can also raise an error for the superuser.
    22
    3 {{{
     3{{{#!python
    44def create_user(self, username, email=None, password=None, **extra_fields):
    55    extra_fields.setdefault('is_staff', False)
     
    88
    99def create_superuser(self, username, email, password, **extra_fields):
    10     if extra_fields.has_key('is_staff') and extra_fields.get('is_staff') is False:
    11         raise ValueError('Superuser needs to be staff. Do not set `is_staff`.')
    12     if extra_fields.has_key('is_superuser') and extra_fields.get('is_superuser') is False:
    13         raise ValueError('Superuser needs to be superuser. Do not set `is_superuser`.')
    1410    extra_fields.setdefault('is_staff', True)
    1511    extra_fields.setdefault('is_superuser', True)
     12    if extra_fields.get('is_staff') is False:
     13        raise ValueError('Superuser needs to be staff. Do not set is_staff.')
     14    if extra_fields.get('is_superuser') is False:
     15        raise ValueError('Superuser needs to be superuser. Do not set is_superuser.')
     16
    1617    return self._create_user(username, email, password, **extra_fields)
    1718}}}
Back to Top