Ver Fonte

use user model for auth

subDesTagesMitExtraKaese há 1 ano atrás
pai
commit
a54832c107

+ 1 - 1
zitap/admin.py

@@ -11,4 +11,4 @@ class DateAdmin(admin.ModelAdmin):
 
 @admin.register(Participant)
 class ParticipantAdmin(admin.ModelAdmin):
-    list_display = ('event', 'name', 'slots')
+    list_display = ('event', 'user', 'slots')

+ 18 - 0
zitap/migrations/0002_alter_participant_pw_hash.py

@@ -0,0 +1,18 @@
+# Generated by Django 4.1.2 on 2022-12-17 11:22
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('zitap', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='participant',
+            name='pw_hash',
+            field=models.CharField(blank=True, max_length=255, null=True),
+        ),
+    ]

+ 23 - 0
zitap/migrations/0003_event_end_time_event_start_time.py

@@ -0,0 +1,23 @@
+# Generated by Django 4.1.2 on 2022-12-17 11:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('zitap', '0002_alter_participant_pw_hash'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='event',
+            name='end_time',
+            field=models.TimeField(default='20:00'),
+        ),
+        migrations.AddField(
+            model_name='event',
+            name='start_time',
+            field=models.TimeField(default='09:00'),
+        ),
+    ]

+ 30 - 0
zitap/migrations/0004_remove_participant_name_remove_participant_pw_hash_and_more.py

@@ -0,0 +1,30 @@
+# Generated by Django 4.1.2 on 2022-12-17 11:44
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('zitap', '0003_event_end_time_event_start_time'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='participant',
+            name='name',
+        ),
+        migrations.RemoveField(
+            model_name='participant',
+            name='pw_hash',
+        ),
+        migrations.AddField(
+            model_name='participant',
+            name='user',
+            field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
+            preserve_default=False,
+        ),
+    ]

+ 4 - 2
zitap/models.py

@@ -1,6 +1,7 @@
 from datetime import timedelta
 import random
 from django.db import models
+from django.contrib.auth.models import User
 
 def generate_random_url():
     # a-z, A-Z, 0-9, -, _
@@ -12,6 +13,8 @@ class Event(models.Model):
     name = models.CharField(max_length=255)
     slot_interval = models.DurationField(default=timedelta(minutes=15))
     created_at = models.DateTimeField(auto_now_add=True)
+    start_time = models.TimeField(default='09:00')
+    end_time = models.TimeField(default='20:00')
 
 class Date(models.Model):
     event = models.ForeignKey(Event, on_delete=models.CASCADE)
@@ -19,6 +22,5 @@ class Date(models.Model):
 
 class Participant(models.Model):
     event = models.ForeignKey(Event, on_delete=models.CASCADE)
-    name = models.CharField(max_length=255)
-    pw_hash = models.CharField(max_length=255)
+    user = models.ForeignKey(User, on_delete=models.CASCADE)
     slots = models.BinaryField()