From fd5e20e1dd2efa40970c6f3a1b54066c7ece3772 Mon Sep 17 00:00:00 2001 From: shabirtech Date: Sat, 13 May 2023 15:33:23 +0500 Subject: [PATCH 1/7] added Cnic field in teacher model --- requirements.txt | 2 +- .../0002_alter_studentfee_valid_until.py | 19 ++++++++ teachers/admin.py | 3 +- ...acher_cnic_teachersalary_financesummary.py | 44 +++++++++++++++++++ teachers/models.py | 1 + 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 students/migrations/0002_alter_studentfee_valid_until.py create mode 100644 teachers/migrations/0002_teacher_cnic_teachersalary_financesummary.py diff --git a/requirements.txt b/requirements.txt index d7f0f0f3..de904476 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ django-debug-toolbar django-filter django-flat-responsive django-flat-theme -django +django==4.2.1 pillow pytz sqlparse diff --git a/students/migrations/0002_alter_studentfee_valid_until.py b/students/migrations/0002_alter_studentfee_valid_until.py new file mode 100644 index 00000000..986be257 --- /dev/null +++ b/students/migrations/0002_alter_studentfee_valid_until.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.1 on 2023-05-13 10:31 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('students', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='studentfee', + name='valid_until', + field=models.DateField(default=datetime.date(2023, 6, 1), verbose_name='Valid Until'), + ), + ] diff --git a/teachers/admin.py b/teachers/admin.py index 0eb5b0e9..7ca2b0fe 100644 --- a/teachers/admin.py +++ b/teachers/admin.py @@ -5,7 +5,8 @@ from django.contrib.auth.admin import UserAdmin from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User -from django.utils.translation import ugettext_lazy as _ +# from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.db.models import Sum from django.db.models.functions import Trunc diff --git a/teachers/migrations/0002_teacher_cnic_teachersalary_financesummary.py b/teachers/migrations/0002_teacher_cnic_teachersalary_financesummary.py new file mode 100644 index 00000000..f5022397 --- /dev/null +++ b/teachers/migrations/0002_teacher_cnic_teachersalary_financesummary.py @@ -0,0 +1,44 @@ +# Generated by Django 4.2.1 on 2023-05-13 10:31 + +import datetime +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('teachers', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='teacher', + name='cnic', + field=models.CharField(default='added fields', max_length=13), + preserve_default=False, + ), + migrations.CreateModel( + name='TeacherSalary', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('valid_until', models.DateField(default=datetime.date(2023, 6, 1), verbose_name='Valid Until')), + ('total_amount', models.PositiveIntegerField(default=0)), + ('paid_on', models.DateTimeField(auto_now_add=True)), + ('teacher', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='teachers.teacher')), + ], + ), + migrations.CreateModel( + name='FinanceSummary', + fields=[ + ], + options={ + 'verbose_name': 'Finance Summary', + 'verbose_name_plural': 'Finance Summary', + 'proxy': True, + 'indexes': [], + 'constraints': [], + }, + bases=('teachers.teachersalary',), + ), + ] diff --git a/teachers/models.py b/teachers/models.py index 9a6459a2..e5165e67 100644 --- a/teachers/models.py +++ b/teachers/models.py @@ -17,6 +17,7 @@ class Teacher(models.Model): date_of_birth = models.DateField() social_security_number = models.CharField(max_length=30) phone_no = models.CharField(max_length=11, default="0000000") + cnic = models.CharField(max_length=13) address = models.CharField(max_length=150, default="Not Set") is_teaching = models.BooleanField(default=True) profile_image = models.ImageField(upload_to=user_directory_path, blank=True) From 8abce3e2b8aa341df7425cc6d8ad5f32e3d24db3 Mon Sep 17 00:00:00 2001 From: shabirtech Date: Tue, 16 May 2023 18:15:30 +0500 Subject: [PATCH 2/7] create models in admission --- admission/__init__.py | 0 admission/admin.py | 10 +++ admission/apps.py | 6 ++ admission/forms.py | 33 +++++++ admission/migrations/0001_initial.py | 85 +++++++++++++++++++ .../0002_personalinformation_admission_no.py | 19 +++++ admission/migrations/__init__.py | 0 admission/models.py | 83 ++++++++++++++++++ admission/tests.py | 3 + admission/urls.py | 12 +++ admission/views.py | 83 ++++++++++++++++++ easyschool/settings.py | 3 +- easyschool/urls.py | 1 + templates/admission/admission_form.html | 20 +++++ .../educational_background_form.html | 12 +++ .../admission/emergency_contact_form.html | 13 +++ templates/admission/parent_guardian_form.html | 28 ++++++ .../admission/personal_information_form.html | 11 +++ templates/admission/success_page.html | 1 + templates/process_application.html | 6 ++ 20 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 admission/__init__.py create mode 100644 admission/admin.py create mode 100644 admission/apps.py create mode 100644 admission/forms.py create mode 100644 admission/migrations/0001_initial.py create mode 100644 admission/migrations/0002_personalinformation_admission_no.py create mode 100644 admission/migrations/__init__.py create mode 100644 admission/models.py create mode 100644 admission/tests.py create mode 100644 admission/urls.py create mode 100644 admission/views.py create mode 100644 templates/admission/admission_form.html create mode 100644 templates/admission/educational_background_form.html create mode 100644 templates/admission/emergency_contact_form.html create mode 100644 templates/admission/parent_guardian_form.html create mode 100644 templates/admission/personal_information_form.html create mode 100644 templates/admission/success_page.html create mode 100644 templates/process_application.html diff --git a/admission/__init__.py b/admission/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/admission/admin.py b/admission/admin.py new file mode 100644 index 00000000..49110511 --- /dev/null +++ b/admission/admin.py @@ -0,0 +1,10 @@ +from django.contrib import admin +from admission.models import * +# Register your models here. + +admin.site.register(PersonalInformation) +admin.site.register(EducationalBackground) +admin.site.register(EmergencyContact) +admin.site.register(ParentGuardian) +admin.site.register(AdmissionForm) + diff --git a/admission/apps.py b/admission/apps.py new file mode 100644 index 00000000..c15ab3f7 --- /dev/null +++ b/admission/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AdmissionConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'admission' diff --git a/admission/forms.py b/admission/forms.py new file mode 100644 index 00000000..73cfdc6f --- /dev/null +++ b/admission/forms.py @@ -0,0 +1,33 @@ +from django import forms + +from admission.models import * + + + +class PersonalInformationForm(forms.ModelForm): + class Meta: + model = PersonalInformation + fields = '__all__' + +class EducationalBackgroundForm(forms.ModelForm): + class Meta: + model = EducationalBackground + fields = '__all__' + + +class ParentGuardianForm(forms.ModelForm): + class Meta: + model = ParentGuardian + fields = '__all__' + + +class EmergencyContactForm(forms.ModelForm): + class Meta: + model = EmergencyContact + fields = '__all__' + + +class AdmissionFormForm(forms.ModelForm): + class Meta: + model = AdmissionForm + fields = '__all__' diff --git a/admission/migrations/0001_initial.py b/admission/migrations/0001_initial.py new file mode 100644 index 00000000..5ee51ede --- /dev/null +++ b/admission/migrations/0001_initial.py @@ -0,0 +1,85 @@ +# Generated by Django 4.2.1 on 2023-05-16 09:37 + +import admission.models +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('course', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='EducationalBackground', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('current_school_name', models.CharField(max_length=100)), + ('current_school_address', models.CharField(max_length=200)), + ('current_school_city', models.CharField(max_length=100)), + ('current_school_state_province', models.CharField(max_length=100)), + ('current_school_postal_code', models.CharField(max_length=20)), + ('current_school_country', models.CharField(max_length=100)), + ('grade_level', models.CharField(max_length=50)), + ('dates_attended', models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name='EmergencyContact', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('relationship', models.CharField(max_length=100)), + ('phone_number', models.CharField(max_length=20)), + ], + ), + migrations.CreateModel( + name='ParentGuardian', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('relationship', models.CharField(max_length=100)), + ('phone_number', models.CharField(max_length=20)), + ('email', models.EmailField(max_length=254)), + ], + ), + migrations.CreateModel( + name='PersonalInformation', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=30)), + ('last_name', models.CharField(max_length=30)), + ('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female')], max_length=1)), + ('date_of_birth', models.DateField()), + ('address', models.CharField(default='Not Set', max_length=150)), + ('city', models.CharField(default='Not Set', max_length=100)), + ('state', models.CharField(max_length=100)), + ('post_code', models.BigIntegerField()), + ('phone_number', models.IntegerField(max_length=11)), + ('email', models.EmailField(max_length=254)), + ('date_of_admissionapplication', models.DateField(auto_now_add=True)), + ('profile_image', models.ImageField(blank=True, upload_to=admission.models.user_directory_path)), + ], + ), + migrations.CreateModel( + name='AdmissionForm', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('additional_information', models.TextField()), + ('signature_applicant', models.CharField(max_length=100)), + ('date_signed', models.DateField()), + ('signature_parent_guardian', models.CharField(max_length=100)), + ('date_parent_guardian_signed', models.DateField()), + ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.course')), + ('educational_background', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='admission.educationalbackground')), + ('emergency_contact', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='admission.emergencycontact')), + ('guardian1', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='guardian1', to='admission.parentguardian')), + ('guardian2', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='guardian2', to='admission.parentguardian')), + ('personal_information', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='admission.personalinformation')), + ], + ), + ] diff --git a/admission/migrations/0002_personalinformation_admission_no.py b/admission/migrations/0002_personalinformation_admission_no.py new file mode 100644 index 00000000..d43f6a10 --- /dev/null +++ b/admission/migrations/0002_personalinformation_admission_no.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.1 on 2023-05-16 09:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('admission', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='personalinformation', + name='admission_no', + field=models.IntegerField(auto_created=True, default=1), + preserve_default=False, + ), + ] diff --git a/admission/migrations/__init__.py b/admission/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/admission/models.py b/admission/models.py new file mode 100644 index 00000000..4e6ab54c --- /dev/null +++ b/admission/models.py @@ -0,0 +1,83 @@ +from django.db import models +from course.models import Course +# Create your models here. + +from easyschool.utils import GENDER_CHOICES +def user_directory_path(instance, filename): + return 'user_{0}/{1}'.format(instance.admission_no, filename) + +class PersonalInformation(models.Model): + admission_no = models.IntegerField(auto_created=True) + first_name = models.CharField(max_length=30) + last_name = models.CharField(max_length=30) + gender = models.CharField(max_length=1, choices=GENDER_CHOICES) + date_of_birth = models.DateField() + address = models.CharField(max_length=150, default="Not Set") + city = models.CharField(max_length=100, default="Not Set") + state = models.CharField(max_length=100) + post_code = models.BigIntegerField() + phone_number = models.IntegerField(max_length=11) + email = models.EmailField() + date_of_admissionapplication = models.DateField(auto_now_add=True) + profile_image = models.ImageField(upload_to=user_directory_path, blank=True) + def __str__(self): + return self.full_name() + + def full_name(self): + return '{} {}'.format(self.first_name, self.last_name).capitalize() + + + + + + +class EducationalBackground(models.Model): + current_school_name = models.CharField(max_length=100) + current_school_address = models.CharField(max_length=200) + current_school_city = models.CharField(max_length=100) + current_school_state_province = models.CharField(max_length=100) + current_school_postal_code = models.CharField(max_length=20) + current_school_country = models.CharField(max_length=100) + grade_level = models.CharField(max_length=50) + dates_attended = models.CharField(max_length=100) + + def __str__(self): + return self.current_school_name + + + +class ParentGuardian(models.Model): + name = models.CharField(max_length=100) + relationship = models.CharField(max_length=100) + phone_number = models.CharField(max_length=20) + email = models.EmailField() + + def __str__(self): + return self.name + + +class EmergencyContact(models.Model): + name = models.CharField(max_length=100) + relationship = models.CharField(max_length=100) + phone_number = models.CharField(max_length=20) + + def __str__(self): + return self.name + + +class AdmissionForm(models.Model): + course =models.ForeignKey(Course, on_delete=models.CASCADE) + personal_information = models.OneToOneField(PersonalInformation, on_delete=models.CASCADE) + educational_background = models.OneToOneField(EducationalBackground, on_delete=models.CASCADE) + guardian1 = models.OneToOneField(ParentGuardian, on_delete=models.CASCADE, related_name='guardian1') + guardian2 = models.OneToOneField(ParentGuardian, on_delete=models.CASCADE, related_name='guardian2') + emergency_contact = models.OneToOneField(EmergencyContact, on_delete=models.CASCADE) + additional_information = models.TextField() + + signature_applicant = models.CharField(max_length=100) + date_signed = models.DateField() + signature_parent_guardian = models.CharField(max_length=100) + date_parent_guardian_signed = models.DateField() + + def __str__(self): + return self.personal_information.full_name \ No newline at end of file diff --git a/admission/tests.py b/admission/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/admission/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/admission/urls.py b/admission/urls.py new file mode 100644 index 00000000..6bfe0cf4 --- /dev/null +++ b/admission/urls.py @@ -0,0 +1,12 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('personal-information/', views.personal_information_view, name='personal_information_form'), + path('educational-background/', views.educational_background_view, name='educational_background_form'), + path('parent-guardian/', views.parent_guardian_view, name='parent_guardian_form'), + path('parent-guardian2/', views.parent_guardian_view2, name='parent_guardian_form2'), + path('emergency-contact/', views.emergency_contact_view, name='emergency_contact_form'), + path('admission-form/', views.admission_form_view, name='admission_form'), + path('success/', views.success_page, name='success_page'), +] \ No newline at end of file diff --git a/admission/views.py b/admission/views.py new file mode 100644 index 00000000..1d3349e2 --- /dev/null +++ b/admission/views.py @@ -0,0 +1,83 @@ +from django.shortcuts import render, redirect +from .forms import PersonalInformationForm, EducationalBackgroundForm, ParentGuardianForm, EmergencyContactForm, AdmissionFormForm + + + + +def personal_information_view(request): + if request.method == 'POST': + form = PersonalInformationForm(request.POST) + if form.is_valid(): + form.save() + return redirect('educational_background_form') + else: + form = PersonalInformationForm() + + return render(request, 'admission/personal_information_form.html', {'form': form}) + + + + + +def educational_background_view(request): + if request.method == 'POST': + form = EducationalBackgroundForm(request.POST) + if form.is_valid(): + form.save() + return redirect('parent_guardian_form') + else: + form = EducationalBackgroundForm() + + return render(request, 'admission/educational_background_form.html', {'form': form}) + + +def parent_guardian_view(request): + if request.method == 'POST': + form = ParentGuardianForm(request.POST, prefix='guardian1') + if form.is_valid(): + form.save() + return redirect('parent_guardian_form2') + else: + form = ParentGuardianForm(prefix='guardian1') + + return render(request, 'admission/parent_guardian_form.html', {'form': form}) + + +def parent_guardian_view2(request): + if request.method == 'POST': + form = ParentGuardianForm(request.POST, prefix='guardian2') + if form.is_valid(): + form.save() + return redirect('emergency_contact_form') + else: + form = ParentGuardianForm(prefix='guardian2') + + return render(request, 'parent_guardian_form.html', {'form': form}) + + +def emergency_contact_view(request): + if request.method == 'POST': + form = EmergencyContactForm(request.POST) + if form.is_valid(): + form.save() + return redirect('admission_form') + else: + form = EmergencyContactForm() + + return render(request, 'admission/emergency_contact_form.html', {'form': form}) + + +def admission_form_view(request): + if request.method == 'POST': + form = AdmissionFormForm(request.POST) + if form.is_valid(): + form.save() + return redirect('success_page') + else: + form = AdmissionFormForm() + + return render(request, 'admission/admission_form.html', {'form': form}) + + +def success_page(request): + return render(request, 'admission/success_page.html') diff --git a/easyschool/settings.py b/easyschool/settings.py index 960bf963..b24f003a 100644 --- a/easyschool/settings.py +++ b/easyschool/settings.py @@ -44,7 +44,8 @@ 'course.apps.CourseConfig', 'debug_toolbar', 'teachers.apps.TeachersConfig', - 'django.contrib.humanize' + 'django.contrib.humanize', + "admission", ] MIDDLEWARE = [ diff --git a/easyschool/urls.py b/easyschool/urls.py index 65ac3c48..999e7c38 100644 --- a/easyschool/urls.py +++ b/easyschool/urls.py @@ -11,6 +11,7 @@ path('admin/', admin.site.urls), path('signup/', views.TeacherSignUpFormView.as_view(), name='signup'), path('login/', views.login, name='login'), + path("admission/", include("admission.urls")), ] if settings.DEBUG: import debug_toolbar # Add debugging urls diff --git a/templates/admission/admission_form.html b/templates/admission/admission_form.html new file mode 100644 index 00000000..f0cc9627 --- /dev/null +++ b/templates/admission/admission_form.html @@ -0,0 +1,20 @@ +
+ + + {% csrf_token %} +

