Add: base user app for user specific settings
This commit is contained in:
parent
a119e041bf
commit
5de12311c4
4 changed files with 78 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import UserProfile
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
|
class UserProfileAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('user', 'show_mature')
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(UserProfile, UserProfileAdmin)
|
||||||
|
|
|
@ -3,4 +3,4 @@ from django.apps import AppConfig
|
||||||
|
|
||||||
class UsersConfig(AppConfig):
|
class UsersConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'users'
|
name = 'apps.user'
|
||||||
|
|
34
archivist/apps/user/migrations/0001_initial.py
Normal file
34
archivist/apps/user/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 4.1.1 on 2023-11-01 14:43
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('furaffinity', '0001_initial'),
|
||||||
|
('auth', '0012_alter_user_first_name_max_length'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='UserProfile',
|
||||||
|
fields=[
|
||||||
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
|
||||||
|
('show_mature', models.CharField(choices=[('H', 'Hide'), ('B', 'Blur'), ('S', 'Show')], default='H', max_length=2)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SeenPost',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('timestamp', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='furaffinity.fa_submission')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.userprofile')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,3 +1,37 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
|
||||||
|
from sites.furaffinity.models import FA_Submission
|
||||||
|
|
||||||
|
class UserProfile(models.Model):
|
||||||
|
|
||||||
|
MATURE = [
|
||||||
|
("H", "Hide"),
|
||||||
|
("B", "Blur"),
|
||||||
|
("S", "Show"),
|
||||||
|
]
|
||||||
|
|
||||||
|
user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True, unique=True)
|
||||||
|
show_mature = models.CharField(max_length=2, choices=MATURE, default=MATURE[0][0])
|
||||||
|
|
||||||
|
|
||||||
|
class SeenPost(models.Model):
|
||||||
|
user = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
|
||||||
|
post = models.ForeignKey(FA_Submission, on_delete=models.CASCADE)
|
||||||
|
timestamp = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
|
||||||
|
#receiver(post_save, sender=User)
|
||||||
|
#def create_user_profile(sender, instance, created, **kwargs):
|
||||||
|
# if created:
|
||||||
|
# UserProfile.objects.create(user=instance)
|
||||||
|
|
||||||
|
#@receiver(post_save, sender=User)
|
||||||
|
#def save_user_profile(sender, instance, **kwargs):
|
||||||
|
# instance.user.save()
|
||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
|
|
Loading…
Reference in a new issue