Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Online Admission feature #69

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added admission/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions admission/admin.py
Original file line number Diff line number Diff line change
@@ -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)

6 changes: 6 additions & 0 deletions admission/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AdmissionConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'admission'
33 changes: 33 additions & 0 deletions admission/forms.py
Original file line number Diff line number Diff line change
@@ -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',)
84 changes: 84 additions & 0 deletions admission/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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')),
],
),
]
Original file line number Diff line number Diff line change
@@ -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'),
),
]
Empty file.
75 changes: 75 additions & 0 deletions admission/models.py
Original file line number Diff line number Diff line change
@@ -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}"
3 changes: 3 additions & 0 deletions admission/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
14 changes: 14 additions & 0 deletions admission/urls.py
Original file line number Diff line number Diff line change
@@ -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/<int:pk>",views.shift_data_view, name='shift_data_view')

]
124 changes: 124 additions & 0 deletions admission/views.py
Original file line number Diff line number Diff line change
@@ -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,
})
3 changes: 2 additions & 1 deletion easyschool/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
'course.apps.CourseConfig',
'debug_toolbar',
'teachers.apps.TeachersConfig',
'django.contrib.humanize'
'django.contrib.humanize',
"admission",
]

MIDDLEWARE = [
Expand Down
Loading