Admission Form

+ + + {% include 'admission/personal_information_form.html' %} + {% include 'admission/educational_background_form.html' %} + {% include 'admission/parent_guardian_form.html' %} + {% include 'admission/emergency_contact_form.html' %} + + +
+ + +
+ + +
\ No newline at end of file diff --git a/templates/admission/educational_background_form.html b/templates/admission/educational_background_form.html new file mode 100644 index 00000000..59039002 --- /dev/null +++ b/templates/admission/educational_background_form.html @@ -0,0 +1,12 @@ +
+ {% csrf_token %} +

Educational Background

+
+ + +
+ + + +
+ \ No newline at end of file diff --git a/templates/admission/emergency_contact_form.html b/templates/admission/emergency_contact_form.html new file mode 100644 index 00000000..1296b9a3 --- /dev/null +++ b/templates/admission/emergency_contact_form.html @@ -0,0 +1,13 @@ + +
+ {% csrf_token %} +

Emergency Contact

+
+ + +
+ + + +
+ \ No newline at end of file diff --git a/templates/admission/parent_guardian_form.html b/templates/admission/parent_guardian_form.html new file mode 100644 index 00000000..4b093db7 --- /dev/null +++ b/templates/admission/parent_guardian_form.html @@ -0,0 +1,28 @@ + + +
+ {% csrf_token %} +

