summaryrefslogtreecommitdiff
path: root/allotter/models.py
blob: 773d9d1c524f8ee210f9caec11416e780cd9c294 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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", "GEN"),
    ("OBC", "OBC(Non-Creamy Layer)"),
    ("SC", "SC"),
    ("ST", "ST"),
    )

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

BIRTH_YEAR_CHOICES = ('1989', '1990', '1991')


DEFAULT_EXAM_ID = 1

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

    exam = models.ManyToManyField(Exam, default=DEFAULT_EXAM_ID)

    class Meta:
        verbose_name_plural = "Options"
        
    def __unicode__(self):
        return self.opt_name


class Profile(models.Model):

    user = models.OneToOneField(User)

    application_number = models.IntegerField(max_length=20,
        verbose_name=u"Examination Application number",
        help_text=u"Application number as per the Examination Hall ticket")

    dob = models.DateField(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)

    exam_code = models.CharField(max_length=30, choices=EXAMINATION_SUBJECTS)

    rank = models.IntegerField(max_length=6)

    gender = models.CharField(max_length=10, choices=GENDER_CHOICES)
	
    pd = models.BooleanField(default=False) 	

    def __unicode__(self):
        return unicode(self.application_number)

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 is_application_editable(self):
        if self.status == "I": return True
        else: return False

    def __unicode__(self):
        u = self.user
        return u'Application for {0} {1}'.format(u.first_name, u.last_name)