summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--allotter/admin.py6
-rw-r--r--allotter/models.py117
2 files changed, 80 insertions, 43 deletions
diff --git a/allotter/admin.py b/allotter/admin.py
index d6f251d..343d2f1 100644
--- a/allotter/admin.py
+++ b/allotter/admin.py
@@ -1,6 +1,6 @@
-from allotter.models import Student, Exam, Options
+from allotter.models import Exam, Option, Application
from django.contrib import admin
-admin.site.register(Student)
admin.site.register(Exam)
-admin.site.register(Options)
+admin.site.register(Option)
+admin.site.register(Application)
diff --git a/allotter/models.py b/allotter/models.py
index ee5860f..20814e7 100644
--- a/allotter/models.py
+++ b/allotter/models.py
@@ -1,11 +1,12 @@
from django.db import models
from django.contrib.auth.models import User
+
from datetime import datetime
EXAMINATION_SUBJECTS = (
- ("physics", "Physics"),
- ("mathematics", "Mathematics"),
- ("chemistry", "Chemistry"),
+ ("phy", "Physics"),
+ ("math", "Mathematics"),
+ ("chem", "Chemistry"),
)
CATEGORIES = (
@@ -13,49 +14,85 @@ CATEGORIES = (
("OBC", "OTHER BACKWARD CASTE"),
)
-OPTIONS = (
- ("M.Sc Chem", "M.Sc Chemisty"),
- ("M.Sc Phy", "M.Sc Physics"),
- ("M.Sc Math","M.Sc Mathematics"))
+AVAILABLE_OPTIONS = (
+ ("MScChem", "M.Sc Chemisty"),
+ ("MScPhy", "M.Sc Physics"),
+ ("MScMath","M.Sc Mathematics"))
+
+GENDER_CHOICES = (
+ ("M", "Male"),
+ ("F", "Female"))
+
+APPLICATION_STATUS = (
+ ("I", "Incomplete"),
+ ("Submitted", "Submitted"))
+
class Option(models.Model):
- opt_name = models.CharField(max_length=100,
- verbose_name=u"Option name",
- help_text=u"Name of Option/Stream",
- choices = OPTIONS)
- class Meta:
- verbose_name_plural = "Options"
+
+ opt_name = models.CharField(max_length=100,
+ verbose_name=u"Option name",
+ help_text=u"Name of Option/Stream",
+ choices = AVAILABLE_OPTIONS)
+
+ seats = models.IntegerField(verbose_name=u"Seats available")
+
+ class Meta:
+ verbose_name_plural = "Options"
+
+ def __unicode__(self):
+ return self.opt_name
+
class Exam(models.Model):
- exam_code = models.CharField(max_length=100,
- verbose_name=u"Examination code",
- help_text=u"Unique code for the examination")
- exam_name = models.CharField(max_length=100,
- verbose_name=u"Examination name",
- help_text=u"Subject name of the examination",
- choices=EXAMINATION_SUBJECTS)
- option_available = models.ForeignKey("Option",
- default=1)
- def __unicode__(self):
- return self.exam_name
+ exam_code = models.CharField(max_length=100,
+ verbose_name=u"Examination code",
+ help_text=u"Unique code for the examination")
+
+ exam_name = models.CharField(max_length=100,
+ verbose_name=u"Examination name",
+ help_text=u"Subject name of the examination",
+ choices=EXAMINATION_SUBJECTS)
+
+ def __unicode__(self):
+ return self.exam_name
class Profile(models.Model):
- user = models.OneToOneField(User)
- name = models.CharField(max_length=1024, verbose_name=u"Full Name",
- help_text=u"Name given in the application")
- roll_number = models.CharField(max_length=20,
- verbose_name=u"Examination Roll number",
- help_text=u"Roll number as per the Examination Hall ticket")
- dob = models.DateTimeField(verbose_name=u"Date of Birth",
- help_text=u"Date of birth as given in the application")
- category = models.CharField(max_length=30, choices=CATEGORIES)
- email = models.CharField(max_length=50, verbose_name=u"Email id",
- help_text=u"This will be for correspondence purposes")
- exam_taken = models.ForeignKey("Exam", default=1)
-
-
- def __unicode__(self):
- return self.name
+
+ user = models.OneToOneField(User)
+
+ roll_number = models.CharField(max_length=20,
+ verbose_name=u"Examination Roll number",
+ help_text=u"Roll number as per the Examination Hall ticket")
+
+ dob = models.DateTimeField(verbose_name=u"Date of Birth",
+ help_text=u"Date of birth as given in the application")
+
+ category = models.CharField(max_length=30, choices=CATEGORIES)
+
+ def __unicode__(self):
+ return self.name
+
+class Application(models.Model):
+ """An application for the student - one per student
+ """
+ user = models.ForeignKey(User)
+
+ profile = models.ForeignKey(Profile)
+
+ #To be modified to include multiple subjects for a student
+ exam_taken = models.ForeignKey(Exam)
+
+ #All options chosen
+ options = models.ManyToManyField(Option)
+
+ status = models.CharField(max_length=24, choices=APPLICATION_STATUS)
+
+ editable = models.BooleanField(default=True)
+
+ def __unicode__(self):
+ u = self.user
+ return u'Application for {0} {1}'.format(u.first_name, u.last_name)