summaryrefslogtreecommitdiff
path: root/allotter/models.py
blob: 20814e7771d677c8dc0ffa1be72c2857b26af7e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from django.db import models
from django.contrib.auth.models import User

from  datetime import datetime

EXAMINATION_SUBJECTS = (
    ("phy", "Physics"),
    ("math", "Mathematics"),
    ("chem", "Chemistry"),
    )

CATEGORIES = (
    ("GEN", "GENERAL"),
    ("OBC", "OTHER BACKWARD CASTE"),
    )

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 = 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)

    def __unicode__(self):
        return self.exam_name


class Profile(models.Model):

    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)