Parent/Guardian Information

+

Guardian 1

+
+ + +
+ + + +
+ + +
+ {% csrf_token %} +

Guardian 2

+
+ + +
+ + + +
+ \ No newline at end of file diff --git a/templates/admission/personal_information_form.html b/templates/admission/personal_information_form.html new file mode 100644 index 00000000..34e67944 --- /dev/null +++ b/templates/admission/personal_information_form.html @@ -0,0 +1,11 @@ +
+ {% csrf_token %} +

Personal Information

+
+ + +
+ + + +
\ No newline at end of file diff --git a/templates/admission/success_page.html b/templates/admission/success_page.html new file mode 100644 index 00000000..2e87f037 --- /dev/null +++ b/templates/admission/success_page.html @@ -0,0 +1 @@ +hey guys \ No newline at end of file diff --git a/templates/process_application.html b/templates/process_application.html new file mode 100644 index 00000000..ce3f249f --- /dev/null +++ b/templates/process_application.html @@ -0,0 +1,6 @@ +
+ {% csrf_token %} + +
+ + \ No newline at end of file From 5b6944e5b3aef249de7999fcba40339a8528afc0 Mon Sep 17 00:00:00 2001 From: shabirtech Date: Tue, 16 May 2023 18:52:46 +0500 Subject: [PATCH 3/7] add form page --- admission/models.py | 2 +- admission/views.py | 2 +- templates/admission/admission_form.html | 6 ++++-- .../admission/educational_background_form.html | 9 ++------- templates/admission/emergency_contact_form.html | 8 +++++--- templates/admission/parent_guardian_form.html | 16 ++++++---------- .../admission/personal_information_form.html | 6 +----- templates/admission/success_page.html | 4 +++- 8 files changed, 23 insertions(+), 30 deletions(-) diff --git a/admission/models.py b/admission/models.py index 4e6ab54c..2569dc30 100644 --- a/admission/models.py +++ b/admission/models.py @@ -80,4 +80,4 @@ class AdmissionForm(models.Model): date_parent_guardian_signed = models.DateField() def __str__(self): - return self.personal_information.full_name \ No newline at end of file + return f"{self.personal_information.first_name} {self.personal_information.last_name}" \ No newline at end of file diff --git a/admission/views.py b/admission/views.py index 1d3349e2..808b4342 100644 --- a/admission/views.py +++ b/admission/views.py @@ -52,7 +52,7 @@ def parent_guardian_view2(request): else: form = ParentGuardianForm(prefix='guardian2') - return render(request, 'parent_guardian_form.html', {'form': form}) + return render(request, 'admission/parent_guardian_form.html', {'form': form}) def emergency_contact_view(request): diff --git a/templates/admission/admission_form.html b/templates/admission/admission_form.html index f0cc9627..49f4d1c6 100644 --- a/templates/admission/admission_form.html +++ b/templates/admission/admission_form.html @@ -5,7 +5,7 @@

