0

我正在为 ESL(英语作为第二语言)学院构建管理界面,基本上它是人们学习英语的语言学校。

我已经为每个应用程序准备了我的模型,我真的希望有人审查它们并为我提供建议和设计中可能出现的错误。

  • 名为ez_core的应用程序的模型
GENDER_CHOICES = [
    ('Female', 'Female'),
    ('Male', 'Male')
]

STREET_ADDRESS_CHOICES = [
    ('A', 'A'),
    ('B', 'B')
]

EDUCATIONAL_LEVEL_CHOICES = [
    ('Bachelor\'s Degree', 'Bachelor\'s Degree'),
    ('Master\'s Degree', 'Master\'s Degree'),
    ('PhD Degree', 'PhD Degree'),
]

CONTACT_RELATIONSHIP_CHOICES = [
    ('Brother', 'Brother'),
    ('Father', 'Father'),
    ('Mother', 'Mother'),
    ('Sister', 'Sister'),
    ('Uncle', 'Uncle'),
    ('Wife', 'Wife'),
]

MEDICAL_CONDITION_CHOICES = [
    ('Chronic Disease', 'Chronic Disease'),
    ('Allergies', 'Allergies')
]


class PersonalInfo(models.Model):
    full_name = models.CharField(max_length=100)
    phone_number = models.CharField(max_length=100)
    email_address = models.EmailField(max_length=100)
    birthdate = models.DateField()
    gender = models.CharField(max_length=6, choices=GENDER_CHOICES)
    personal_id_number = models.CharField(max_length=100)
    passport_number = models.CharField(max_length=100)
    personal_photo_link = models.CharField(max_length=100)
    id_card_attchment_link = models.CharField(max_length=100)
    passport_attachment_link = models.CharField(max_length=100)
    street_address = models.CharField(
        max_length=100, choices=STREET_ADDRESS_CHOICES)
    address_reference_point = models.CharField(max_length=100)
    educational_level = models.CharField(
        max_length=100, choices=EDUCATIONAL_LEVEL_CHOICES)
    specialization = models.CharField(max_length=100)
    contact_phone_number = models.CharField(max_length=100)
    contact_name = models.CharField(max_length=100)
    contact_relationship = models.CharField(
        max_length=100, choices=CONTACT_RELATIONSHIP_CHOICES)
    medical_condition = models.CharField(
        max_length=100, choices=MEDICAL_CONDITION_CHOICES)
    medication = models.CharField(max_length=100)

    class Meta:
        abstract = True
  • 名为ez_course的应用程序的模型
COURSE_TYPE_CHOICES = [
    ('Adults', 'Adults'),
    ('Kids', 'Kids')
]

COURSE_TITLE_CHOICES = [
    ('General English', 'General English'),
    ('Big English', 'Big English'),
    ('Supermind', 'Supermind'),
    ('Business', 'Business'),
    ('UK Visa', 'UK Visa'),
    ('IELTS', 'IELTS'),
]


class CourseDays(models.Model):
    date = models.DateField()


class Course(models.Model):
    course_type = models.CharField(max_length=100, choices=COURSE_TYPE_CHOICES)
    course_title = models.CharField(
        max_length=100, choices=COURSE_TITLE_CHOICES)
    course_description = models.TextField()
    course_start_time = models.TimeField()
    course_end_time = models.TimeField()
    # teachers
    course_cost = models.IntegerField()
    course_days = models.ManyToManyField(CourseDays)
  • 名为ez_staff的应用程序的模型
from ez_core.models import PersonalInfo
from ez_course.models import Course

POSITION_CHOICES = [
    ('Teacher Assistant', 'Teacher Assistant'),
    ('Volunteer', 'Volunteer'),
    ('Teacher', 'Teacher'),
    ('Service', 'Service'),
    ('Intern', 'Intern'),
    ('Admin', 'Admin'),
    ('Boss', 'Boss'),
]


class Staff(PersonalInfo):
    is_married = models.BooleanField(default=False)
    number_of_children = models.IntegerField()
    start_working_date = models.DateField()
    position = models.CharField(max_length=100, choices=POSITION_CHOICES)
    taught_courses = models.ManyToManyField(Course, blank=True)
    is_active = models.BooleanField(default=True)
    inactivity_reason = models.CharField(max_length=100, blank=True, null=True)
  • 名为ez_student的应用程序的模型
from ez_core.models import PersonalInfo
from ez_course.models import Course


class DailyAttendance(models.Model):
    date = models.DateField()
    first_hour = models.BooleanField(default=False)
    second_hour = models.BooleanField(default=False)
    leave = models.BooleanField(default=False)


class Test(models.Model):
    test_title = models.CharField(max_length=100)
    test_max_score = models.IntegerField()
    test_score = models.IntegerField()
    test_date = models.DateField()


class Student(PersonalInfo):
    has_bus_service = models.BooleanField(default=False)
    is_postponed = models.BooleanField(default=False)
    postpone_reason = models.CharField(max_length=100, blank=True, null=True)
    courses = models.ForeignKey(Course, on_delete=models.CASCADE)
    daily_attendance = models.ManyToManyField(
        DailyAttendance, blank=True)
    tests = models.ManyToManyField(Test)
4

2 回答 2

0

到目前为止一切都很好。我认为一个强大的电话号码字段将是

phone_regex = RegexValidator(
        regex=r'^(05)\d{9}$',
        message=phone_message
    )
于 2021-04-25T11:47:47.453 回答
0

一切看起来都不错,只是我认为在数字方面可能使用 IntegerField() 比 CharField() 更好:

phone_number = models.IntegerField()
contact_phone_number = models.IntegerField()

并且:

personal_photo_link = models.CharField(max_length=100)

我认为:(max_length = 100)对于链接来说是不够的。

于 2021-04-25T15:10:15.503 回答