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..50e30b8f --- /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(StudentPersonalInformation) +admin.site.register(EducationalBackground) +admin.site.register(EmergencyContact) +admin.site.register(Guardian) +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..728154e3 --- /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 = StudentPersonalInformation + fields = '__all__' + +class EducationalBackgroundForm(forms.ModelForm): + class Meta: + model = EducationalBackground + 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): + class Meta: + model = Guardian + fields = ("name","relationship","phone_number","email",) + + +class EmergencyContactForm(forms.ModelForm): + class Meta: + model = EmergencyContact + fields = ("name", "relationship", "phone_number",) + + +class AdmissionFormForm(forms.ModelForm): + class Meta: + model = AdmissionForm + fields = ("course","additional_information","signature_applicant",'signature_parent_guardian',) diff --git a/admission/migrations/0001_initial.py b/admission/migrations/0001_initial.py new file mode 100644 index 00000000..7c8e695a --- /dev/null +++ b/admission/migrations/0001_initial.py @@ -0,0 +1,84 @@ +# Generated by Django 4.2.1 on 2023-05-19 15:05 + +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='StudentPersonalInformation', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('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='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='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)), + ('personal_information', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='emergency_contact', to='admission.studentpersonalinformation')), + ], + ), + 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)), + ('personal_information', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='Educational_background', to='admission.studentpersonalinformation')), + ], + ), + 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)), + ('signature_parent_guardian', models.CharField(max_length=100)), + ('date_signed', models.DateField(auto_now_add=True)), + ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.course')), + ('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/__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..e396ebed --- /dev/null +++ b/admission/models.py @@ -0,0 +1,75 @@ +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 StudentPersonalInformation(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): + 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) + 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 Guardian(models.Model): + 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) + email = models.EmailField() + + def __str__(self): + return self.name + + +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) + + def __str__(self): + return self.name + + +class AdmissionForm(models.Model): + course =models.ForeignKey(Course, 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) + 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/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..e4cd0f5f --- /dev/null +++ b/admission/urls.py @@ -0,0 +1,14 @@ +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('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("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 new file mode 100644 index 00000000..f564ca65 --- /dev/null +++ b/admission/views.py @@ -0,0 +1,124 @@ +from django.shortcuts import render, redirect +from .forms import PersonalInformationForm, EducationalBackgroundForm, ParentGuardianForm, EmergencyContactForm, AdmissionFormForm +from .models import StudentPersonalInformation +from students.models import Student + + +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) + 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_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') + 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('emergency_contact_form') + else: + form = ParentGuardianForm(prefix='guardian1') + + 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(): + personal_info = form.save(commit=False) + personal_info.personal_information = person_data + personal_info.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) + 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('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') + + + +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/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/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) diff --git a/templates/admission/admission_form.html b/templates/admission/admission_form.html new file mode 100644 index 00000000..49f4d1c6 --- /dev/null +++ b/templates/admission/admission_form.html @@ -0,0 +1,22 @@ +
+ + + {% csrf_token %} +

Admission Form

+ + + {% 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' %} + + +
+ + +
{% 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 new file mode 100644 index 00000000..9edf615f --- /dev/null +++ b/templates/admission/educational_background_form.html @@ -0,0 +1,7 @@ +
+ {% csrf_token %} +

Educational Background

+ {{ form.as_p }} + +
+ \ 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..148e88ff --- /dev/null +++ b/templates/admission/emergency_contact_form.html @@ -0,0 +1,10 @@ + +
+ {% csrf_token %} +

Emergency Contact

+ + + {{ 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 new file mode 100644 index 00000000..a784b0af --- /dev/null +++ b/templates/admission/parent_guardian_form.html @@ -0,0 +1,12 @@ + +
+ {% csrf_token %} +

Parent/Guardian Information

+

Guardian 1

+ + {{ 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 new file mode 100644 index 00000000..afd05652 --- /dev/null +++ b/templates/admission/personal_information_form.html @@ -0,0 +1,7 @@ +
+ {% csrf_token %} +

Personal Information

+ {{ 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..39af6108 --- /dev/null +++ b/templates/admission/studentsdetail.html @@ -0,0 +1,21 @@ + +{% 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}} + + +
+ {% csrf_token %} + + +
+ +{% endfor %} + diff --git a/templates/admission/success_page.html b/templates/admission/success_page.html new file mode 100644 index 00000000..8a38427a --- /dev/null +++ b/templates/admission/success_page.html @@ -0,0 +1,3 @@ + + +form submit successfully \ 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