Admission Form

- {% include 'admission/personal_information_form.html' %} + {% comment %} {% include 'admission/personal_information_form.html' %} {% include 'admission/educational_background_form.html' %} {% include 'admission/parent_guardian_form.html' %} {% include 'admission/emergency_contact_form.html' %} @@ -14,7 +14,9 @@

Admission Form

-
+ {% endcomment %} + + {{ form.as_p }} \ No newline at end of file diff --git a/templates/admission/educational_background_form.html b/templates/admission/educational_background_form.html index 59039002..9edf615f 100644 --- a/templates/admission/educational_background_form.html +++ b/templates/admission/educational_background_form.html @@ -1,12 +1,7 @@
{% csrf_token %}

Educational Background

-
- - -
- - + {{ form.as_p }}
- \ No newline at end of file + \ No newline at end of file diff --git a/templates/admission/emergency_contact_form.html b/templates/admission/emergency_contact_form.html index 1296b9a3..b538253a 100644 --- a/templates/admission/emergency_contact_form.html +++ b/templates/admission/emergency_contact_form.html @@ -1,13 +1,15 @@ - +
{% csrf_token %}

Emergency Contact

-
+ {% comment %}
- + {% endcomment %} + + {{ form.as_p }} \ No newline at end of file diff --git a/templates/admission/parent_guardian_form.html b/templates/admission/parent_guardian_form.html index 4b093db7..3a89908c 100644 --- a/templates/admission/parent_guardian_form.html +++ b/templates/admission/parent_guardian_form.html @@ -1,15 +1,15 @@ - - +
{% csrf_token %}

Parent/Guardian Information

Guardian 1

-
+ {% comment %}
- + {% endcomment %} + {{ form.as_p }} @@ -17,12 +17,8 @@

Guardian 1

{% csrf_token %}

Guardian 2

-
- - -
- - + + {{ form.as_p }}
\ No newline at end of file diff --git a/templates/admission/personal_information_form.html b/templates/admission/personal_information_form.html index 34e67944..afd05652 100644 --- a/templates/admission/personal_information_form.html +++ b/templates/admission/personal_information_form.html @@ -1,11 +1,7 @@
{% csrf_token %}

Personal Information

