refactor!: Move to custom user model
This commit is contained in:
parent
4a1332dd4a
commit
0d22ea0b65
@ -1,8 +1,9 @@
|
|||||||
from django.contrib import admin
|
|
||||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
from django.contrib.auth.models import User
|
from django.contrib import admin
|
||||||
|
from .models import User
|
||||||
|
|
||||||
from .models import Animal, Species, RescueOrganization, AdoptionNotice, Location, Rule, Image, ModerationAction, Report, Member
|
from .models import Animal, Species, RescueOrganization, AdoptionNotice, Location, Rule, Image, ModerationAction, \
|
||||||
|
Report, Member
|
||||||
|
|
||||||
|
|
||||||
# Define an inline admin descriptor for Employee model
|
# Define an inline admin descriptor for Employee model
|
||||||
@ -19,7 +20,6 @@ class UserAdmin(BaseUserAdmin):
|
|||||||
|
|
||||||
|
|
||||||
# Re-register UserAdmin
|
# Re-register UserAdmin
|
||||||
admin.site.unregister(User)
|
|
||||||
admin.site.register(User, UserAdmin)
|
admin.site.register(User, UserAdmin)
|
||||||
|
|
||||||
admin.site.register(Animal)
|
admin.site.register(Animal)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from .models import AdoptionNotice, Animal, Image, Report, ModerationAction
|
from .models import AdoptionNotice, Animal, Image, Report, ModerationAction
|
||||||
|
from django_registration.forms import RegistrationForm
|
||||||
|
|
||||||
|
|
||||||
class DateInput(forms.DateInput):
|
class DateInput(forms.DateInput):
|
||||||
@ -41,3 +42,7 @@ class ModerationActionForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = ModerationAction
|
model = ModerationAction
|
||||||
fields = ('action', 'public_comment', 'private_comment')
|
fields = ('action', 'public_comment', 'private_comment')
|
||||||
|
|
||||||
|
|
||||||
|
class CustomRegistrationForm(RegistrationForm):
|
||||||
|
pass
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
# Generated by Django 5.0.3 on 2024-03-23 10:04
|
# Generated by Django 5.0.3 on 2024-04-07 09:32
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import django.contrib.auth.models
|
||||||
|
import django.contrib.auth.validators
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
import uuid
|
import uuid
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
@ -12,7 +15,7 @@ class Migration(migrations.Migration):
|
|||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
('auth', '0012_alter_user_first_name_max_length'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
@ -77,6 +80,32 @@ class Migration(migrations.Migration):
|
|||||||
'verbose_name_plural': 'Species',
|
'verbose_name_plural': 'Species',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='User',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('password', models.CharField(max_length=128, verbose_name='password')),
|
||||||
|
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
||||||
|
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||||
|
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
|
||||||
|
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
|
||||||
|
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
|
||||||
|
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
|
||||||
|
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
||||||
|
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
||||||
|
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
|
||||||
|
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
|
||||||
|
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'user',
|
||||||
|
'verbose_name_plural': 'users',
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
managers=[
|
||||||
|
('objects', django.contrib.auth.models.UserManager()),
|
||||||
|
],
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='AdoptionNotice',
|
name='AdoptionNotice',
|
||||||
fields=[
|
fields=[
|
||||||
|
@ -2,12 +2,14 @@ import uuid
|
|||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from fellchensammlung.tools import misc
|
from fellchensammlung.tools import misc
|
||||||
|
|
||||||
@ -285,6 +287,10 @@ Membership
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class User(AbstractUser):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Member(models.Model):
|
class Member(models.Model):
|
||||||
"""
|
"""
|
||||||
Model that holds a user's profile, including the django user model
|
Model that holds a user's profile, including the django user model
|
||||||
|
@ -77,6 +77,7 @@ else:
|
|||||||
EMAIL_USE_SSL = config.getboolean('mail', 'ssl', fallback=False)
|
EMAIL_USE_SSL = config.getboolean('mail', 'ssl', fallback=False)
|
||||||
|
|
||||||
"""USER MANAGEMENT"""
|
"""USER MANAGEMENT"""
|
||||||
|
AUTH_USER_MODEL = "fellchensammlung.User"
|
||||||
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window
|
ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window
|
||||||
REGISTRATION_OPEN = True
|
REGISTRATION_OPEN = True
|
||||||
REGISTRATION_SALT = "notfellchen"
|
REGISTRATION_SALT = "notfellchen"
|
||||||
|
Loading…
Reference in New Issue
Block a user