prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Promote people to superuser in Django admin
  Replace the current `is_staff` checkbox with a `is_superuser` checkbox. This way, the project manager can give superuser access (access to Django admin interface) to people without touching the command line. 
  
  Project managers can access the Cantus editing functionalities (within the Cantus DB website, not the Admin interface). 
  Superusers can access the Django admin interface. 
  If we want someone to have access to both, they need to be in the `project manager` group and have `is_superuser` as `True`.
  
  </issue>
  <code>
  [start of django/cantusdb_project/main_app/admin.py]
  1 from django.contrib import admin
  2 from main_app.models import *
  3 # Register your models here.
  4 admin.site.register(Chant)
  5 admin.site.register(Feast)
  6 admin.site.register(Genre)
  7 admin.site.register(Indexer)
  8 admin.site.register(Notation)
  9 admin.site.register(Office)
  10 admin.site.register(Provenance)
  11 admin.site.register(Segment)
  12 admin.site.register(Sequence)
  13 admin.site.register(Source)
  14
  [end of django/cantusdb_project/main_app/admin.py]
  [start of django/cantusdb_project/users/admin.py]
  1 from django.contrib import admin
  2 from .models import *
  3 from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
  4 from django.contrib.auth.forms import UserCreationForm, UserChangeForm
  5 
  6 # Register your models here.
  7 
  8 class CustomUserCreationForm(UserCreationForm):
  9 
  10     class Meta:
  11         model = User
  12         fields = (
  13             'email', 'password', 'is_active', 'date_joined', 'last_login', 
  14             'full_name', 'first_name', 'last_name', 'institution', 'city', 
  15             'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',
  16         )
  17 
  18 
  19 class CustomUserChangeForm(UserChangeForm):
  20 
  21     class Meta:
  22         model = User
  23         fields = (
  24             'email', 'password', 'is_active', 'date_joined', 'last_login', 
  25             'full_name', 'first_name', 'last_name', 'institution', 'city', 
  26             'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',
  27         )
  28 
  29 
  30 class UserAdmin(BaseUserAdmin):
  31     form = CustomUserChangeForm
  32     add_form = CustomUserCreationForm 
  33     list_display = ('email', 'first_name', 'last_name', 'institution',)
  34     list_filter = ('groups',)
  35     fieldsets = (
  36         ('Account info', {'fields': (('email', 'password'), 'is_active', ('date_joined', 'last_login'))}),
  37         ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),
  38         ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),
  39     )
  40     add_fieldsets = (
  41         ('Account info', {'fields': ('email', ('password1', 'password2'),)}),
  42         ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),
  43         ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),
  44     )
  45     search_fields = ('email', 'first_name', 'last_name', 'institution',)
  46     ordering = ('email',)
  47     filter_horizontal = ('groups', 'sources_user_can_edit',)
  48 
  49 admin.site.register(User, UserAdmin)
  50
  [end of django/cantusdb_project/users/admin.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/django/cantusdb_project/main_app/admin.py b/django/cantusdb_project/main_app/admin.py
  --- a/django/cantusdb_project/main_app/admin.py
  +++ b/django/cantusdb_project/main_app/admin.py
  @@ -1,6 +1,15 @@
   from django.contrib import admin
   from main_app.models import *
  +from django.contrib.auth import get_user_model
   # Register your models here.
  +
  +class SourcesUserCanEditInline(admin.TabularInline):
  +    model = get_user_model().sources_user_can_edit.through
  +
  +class SourceAdmin(admin.ModelAdmin):
  +    inlines = [SourcesUserCanEditInline]
  +    filter_horizontal = ('century', 'notation', 'current_editors', 'inventoried_by', 'full_text_entered_by', 'melodies_entered_by', 'proofreaders', 'other_editors')
  +
   admin.site.register(Chant)
   admin.site.register(Feast)
   admin.site.register(Genre)
  @@ -10,4 +19,4 @@
   admin.site.register(Provenance)
   admin.site.register(Segment)
   admin.site.register(Sequence)
  -admin.site.register(Source)
  +admin.site.register(Source, SourceAdmin)
  diff --git a/django/cantusdb_project/users/admin.py b/django/cantusdb_project/users/admin.py
  --- a/django/cantusdb_project/users/admin.py
  +++ b/django/cantusdb_project/users/admin.py
  @@ -5,42 +5,19 @@
   
   # Register your models here.
   
  -class CustomUserCreationForm(UserCreationForm):
  -
  -    class Meta:
  -        model = User
  -        fields = (
  -            'email', 'password', 'is_active', 'date_joined', 'last_login', 
  -            'full_name', 'first_name', 'last_name', 'institution', 'city', 
  -            'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',
  -        )
  -
  -
  -class CustomUserChangeForm(UserChangeForm):
  -
  -    class Meta:
  -        model = User
  -        fields = (
  -            'email', 'password', 'is_active', 'date_joined', 'last_login', 
  -            'full_name', 'first_name', 'last_name', 'institution', 'city', 
  -            'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',
  -        )
  -
  -
   class UserAdmin(BaseUserAdmin):
  -    form = CustomUserChangeForm
  -    add_form = CustomUserCreationForm 
  +    readonly_fields = ('date_joined', 'last_login',)
       list_display = ('email', 'first_name', 'last_name', 'institution',)
       list_filter = ('groups',)
       fieldsets = (
           ('Account info', {'fields': (('email', 'password'), 'is_active', ('date_joined', 'last_login'))}),
           ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),
  -        ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),
  +        ('Permissions', {'fields': ('is_staff', 'is_superuser', 'groups', 'sources_user_can_edit',)}),
       )
       add_fieldsets = (
           ('Account info', {'fields': ('email', ('password1', 'password2'),)}),
           ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),
  -        ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),
  +        ('Permissions', {'fields': ('is_staff', 'is_superuser', 'groups', 'sources_user_can_edit',)}),
       )
       search_fields = ('email', 'first_name', 'last_name', 'institution',)
       ordering = ('email',)
  