-
- - -
- + {{ form.as_p }}
\ No newline at end of file diff --git a/templates/admission/success_page.html b/templates/admission/success_page.html index 2e87f037..8a38427a 100644 --- a/templates/admission/success_page.html +++ b/templates/admission/success_page.html @@ -1 +1,3 @@ -hey guys \ No newline at end of file + + +form submit successfully \ No newline at end of file From 99f143d2ca0d5c4f3ca023e4e510037e4d1daf7a Mon Sep 17 00:00:00 2001 From: shabirtech Date: Fri, 19 May 2023 13:48:12 +0500 Subject: [PATCH 4/7] some changes in models --- admission/admin.py | 2 +- admission/forms.py | 6 +-- .../migrations/0003_guardian_and_more.py | 40 +++++++++++++++++++ .../0004_alter_admissionform_date_signed.py | 18 +++++++++ admission/models.py | 16 ++------ admission/views.py | 21 ++++++++-- 6 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 admission/migrations/0003_guardian_and_more.py create mode 100644 admission/migrations/0004_alter_admissionform_date_signed.py diff --git a/admission/admin.py b/admission/admin.py index 49110511..f8b2649c 100644 --- a/admission/admin.py +++ b/admission/admin.py @@ -5,6 +5,6 @@ admin.site.register(PersonalInformation) admin.site.register(EducationalBackground) admin.site.register(EmergencyContact) -admin.site.register(ParentGuardian) +admin.site.register(Guardian) admin.site.register(AdmissionForm) diff --git a/admission/forms.py b/admission/forms.py index 73cfdc6f..a68c3e58 100644 --- a/admission/forms.py +++ b/admission/forms.py @@ -17,8 +17,8 @@ class Meta: class ParentGuardianForm(forms.ModelForm): class Meta: - model = ParentGuardian - fields = '__all__' + model = Guardian + fields = ("name","relationship","phone_number","email",) class EmergencyContactForm(forms.ModelForm): @@ -30,4 +30,4 @@ class Meta: class AdmissionFormForm(forms.ModelForm): class Meta: model = AdmissionForm - fields = '__all__' + fields = ("course","additional_information","signature_applicant",'signature_parent_guardian',) diff --git a/admission/migrations/0003_guardian_and_more.py b/admission/migrations/0003_guardian_and_more.py new file mode 100644 index 00000000..848e43e1 --- /dev/null +++ b/admission/migrations/0003_guardian_and_more.py @@ -0,0 +1,40 @@ +# Generated by Django 4.2.1 on 2023-05-19 07:01 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('admission', '0002_personalinformation_admission_no'), + ] + + operations = [ + migrations.CreateModel( + name='Guardian', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('relationship', models.CharField(max_length=100)), + ('phone_number', models.CharField(max_length=20)), + ('email', models.EmailField(max_length=254)), + ('personal_information', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='guardian', to='admission.personalinformation')), + ], + ), + migrations.RemoveField( + model_name='admissionform', + name='date_parent_guardian_signed', + ), + migrations.RemoveField( + model_name='admissionform', + name='guardian1', + ), + migrations.RemoveField( + model_name='admissionform', + name='guardian2', + ), + migrations.DeleteModel( + name='ParentGuardian', + ), + ] diff --git a/admission/migrations/0004_alter_admissionform_date_signed.py b/admission/migrations/0004_alter_admissionform_date_signed.py new file mode 100644 index 00000000..5f126562 --- /dev/null +++ b/admission/migrations/0004_alter_admissionform_date_signed.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.1 on 2023-05-19 07:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('admission', '0003_guardian_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='admissionform', + name='date_signed', + field=models.DateField(auto_now_add=True), + ), + ] diff --git a/admission/models.py b/admission/models.py index 2569dc30..2c63bce4 100644 --- a/admission/models.py +++ b/admission/models.py @@ -24,12 +24,7 @@ def __str__(self): return self.full_name() def full_name(self): - return '{} {}'.format(self.first_name, self.last_name).capitalize() - - - - - + return '{} {}'.format(self.first_name, self.last_name).capitalize() class EducationalBackground(models.Model): current_school_name = models.CharField(max_length=100) @@ -46,7 +41,8 @@ def __str__(self): -class ParentGuardian(models.Model): +class Guardian(models.Model): + personal_information = models.ForeignKey(PersonalInformation, on_delete=models.CASCADE, related_name='guardian') name = models.CharField(max_length=100) relationship = models.CharField(max_length=100) phone_number = models.CharField(max_length=20) @@ -69,15 +65,11 @@ class AdmissionForm(models.Model): course =models.ForeignKey(Course, on_delete=models.CASCADE) personal_information = models.OneToOneField(PersonalInformation, on_delete=models.CASCADE) educational_background = models.OneToOneField(EducationalBackground, on_delete=models.CASCADE) - guardian1 = models.OneToOneField(ParentGuardian, on_delete=models.CASCADE, related_name='guardian1') - guardian2 = models.OneToOneField(ParentGuardian, on_delete=models.CASCADE, related_name='guardian2') emergency_contact = models.OneToOneField(EmergencyContact, on_delete=models.CASCADE) additional_information = models.TextField() - signature_applicant = models.CharField(max_length=100) - date_signed = models.DateField() signature_parent_guardian = models.CharField(max_length=100) - date_parent_guardian_signed = models.DateField() + date_signed = models.DateField(auto_now_add=True) def __str__(self): return f"{self.personal_information.first_name} {self.personal_information.last_name}" \ No newline at end of file diff --git a/admission/views.py b/admission/views.py index 808b4342..2e668cd1 100644 --- a/admission/views.py +++ b/admission/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render, redirect from .forms import PersonalInformationForm, EducationalBackgroundForm, ParentGuardianForm, EmergencyContactForm, AdmissionFormForm - +from .models import PersonalInformation, EducationalBackground, EmergencyContact @@ -34,8 +34,11 @@ def educational_background_view(request): def parent_guardian_view(request): if request.method == 'POST': form = ParentGuardianForm(request.POST, prefix='guardian1') + person_data = PersonalInformation.objects.order_by('-id').first() if form.is_valid(): - form.save() + personal_info = form.save(commit=False) + personal_info.personal_information = person_data + personal_info.save() return redirect('parent_guardian_form2') else: form = ParentGuardianForm(prefix='guardian1') @@ -46,8 +49,11 @@ def parent_guardian_view(request): def parent_guardian_view2(request): if request.method == 'POST': form = ParentGuardianForm(request.POST, prefix='guardian2') + person_data = PersonalInformation.objects.order_by('-id').first() if form.is_valid(): - form.save() + personal_info = form.save(commit=False) + personal_info.personal_information = person_data + personal_info.save() return redirect('emergency_contact_form') else: form = ParentGuardianForm(prefix='guardian2') @@ -70,8 +76,15 @@ def emergency_contact_view(request): def admission_form_view(request): if request.method == 'POST': form = AdmissionFormForm(request.POST) + person_data = PersonalInformation.objects.order_by('-id').first() + contact = EmergencyContact.objects.order_by('-id').first() + education = EducationalBackground.objects.order_by('-id').first() if form.is_valid(): - form.save() + personal_info = form.save(commit=False) + personal_info.personal_information = person_data + personal_info.emergency_contact = contact + personal_info.educational_background = education + personal_info.save() return redirect('success_page') else: form = AdmissionFormForm() From d05a17602106df5f3d858edea0520c3a9291b517 Mon Sep 17 00:00:00 2001 From: shabirtech Date: Fri, 19 May 2023 22:29:05 +0500 Subject: [PATCH 5/7] modified model data --- admission/admin.py | 2 +- admission/forms.py | 6 +- admission/migrations/0001_initial.py | 65 +++++++++---------- ...ssionform_personal_information_and_more.py | 24 +++++++ .../0002_personalinformation_admission_no.py | 19 ------ .../migrations/0003_guardian_and_more.py | 40 ------------ .../0004_alter_admissionform_date_signed.py | 18 ----- admission/models.py | 10 +-- admission/urls.py | 2 +- admission/views.py | 46 ++++++------- .../admission/emergency_contact_form.html | 7 +- templates/admission/parent_guardian_form.html | 14 +--- templates/admission/studentsdetail.html | 47 ++++++++++++++ 13 files changed, 138 insertions(+), 162 deletions(-) create mode 100644 admission/migrations/0002_alter_admissionform_personal_information_and_more.py delete mode 100644 admission/migrations/0002_personalinformation_admission_no.py delete mode 100644 admission/migrations/0003_guardian_and_more.py delete mode 100644 admission/migrations/0004_alter_admissionform_date_signed.py create mode 100644 templates/admission/studentsdetail.html diff --git a/admission/admin.py b/admission/admin.py index f8b2649c..50e30b8f 100644 --- a/admission/admin.py +++ b/admission/admin.py @@ -2,7 +2,7 @@ from admission.models import * # Register your models here. -admin.site.register(PersonalInformation) +admin.site.register(StudentPersonalInformation) admin.site.register(EducationalBackground) admin.site.register(EmergencyContact) admin.site.register(Guardian) diff --git a/admission/forms.py b/admission/forms.py index a68c3e58..728154e3 100644 --- a/admission/forms.py +++ b/admission/forms.py @@ -6,13 +6,13 @@ class PersonalInformationForm(forms.ModelForm): class Meta: - model = PersonalInformation + model = StudentPersonalInformation fields = '__all__' class EducationalBackgroundForm(forms.ModelForm): class Meta: model = EducationalBackground - fields = '__all__' + fields = ("current_school_name","current_school_address","current_school_city",'current_school_state_province',"current_school_postal_code",'current_school_country',"grade_level","dates_attended",) class ParentGuardianForm(forms.ModelForm): @@ -24,7 +24,7 @@ class Meta: class EmergencyContactForm(forms.ModelForm): class Meta: model = EmergencyContact - fields = '__all__' + fields = ("name", "relationship", "phone_number",) class AdmissionFormForm(forms.ModelForm): diff --git a/admission/migrations/0001_initial.py b/admission/migrations/0001_initial.py index 5ee51ede..7c8e695a 100644 --- a/admission/migrations/0001_initial.py +++ b/admission/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.1 on 2023-05-16 09:37 +# Generated by Django 4.2.1 on 2023-05-19 15:05 import admission.models from django.db import migrations, models @@ -15,54 +15,58 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='EducationalBackground', + name='StudentPersonalInformation', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('current_school_name', models.CharField(max_length=100)), - ('current_school_address', models.CharField(max_length=200)), - ('current_school_city', models.CharField(max_length=100)), - ('current_school_state_province', models.CharField(max_length=100)), - ('current_school_postal_code', models.CharField(max_length=20)), - ('current_school_country', models.CharField(max_length=100)), - ('grade_level', models.CharField(max_length=50)), - ('dates_attended', models.CharField(max_length=100)), + ('admission_no', models.IntegerField(auto_created=True)), + ('first_name', models.CharField(max_length=30)), + ('last_name', models.CharField(max_length=30)), + ('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female')], max_length=1)), + ('date_of_birth', models.DateField()), + ('address', models.CharField(default='Not Set', max_length=150)), + ('city', models.CharField(default='Not Set', max_length=100)), + ('state', models.CharField(max_length=100)), + ('post_code', models.BigIntegerField()), + ('phone_number', models.IntegerField(max_length=11)), + ('email', models.EmailField(max_length=254)), + ('date_of_admissionapplication', models.DateField(auto_now_add=True)), + ('profile_image', models.ImageField(blank=True, upload_to=admission.models.user_directory_path)), ], ), migrations.CreateModel( - name='EmergencyContact', + name='Guardian', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=100)), ('relationship', models.CharField(max_length=100)), ('phone_number', models.CharField(max_length=20)), + ('email', models.EmailField(max_length=254)), + ('personal_information', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='guardian', to='admission.studentpersonalinformation')), ], ), migrations.CreateModel( - name='ParentGuardian', + name='EmergencyContact', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=100)), ('relationship', models.CharField(max_length=100)), ('phone_number', models.CharField(max_length=20)), - ('email', models.EmailField(max_length=254)), + ('personal_information', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='emergency_contact', to='admission.studentpersonalinformation')), ], ), migrations.CreateModel( - name='PersonalInformation', + name='EducationalBackground', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('first_name', models.CharField(max_length=30)), - ('last_name', models.CharField(max_length=30)), - ('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female')], max_length=1)), - ('date_of_birth', models.DateField()), - ('address', models.CharField(default='Not Set', max_length=150)), - ('city', models.CharField(default='Not Set', max_length=100)), - ('state', models.CharField(max_length=100)), - ('post_code', models.BigIntegerField()), - ('phone_number', models.IntegerField(max_length=11)), - ('email', models.EmailField(max_length=254)), - ('date_of_admissionapplication', models.DateField(auto_now_add=True)), - ('profile_image', models.ImageField(blank=True, upload_to=admission.models.user_directory_path)), + ('current_school_name', models.CharField(max_length=100)), + ('current_school_address', models.CharField(max_length=200)), + ('current_school_city', models.CharField(max_length=100)), + ('current_school_state_province', models.CharField(max_length=100)), + ('current_school_postal_code', models.CharField(max_length=20)), + ('current_school_country', models.CharField(max_length=100)), + ('grade_level', models.CharField(max_length=50)), + ('dates_attended', models.CharField(max_length=100)), + ('personal_information', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='Educational_background', to='admission.studentpersonalinformation')), ], ), migrations.CreateModel( @@ -71,15 +75,10 @@ class Migration(migrations.Migration): ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('additional_information', models.TextField()), ('signature_applicant', models.CharField(max_length=100)), - ('date_signed', models.DateField()), ('signature_parent_guardian', models.CharField(max_length=100)), - ('date_parent_guardian_signed', models.DateField()), + ('date_signed', models.DateField(auto_now_add=True)), ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.course')), - ('educational_background', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='admission.educationalbackground')), - ('emergency_contact', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='admission.emergencycontact')), - ('guardian1', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='guardian1', to='admission.parentguardian')), - ('guardian2', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='guardian2', to='admission.parentguardian')), - ('personal_information', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='admission.personalinformation')), + ('personal_information', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='admission.studentpersonalinformation')), ], ), ] diff --git a/admission/migrations/0002_alter_admissionform_personal_information_and_more.py b/admission/migrations/0002_alter_admissionform_personal_information_and_more.py new file mode 100644 index 00000000..7ccc462b --- /dev/null +++ b/admission/migrations/0002_alter_admissionform_personal_information_and_more.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.1 on 2023-05-19 15:31 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('admission', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='admissionform', + name='personal_information', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='admission_form', to='admission.studentpersonalinformation'), + ), + migrations.AlterField( + model_name='educationalbackground', + name='personal_information', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='educational_background', to='admission.studentpersonalinformation'), + ), + ] diff --git a/admission/migrations/0002_personalinformation_admission_no.py b/admission/migrations/0002_personalinformation_admission_no.py deleted file mode 100644 index d43f6a10..00000000 --- a/admission/migrations/0002_personalinformation_admission_no.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.2.1 on 2023-05-16 09:45 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('admission', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='personalinformation', - name='admission_no', - field=models.IntegerField(auto_created=True, default=1), - preserve_default=False, - ), - ] diff --git a/admission/migrations/0003_guardian_and_more.py b/admission/migrations/0003_guardian_and_more.py deleted file mode 100644 index 848e43e1..00000000 --- a/admission/migrations/0003_guardian_and_more.py +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by Django 4.2.1 on 2023-05-19 07:01 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('admission', '0002_personalinformation_admission_no'), - ] - - operations = [ - migrations.CreateModel( - name='Guardian', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=100)), - ('relationship', models.CharField(max_length=100)), - ('phone_number', models.CharField(max_length=20)), - ('email', models.EmailField(max_length=254)), - ('personal_information', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='guardian', to='admission.personalinformation')), - ], - ), - migrations.RemoveField( - model_name='admissionform', - name='date_parent_guardian_signed', - ), - migrations.RemoveField( - model_name='admissionform', - name='guardian1', - ), - migrations.RemoveField( - model_name='admissionform', - name='guardian2', - ), - migrations.DeleteModel( - name='ParentGuardian', - ), - ] diff --git a/admission/migrations/0004_alter_admissionform_date_signed.py b/admission/migrations/0004_alter_admissionform_date_signed.py deleted file mode 100644 index 5f126562..00000000 --- a/admission/migrations/0004_alter_admissionform_date_signed.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.1 on 2023-05-19 07:20 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('admission', '0003_guardian_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='admissionform', - name='date_signed', - field=models.DateField(auto_now_add=True), - ), - ] diff --git a/admission/models.py b/admission/models.py index 2c63bce4..e396ebed 100644 --- a/admission/models.py +++ b/admission/models.py @@ -6,7 +6,7 @@ def user_directory_path(instance, filename): return 'user_{0}/{1}'.format(instance.admission_no, filename) -class PersonalInformation(models.Model): +class StudentPersonalInformation(models.Model): admission_no = models.IntegerField(auto_created=True) first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -27,6 +27,7 @@ def full_name(self): return '{} {}'.format(self.first_name, self.last_name).capitalize() class EducationalBackground(models.Model): + personal_information = models.OneToOneField(StudentPersonalInformation, on_delete=models.CASCADE, related_name='educational_background') current_school_name = models.CharField(max_length=100) current_school_address = models.CharField(max_length=200) current_school_city = models.CharField(max_length=100) @@ -42,7 +43,7 @@ def __str__(self): class Guardian(models.Model): - personal_information = models.ForeignKey(PersonalInformation, on_delete=models.CASCADE, related_name='guardian') + personal_information = models.ForeignKey(StudentPersonalInformation, on_delete=models.CASCADE, related_name='guardian') name = models.CharField(max_length=100) relationship = models.CharField(max_length=100) phone_number = models.CharField(max_length=20) @@ -53,6 +54,7 @@ def __str__(self): class EmergencyContact(models.Model): + personal_information = models.OneToOneField(StudentPersonalInformation, models.CASCADE, related_name="emergency_contact") name = models.CharField(max_length=100) relationship = models.CharField(max_length=100) phone_number = models.CharField(max_length=20) @@ -63,9 +65,7 @@ def __str__(self): class AdmissionForm(models.Model): course =models.ForeignKey(Course, on_delete=models.CASCADE) - personal_information = models.OneToOneField(PersonalInformation, on_delete=models.CASCADE) - educational_background = models.OneToOneField(EducationalBackground, on_delete=models.CASCADE) - emergency_contact = models.OneToOneField(EmergencyContact, on_delete=models.CASCADE) + personal_information = models.OneToOneField(StudentPersonalInformation, on_delete=models.CASCADE, related_name="admission_form") additional_information = models.TextField() signature_applicant = models.CharField(max_length=100) signature_parent_guardian = models.CharField(max_length=100) diff --git a/admission/urls.py b/admission/urls.py index 6bfe0cf4..ecba7206 100644 --- a/admission/urls.py +++ b/admission/urls.py @@ -5,8 +5,8 @@ path('personal-information/', views.personal_information_view, name='personal_information_form'), path('educational-background/', views.educational_background_view, name='educational_background_form'), path('parent-guardian/', views.parent_guardian_view, name='parent_guardian_form'), - path('parent-guardian2/', views.parent_guardian_view2, name='parent_guardian_form2'), path('emergency-contact/', views.emergency_contact_view, name='emergency_contact_form'), path('admission-form/', views.admission_form_view, name='admission_form'), path('success/', views.success_page, name='success_page'), + path("studentsdetail/", views.studentsdetail, name="studentsdetail") ] \ No newline at end of file diff --git a/admission/views.py b/admission/views.py index 2e668cd1..60dba562 100644 --- a/admission/views.py +++ b/admission/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render, redirect from .forms import PersonalInformationForm, EducationalBackgroundForm, ParentGuardianForm, EmergencyContactForm, AdmissionFormForm -from .models import PersonalInformation, EducationalBackground, EmergencyContact +from .models import StudentPersonalInformation, EducationalBackground, EmergencyContact, AdmissionForm @@ -22,8 +22,11 @@ def personal_information_view(request): def educational_background_view(request): if request.method == 'POST': form = EducationalBackgroundForm(request.POST) + person_data = StudentPersonalInformation.objects.order_by('-id').first() if form.is_valid(): - form.save() + personal_info = form.save(commit=False) + personal_info.personal_information = person_data + personal_info.save() return redirect('parent_guardian_form') else: form = EducationalBackgroundForm() @@ -34,38 +37,29 @@ def educational_background_view(request): def parent_guardian_view(request): if request.method == 'POST': form = ParentGuardianForm(request.POST, prefix='guardian1') - person_data = PersonalInformation.objects.order_by('-id').first() + person_data = StudentPersonalInformation.objects.order_by('-id').first() if form.is_valid(): personal_info = form.save(commit=False) personal_info.personal_information = person_data personal_info.save() - return redirect('parent_guardian_form2') + return redirect('emergency_contact_form') else: form = ParentGuardianForm(prefix='guardian1') return render(request, 'admission/parent_guardian_form.html', {'form': form}) -def parent_guardian_view2(request): - if request.method == 'POST': - form = ParentGuardianForm(request.POST, prefix='guardian2') - person_data = PersonalInformation.objects.order_by('-id').first() - if form.is_valid(): - personal_info = form.save(commit=False) - personal_info.personal_information = person_data - personal_info.save() - return redirect('emergency_contact_form') - else: - form = ParentGuardianForm(prefix='guardian2') - - return render(request, 'admission/parent_guardian_form.html', {'form': form}) + def emergency_contact_view(request): if request.method == 'POST': form = EmergencyContactForm(request.POST) + person_data = StudentPersonalInformation.objects.order_by('-id').first() if form.is_valid(): - form.save() + personal_info = form.save(commit=False) + personal_info.personal_information = person_data + personal_info.save() return redirect('admission_form') else: form = EmergencyContactForm() @@ -76,14 +70,10 @@ def emergency_contact_view(request): def admission_form_view(request): if request.method == 'POST': form = AdmissionFormForm(request.POST) - person_data = PersonalInformation.objects.order_by('-id').first() - contact = EmergencyContact.objects.order_by('-id').first() - education = EducationalBackground.objects.order_by('-id').first() + person_data = StudentPersonalInformation.objects.order_by('-id').first() if form.is_valid(): personal_info = form.save(commit=False) personal_info.personal_information = person_data - personal_info.emergency_contact = contact - personal_info.educational_background = education personal_info.save() return redirect('success_page') else: @@ -94,3 +84,13 @@ def admission_form_view(request): def success_page(request): return render(request, 'admission/success_page.html') + + + +def studentsdetail(request): + + detail = StudentPersonalInformation.objects.all() + + return render(request ,"admission/studentsdetail.html",{ + "details":detail, + }) \ No newline at end of file diff --git a/templates/admission/emergency_contact_form.html b/templates/admission/emergency_contact_form.html index b538253a..148e88ff 100644 --- a/templates/admission/emergency_contact_form.html +++ b/templates/admission/emergency_contact_form.html @@ -2,12 +2,7 @@
{% csrf_token %}

