diff --git a/.gitignore b/.gitignore index 43cabbf..086cf43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ - +/static /upload_file /generate_paper *.pyc \ No newline at end of file diff --git a/ec_user/forms.py b/ec_user/forms.py index dcde108..9f6a072 100644 --- a/ec_user/forms.py +++ b/ec_user/forms.py @@ -1,7 +1,7 @@ from django import forms from .models import EcUser, ContactInfo, SchoolInfo, AcademicInfo, HealthInfo, SelfEvaluation -from .models import HobbiesInterests, SocialPractice, FamilyInfo, AwardsPunishments +from .models import HobbiesInterests, SocialPractice, FamilyInfo, AwardsInfo, PunishmentsInfo class BaiscInfoForm(forms.ModelForm): class Meta: @@ -105,15 +105,21 @@ class FamilyInfoForm(forms.ModelForm): } # AwardsPunishments 表单 -class AwardsPunishmentsForm(forms.ModelForm): +class AwardsInfoForm(forms.ModelForm): class Meta: - model = AwardsPunishments - fields = ['award_name', 'award_date', 'award_organization', 'discipline_date', 'discipline_issue', 'discipline_outcome'] + model = AwardsInfo + fields = ['award_name', 'award_date', 'award_organization'] labels = { - 'award_name': '奖项名称', 'award_date': '获奖日期', 'award_organization': '颁奖机构', + } + +class PunishmentsInfoForm(forms.ModelForm): + class Meta: + model = PunishmentsInfo + fields = ['discipline_date', 'discipline_issue', 'discipline_outcome'] + labels = { 'discipline_date': '处分日期', 'discipline_issue': '处分问题', 'discipline_outcome': '处分结果', @@ -129,7 +135,8 @@ g_models = { 'hobbies_interests': HobbiesInterests, 'social_practice': SocialPractice, 'family_info': FamilyInfo, - 'awards_punishments': AwardsPunishments + 'awards_info': AwardsInfo, + 'punishments_info': PunishmentsInfo } g_form_classes = { @@ -141,5 +148,6 @@ g_form_classes = { 'hobbies_interests_form': HobbiesInterestsForm, 'social_practice_form': SocialPracticeForm, 'family_info_form': FamilyInfoForm, - 'awards_punishments_form': AwardsPunishmentsForm + 'awards_info_form': AwardsInfoForm, + 'punishments_info_form': PunishmentsInfoForm, } diff --git a/ec_user/migrations/0016_awardsinfo_punishmentsinfo_alter_ecuser_age_and_more.py b/ec_user/migrations/0016_awardsinfo_punishmentsinfo_alter_ecuser_age_and_more.py new file mode 100644 index 0000000..0854e47 --- /dev/null +++ b/ec_user/migrations/0016_awardsinfo_punishmentsinfo_alter_ecuser_age_and_more.py @@ -0,0 +1,91 @@ +# Generated by Django 4.2.19 on 2025-03-01 14:45 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ec_user', '0015_alter_hobbiesinterests_extracurricular_activities_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='AwardsInfo', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('award_name', models.CharField(max_length=100)), + ('award_date', models.DateField()), + ('award_organization', models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name='PunishmentsInfo', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('discipline_date', models.DateField(blank=True, null=True)), + ('discipline_issue', models.CharField(blank=True, max_length=255, null=True)), + ('discipline_outcome', models.CharField(blank=True, max_length=255, null=True)), + ], + ), + migrations.AlterField( + model_name='ecuser', + name='age', + field=models.IntegerField(blank=True, null=True, verbose_name='年龄'), + ), + migrations.AlterField( + model_name='ecuser', + name='dob', + field=models.DateField(blank=True, null=True, verbose_name='出生日期'), + ), + migrations.AlterField( + model_name='ecuser', + name='ethnicity', + field=models.CharField(default='Unknown', max_length=50, verbose_name='民族'), + ), + migrations.AlterField( + model_name='ecuser', + name='gender', + field=models.CharField(choices=[('M', 'Male'), ('F', 'Female'), ('O', 'Other')], default='M', max_length=1, verbose_name='性别'), + ), + migrations.AlterField( + model_name='ecuser', + name='id_card_number', + field=models.CharField(max_length=18, unique=True, verbose_name='身份证号'), + ), + migrations.AlterField( + model_name='ecuser', + name='name', + field=models.CharField(max_length=100, verbose_name='姓名'), + ), + migrations.AlterField( + model_name='ecuser', + name='political_status', + field=models.CharField(blank=True, max_length=50, null=True, verbose_name='政治面貌'), + ), + migrations.AlterField( + model_name='ecuser', + name='subject_usage_count', + field=models.IntegerField(default=5, verbose_name='使用次数限制'), + ), + migrations.AlterField( + model_name='ecuser', + name='subjects', + field=models.ManyToManyField(blank=True, related_name='users', to='ec_user.subject', verbose_name='开放权限的科目'), + ), + migrations.DeleteModel( + name='AwardsPunishments', + ), + migrations.AddField( + model_name='punishmentsinfo', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='awardsinfo', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/ec_user/migrations/0017_alter_awardsinfo_award_date_and_more.py b/ec_user/migrations/0017_alter_awardsinfo_award_date_and_more.py new file mode 100644 index 0000000..7d788f6 --- /dev/null +++ b/ec_user/migrations/0017_alter_awardsinfo_award_date_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.19 on 2025-03-01 14:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ec_user', '0016_awardsinfo_punishmentsinfo_alter_ecuser_age_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='awardsinfo', + name='award_date', + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name='awardsinfo', + name='award_name', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AlterField( + model_name='awardsinfo', + name='award_organization', + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/ec_user/models.py b/ec_user/models.py index 1e8c013..e29c876 100644 --- a/ec_user/models.py +++ b/ec_user/models.py @@ -229,16 +229,24 @@ class FamilyInfo(models.Model): } return f"Family Info of {self.user.name}" -# AwardsPunishments(奖惩情况表) -class AwardsPunishments(models.Model): +# Awards(奖情况表) +class AwardsInfo(models.Model): + # 定义一个与EcUser一对多关联的外键 + user = models.ForeignKey(EcUser, on_delete=models.CASCADE) + award_name = models.CharField(max_length=100,null=True, blank=True) + award_date = models.DateField(null=True, blank=True) + award_organization = models.CharField(max_length=100, null=True, blank=True) + + def __str__(self): + return f"Awards of {self.user.name}" + +# Punishments(处分情况表) +class PunishmentsInfo(models.Model): # 定义一个与EcUser一对多关联的外键 user = models.ForeignKey(EcUser, on_delete=models.CASCADE) - award_name = models.CharField(max_length=100) - award_date = models.DateField() - award_organization = models.CharField(max_length=100) discipline_date = models.DateField(null=True, blank=True) discipline_issue = models.CharField(max_length=255, null=True, blank=True) discipline_outcome = models.CharField(max_length=255, null=True, blank=True) def __str__(self): - return f"Awards and Punishments of {self.user.name}" + return f"Punishments of {self.user.name}" \ No newline at end of file diff --git a/ec_user/templates/all_info_form.html b/ec_user/templates/all_info_form.html index 3aa7dcb..877b9b6 100644 --- a/ec_user/templates/all_info_form.html +++ b/ec_user/templates/all_info_form.html @@ -269,17 +269,33 @@ -
+ +