1- # Generated by Django 5.0 on 2025-11-13 13:14
1+ # Generated by Django 5.2.8 on 2025-11-28 08:19
22
33import django .core .validators
44import django .db .models .deletion
5+ import django .utils .timezone
56import django_email_learning .models
67from django .conf import settings
78from django .db import migrations , models
@@ -15,6 +16,41 @@ class Migration(migrations.Migration):
1516 ]
1617
1718 operations = [
19+ migrations .CreateModel (
20+ name = "BlockedEmail" ,
21+ fields = [
22+ (
23+ "id" ,
24+ models .BigAutoField (
25+ auto_created = True ,
26+ primary_key = True ,
27+ serialize = False ,
28+ verbose_name = "ID" ,
29+ ),
30+ ),
31+ ("email" , models .EmailField (max_length = 254 , unique = True )),
32+ ],
33+ ),
34+ migrations .CreateModel (
35+ name = "EventTimestamp" ,
36+ fields = [
37+ (
38+ "id" ,
39+ models .BigAutoField (
40+ auto_created = True ,
41+ primary_key = True ,
42+ serialize = False ,
43+ verbose_name = "ID" ,
44+ ),
45+ ),
46+ (
47+ "time" ,
48+ models .DateTimeField (
49+ db_index = True , default = django .utils .timezone .now
50+ ),
51+ ),
52+ ],
53+ ),
1854 migrations .CreateModel (
1955 name = "ImapConnection" ,
2056 fields = [
@@ -34,11 +70,27 @@ class Migration(migrations.Migration):
3470 validators = [django_email_learning .models .is_domain_or_ip ],
3571 ),
3672 ),
37- ("port" , models .IntegerField (db_default = models . Value ( 993 ) )),
73+ ("port" , models .IntegerField (db_default = 993 )),
3874 ("email" , models .EmailField (max_length = 200 , unique = True )),
3975 ("password" , models .CharField (max_length = 200 )),
4076 ],
4177 ),
78+ migrations .CreateModel (
79+ name = "Learner" ,
80+ fields = [
81+ (
82+ "id" ,
83+ models .BigAutoField (
84+ auto_created = True ,
85+ primary_key = True ,
86+ serialize = False ,
87+ verbose_name = "ID" ,
88+ ),
89+ ),
90+ ("email" , models .EmailField (max_length = 254 , unique = True )),
91+ ("created_at" , models .DateTimeField (auto_now_add = True )),
92+ ],
93+ ),
4294 migrations .CreateModel (
4395 name = "Lesson" ,
4496 fields = [
@@ -157,12 +209,67 @@ class Migration(migrations.Migration):
157209 ),
158210 ),
159211 ],
160- options = {
161- "unique_together" : {
162- ("slug" , "organization" ),
163- ("title" , "organization" ),
164- },
165- },
212+ ),
213+ migrations .CreateModel (
214+ name = "Enrollment" ,
215+ fields = [
216+ (
217+ "id" ,
218+ models .BigAutoField (
219+ auto_created = True ,
220+ primary_key = True ,
221+ serialize = False ,
222+ verbose_name = "ID" ,
223+ ),
224+ ),
225+ ("enrolled_at" , models .DateTimeField (auto_now_add = True )),
226+ ("next_send_timestamp" , models .DateTimeField (blank = True , null = True )),
227+ (
228+ "status" ,
229+ models .CharField (
230+ choices = [
231+ ("unverified" , "Unverified" ),
232+ ("active" , "Active" ),
233+ ("completed" , "Completed" ),
234+ ("deactivated" , "Deactivated" ),
235+ ],
236+ default = "unverified" ,
237+ max_length = 50 ,
238+ ),
239+ ),
240+ (
241+ "deactivation_reason" ,
242+ models .CharField (
243+ blank = True ,
244+ choices = [
245+ ("canceled" , "Canceled" ),
246+ ("blocked" , "Blocked" ),
247+ ("failed" , "Failed" ),
248+ ("inactive" , "Inactive" ),
249+ ],
250+ max_length = 50 ,
251+ null = True ,
252+ ),
253+ ),
254+ (
255+ "activation_code" ,
256+ models .CharField (blank = True , max_length = 100 , null = True ),
257+ ),
258+ (
259+ "course" ,
260+ models .ForeignKey (
261+ on_delete = django .db .models .deletion .CASCADE ,
262+ to = "django_email_learning.course" ,
263+ ),
264+ ),
265+ (
266+ "learner" ,
267+ models .ForeignKey (
268+ on_delete = django .db .models .deletion .CASCADE ,
269+ to = "django_email_learning.learner" ,
270+ ),
271+ ),
272+ ],
166273 ),
167274 migrations .AddField (
168275 model_name = "imapconnection" ,
@@ -265,6 +372,12 @@ class Migration(migrations.Migration):
265372 choices = [("lesson" , "Lesson" ), ("quiz" , "Quiz" )], max_length = 50
266373 ),
267374 ),
375+ (
376+ "waiting_period" ,
377+ models .IntegerField (
378+ help_text = "Waiting period in seconds after previous content is sent or submited."
379+ ),
380+ ),
268381 (
269382 "course" ,
270383 models .ForeignKey (
@@ -292,4 +405,57 @@ class Migration(migrations.Migration):
292405 ),
293406 ],
294407 ),
408+ migrations .CreateModel (
409+ name = "SentItem" ,
410+ fields = [
411+ (
412+ "id" ,
413+ models .BigAutoField (
414+ auto_created = True ,
415+ primary_key = True ,
416+ serialize = False ,
417+ verbose_name = "ID" ,
418+ ),
419+ ),
420+ ("quiz_score" , models .IntegerField (blank = True , null = True )),
421+ ("is_quiz_passed" , models .BooleanField (blank = True , null = True )),
422+ ("times_sent" , models .IntegerField (default = 1 )),
423+ (
424+ "course_content" ,
425+ models .ForeignKey (
426+ on_delete = django .db .models .deletion .CASCADE ,
427+ to = "django_email_learning.coursecontent" ,
428+ ),
429+ ),
430+ (
431+ "enrollment" ,
432+ models .ForeignKey (
433+ on_delete = django .db .models .deletion .CASCADE ,
434+ to = "django_email_learning.enrollment" ,
435+ ),
436+ ),
437+ (
438+ "send_events" ,
439+ models .ManyToManyField (to = "django_email_learning.eventtimestamp" ),
440+ ),
441+ ],
442+ ),
443+ migrations .AddConstraint (
444+ model_name = "enrollment" ,
445+ constraint = models .UniqueConstraint (
446+ condition = models .Q (
447+ ("status__in" , ["unverified" , "active" , "completed" ])
448+ ),
449+ fields = ("learner" , "course" ),
450+ name = "unique_active_enrollment" ,
451+ ),
452+ ),
453+ migrations .AlterUniqueTogether (
454+ name = "course" ,
455+ unique_together = {("slug" , "organization" ), ("title" , "organization" )},
456+ ),
457+ migrations .AlterUniqueTogether (
458+ name = "sentitem" ,
459+ unique_together = {("enrollment" , "course_content" )},
460+ ),
295461 ]
0 commit comments