Emergency Contact

- {% comment %}
- - -
- - {% endcomment %} + {{ form.as_p }} diff --git a/templates/admission/parent_guardian_form.html b/templates/admission/parent_guardian_form.html index 3a89908c..a784b0af 100644 --- a/templates/admission/parent_guardian_form.html +++ b/templates/admission/parent_guardian_form.html @@ -3,22 +3,10 @@ {% csrf_token %}

Parent/Guardian Information

Guardian 1

- {% comment %}
- - -
- - {% endcomment %} + {{ form.as_p }}
- - -
- {% csrf_token %} -

Guardian 2

- {{ form.as_p }} -
\ No newline at end of file diff --git a/templates/admission/studentsdetail.html b/templates/admission/studentsdetail.html new file mode 100644 index 00000000..603f412d --- /dev/null +++ b/templates/admission/studentsdetail.html @@ -0,0 +1,47 @@ + +{% for detail in details%} + + +{{detail.first_name}} +{{detail.educational_background.current_school_name}} +{% for guardian in detail.guardian.all %} + {{guardian.relationship}} +{% endfor %} +{{detail.emergency_contact.name}} +{{detail.admission_form.course}} + + + + +{% endfor %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#FirstLastHandle
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
\ No newline at end of file From 5cf208bb7cdc83030b398c06941e27ffe772855c Mon Sep 17 00:00:00 2001 From: shabirtech Date: Sat, 20 May 2023 14:21:40 +0500 Subject: [PATCH 6/7] data sent from studentinfo model to student --- admission/urls.py | 4 ++- admission/views.py | 34 ++++++++++++++++++++++--- templates/admission/studentsdetail.html | 34 +++---------------------- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/admission/urls.py b/admission/urls.py index ecba7206..e4cd0f5f 100644 --- a/admission/urls.py +++ b/admission/urls.py @@ -8,5 +8,7 @@ path('emergency-contact/', views.emergency_contact_view, name='emergency_contact_form'), path('admission-form/', views.admission_form_view, name='admission_form'), path('success/', views.success_page, name='success_page'), - path("studentsdetail/", views.studentsdetail, name="studentsdetail") + path("studentsdetail/", views.studentsdetail, name="studentsdetail"), + path("shift_data_view/",views.shift_data_view, name='shift_data_view') + ] \ No newline at end of file diff --git a/admission/views.py b/admission/views.py index 60dba562..f564ca65 100644 --- a/admission/views.py +++ b/admission/views.py @@ -1,7 +1,7 @@ from django.shortcuts import render, redirect from .forms import PersonalInformationForm, EducationalBackgroundForm, ParentGuardianForm, EmergencyContactForm, AdmissionFormForm -from .models import StudentPersonalInformation, EducationalBackground, EmergencyContact, AdmissionForm - +from .models import StudentPersonalInformation +from students.models import Student def personal_information_view(request): @@ -88,9 +88,37 @@ def success_page(request): def studentsdetail(request): - detail = StudentPersonalInformation.objects.all() + return render(request ,"admission/studentsdetail.html",{ "details":detail, + }) + + + + +def shift_data_view(request, pk): + if request.method == 'POST': + personal_info_queryset = StudentPersonalInformation.objects.filter(pk=pk) + if personal_info_queryset.exists(): + personal_info = personal_info_queryset.first() + student = Student( + admission_no=personal_info.admission_no, + date_of_admission=personal_info.date_of_admissionapplication, + first_name=personal_info.first_name, + last_name=personal_info.last_name, + gender=personal_info.gender, + date_of_birth=personal_info.date_of_birth, + address=personal_info.address, + current_class=personal_info.admission_form.course, + profile_image=personal_info.profile_image, + is_studying = True, + ) + student.save() + + return redirect('success_page') + + return render(request, 'admission/studentsdetail.html',{ + 'student':student, }) \ No newline at end of file diff --git a/templates/admission/studentsdetail.html b/templates/admission/studentsdetail.html index 603f412d..39af6108 100644 --- a/templates/admission/studentsdetail.html +++ b/templates/admission/studentsdetail.html @@ -11,37 +11,11 @@ {{detail.admission_form.course}} +
+ {% csrf_token %} + +
{% endfor %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#FirstLastHandle
1MarkOtto@mdo
2JacobThornton@fat
3Larry the Bird@twitter
\ No newline at end of file From a710589727b38f6ba8c1c162f599c448909fbd4e Mon Sep 17 00:00:00 2001 From: shabirtech Date: Sat, 20 May 2023 14:22:35 +0500 Subject: [PATCH 7/7] data send from info model to student