auto_creation.py 1.07 KB
Newer Older
1 2
from backend_app.models.course import Course
from backend_app.models.courseFeedback import CourseFeedback
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
from backend_app.models.university import University
from backend_app.models.universityInfo import UniversityInfo
from backend_app.models.universitySemestersDates import UniversitySemestersDates
from backend_app.models.userData import UserData

from django.db.models.signals import post_save

from base_app.models import User


def create_univ_modules(sender, instance, created, **kwargs):
    if created:
        UniversityInfo.objects.create(university=instance)
        UniversitySemestersDates.objects.create(university=instance)


def create_user_modules(sender, instance, created, **kwargs):
    if created:
        UserData.objects.create(owner=instance)


24 25 26 27 28
def create_course_feedback_modules(sender, instance, created, **kwargs):
    if created:
        CourseFeedback.objects.create(course=instance)


29 30
post_save.connect(create_univ_modules, sender=University)
post_save.connect(create_user_modules, sender=User)
31
post_save.connect(create_course_feedback_modules, sender=Course)