verification_info: {"golden_diff": "diff --git a/django/cantusdb_project/main_app/admin.py b/django/cantusdb_project/main_app/admin.py\n--- a/django/cantusdb_project/main_app/admin.py\n+++ b/django/cantusdb_project/main_app/admin.py\n@@ -1,6 +1,15 @@\n from django.contrib import admin\n from main_app.models import *\n+from django.contrib.auth import get_user_model\n # Register your models here.\n+\n+class SourcesUserCanEditInline(admin.TabularInline):\n+    model = get_user_model().sources_user_can_edit.through\n+\n+class SourceAdmin(admin.ModelAdmin):\n+    inlines = [SourcesUserCanEditInline]\n+    filter_horizontal = ('century', 'notation', 'current_editors', 'inventoried_by', 'full_text_entered_by', 'melodies_entered_by', 'proofreaders', 'other_editors')\n+\n admin.site.register(Chant)\n admin.site.register(Feast)\n admin.site.register(Genre)\n@@ -10,4 +19,4 @@\n admin.site.register(Provenance)\n admin.site.register(Segment)\n admin.site.register(Sequence)\n-admin.site.register(Source)\n+admin.site.register(Source, SourceAdmin)\ndiff --git a/django/cantusdb_project/users/admin.py b/django/cantusdb_project/users/admin.py\n--- a/django/cantusdb_project/users/admin.py\n+++ b/django/cantusdb_project/users/admin.py\n@@ -5,42 +5,19 @@\n \n # Register your models here.\n \n-class CustomUserCreationForm(UserCreationForm):\n-\n-    class Meta:\n-        model = User\n-        fields = (\n-            'email', 'password', 'is_active', 'date_joined', 'last_login', \n-            'full_name', 'first_name', 'last_name', 'institution', 'city', \n-            'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',\n-        )\n-\n-\n-class CustomUserChangeForm(UserChangeForm):\n-\n-    class Meta:\n-        model = User\n-        fields = (\n-            'email', 'password', 'is_active', 'date_joined', 'last_login', \n-            'full_name', 'first_name', 'last_name', 'institution', 'city', \n-            'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',\n-        )\n-\n-\n class UserAdmin(BaseUserAdmin):\n-    form = CustomUserChangeForm\n-    add_form = CustomUserCreationForm \n+    readonly_fields = ('date_joined', 'last_login',)\n     list_display = ('email', 'first_name', 'last_name', 'institution',)\n     list_filter = ('groups',)\n     fieldsets = (\n         ('Account info', {'fields': (('email', 'password'), 'is_active', ('date_joined', 'last_login'))}),\n         ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),\n-        ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),\n+        ('Permissions', {'fields': ('is_staff', 'is_superuser', 'groups', 'sources_user_can_edit',)}),\n     )\n     add_fieldsets = (\n         ('Account info', {'fields': ('email', ('password1', 'password2'),)}),\n         ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),\n-        ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),\n+        ('Permissions', {'fields': ('is_staff', 'is_superuser', 'groups', 'sources_user_can_edit',)}),\n     )\n     search_fields = ('email', 'first_name', 'last_name', 'institution',)\n     ordering = ('email',)\n", "issue": "Promote people to superuser in Django admin\nReplace the current `is_staff` checkbox with a `is_superuser` checkbox. This way, the project manager can give superuser access (access to Django admin interface) to people without touching the command line. \r\n\r\nProject managers can access the Cantus editing functionalities (within the Cantus DB website, not the Admin interface). \r\nSuperusers can access the Django admin interface. \r\nIf we want someone to have access to both, they need to be in the `project manager` group and have `is_superuser` as `True`.\n", "before_files": [{"content": "from django.contrib import admin\nfrom main_app.models import *\n# Register your models here.\nadmin.site.register(Chant)\nadmin.site.register(Feast)\nadmin.site.register(Genre)\nadmin.site.register(Indexer)\nadmin.site.register(Notation)\nadmin.site.register(Office)\nadmin.site.register(Provenance)\nadmin.site.register(Segment)\nadmin.site.register(Sequence)\nadmin.site.register(Source)\n", "path": "django/cantusdb_project/main_app/admin.py"}, {"content": "from django.contrib import admin\nfrom .models import *\nfrom django.contrib.auth.admin import UserAdmin as BaseUserAdmin\nfrom django.contrib.auth.forms import UserCreationForm, UserChangeForm\n\n# Register your models here.\n\nclass CustomUserCreationForm(UserCreationForm):\n\n    class Meta:\n        model = User\n        fields = (\n            'email', 'password', 'is_active', 'date_joined', 'last_login', \n            'full_name', 'first_name', 'last_name', 'institution', 'city', \n            'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',\n        )\n\n\nclass CustomUserChangeForm(UserChangeForm):\n\n    class Meta:\n        model = User\n        fields = (\n            'email', 'password', 'is_active', 'date_joined', 'last_login', \n            'full_name', 'first_name', 'last_name', 'institution', 'city', \n            'country', 'website', 'is_staff', 'groups', 'sources_user_can_edit',\n        )\n\n\nclass UserAdmin(BaseUserAdmin):\n    form = CustomUserChangeForm\n    add_form = CustomUserCreationForm \n    list_display = ('email', 'first_name', 'last_name', 'institution',)\n    list_filter = ('groups',)\n    fieldsets = (\n        ('Account info', {'fields': (('email', 'password'), 'is_active', ('date_joined', 'last_login'))}),\n        ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),\n        ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),\n    )\n    add_fieldsets = (\n        ('Account info', {'fields': ('email', ('password1', 'password2'),)}),\n        ('Personal info', {'fields': ('full_name', ('first_name', 'last_name'), 'institution', ('city', 'country'), 'website',)}),\n        ('Permissions', {'fields': ('is_staff', 'groups', 'sources_user_can_edit',)}),\n    )\n    search_fields = ('email', 'first_name', 'last_name', 'institution',)\n    ordering = ('email',)\n    filter_horizontal = ('groups', 'sources_user_can_edit',)\n\nadmin.site.register(User, UserAdmin)\n", "path": "django/cantusdb_project/users/admin.py"}]}