Project

General

Profile

Statistics
| Branch: | Revision:

root / crm / robocrm / models.py @ 03f9c52d

History | View | Annotate | Download (3.67 KB)

1
from django.db import models
2
from django.contrib.auth.models import User
3
from django.db.models.signals import post_save
4

    
5

    
6
# User Model
7
class RoboUser(models.Model):
8
  # Field is required when using profiles 
9
  user = models.OneToOneField(User)
10

    
11
  # Roboclub RFID Card number
12
  rfid = models.DecimalField(max_digits=10, decimal_places=0)
13
  
14
  # Roboclub Shop Access Permissions
15
  machines = models.ManyToManyField(Machine)
16

    
17
  # Cell Phone
18
  cell = models.DecimalField(max_digits=10, decimal_places=0)
19

    
20
  # Class Level
21
  FRESHMAN = 'FR'
22
  SOPHOMORE = 'SO'
23
  JUNIOR = 'JR'
24
  SENIOR = 'SR'
25
  MASTERS = 'MS'
26
  DOCTORAL = 'DR'
27
  CLASS_LEVEL_CHOICES = (
28
      (FRESHMAN, 'Freshman'),
29
      (SOPHOMORE, 'Sophomore'),
30
      (JUNIOR, 'Junior'),
31
      (SENIOR, 'Senior'),
32
      (MASTERs, 'Masters'),
33
      (DOCTORAL, 'Doctoral'),
34
  )
35
  class_level = models.CharField(max_length=2, 
36
                                 choices=CLASS_LEVEL_CHOICES,
37
                                 default=FRESHMAN)
38

    
39
  # Graduation Year
40
  grad_year = models.DecimalField(max_digits=4, decimal_places=0)
41

    
42
  # Primary and Secondary Major/Minors
43
  major = models.CharField(max_length=20)
44
  sec_major_one = models.CharField(max_length=20)
45
  sec_major_two = models.CharField(max_lenght=20)
46

    
47
  #Club Rank
48
  JUNIOR_MEM = 'JM'
49
  SENIOR_MEM = 'SM'
50
  OFFICER = 'OM'
51
  CLUB_RANK_CHOICES = (
52
      (JUNIOR_MEM, 'Junior Member'),
53
      (SENIOR_MEM, 'Senior Member'),
54
      (OFFICER, 'Officer'),
55
  )
56
  club_rank = models.CharField(max_length=2, 
57
                               choices=CLUB_RANK_CHOICES,
58
                               default=JUNIOR_MEM)
59
  
60
  # Roboclub Transaction Info
61
  dues_paid = models.DateField()
62
  tshirt_rec = models.BooleanField(default=False)
63
  
64
  # Shop and E-Bench Status
65
  GOOD = 'GD'
66
  FIRST_WARN = 'FS'
67
  SECOND_WARN = 'SD'
68
  SEM_BAN = 'SB'
69
  CLUB_BAN = 'CB'
70
  STATUS_CHOICES = (
71
      (GOOD, 'Good Standing'),
72
      (FIRST_WARN, 'First Warning Recieved'),
73
      (SECOND_WARN, 'Second Warning Recieved'),
74
      (SEM_BAN, 'Semester Ban'),
75
      (CLUB_BAN, 'Club Ban')
76
  )
77
  bench_status = models.CharField(max_length=2,
78
                                  choices=STATUS_CHOICES,
79
                                  default=GOOD)
80
  shop_status = models.CharField(max_length=2,
81
                                  choices=STATUS_CHOICES,
82
                                  default=GOOD)
83
# needed for Django Auth model
84
def create_roboclub_user(sender, instance, created, **kwargs):
85
  if created:
86
      RoboUser.objects.create(user=instance)
87
post_save.connect(create_roboclub_user, sender=User)
88

    
89

    
90
# Machine Model
91
class Machine(models.Model)
92
  type = models.CharField(max_length=20)
93
  id = models.CharField(max_length=10, unique=True)
94
  maint = models.BooleanField(default=False)
95
  dstart = models.DateTimeField()
96
  dend = models.DateTimeField()
97

    
98
# Event Model
99
class Event(models.Model)
100
  type = models.CharField(max_length=30)
101
  tstart = models.DateTimeField()
102
  tend = models.DateTimeField()
103
  user = models.ForeignKey('RoboUser')
104
  succ = models.BooleanField(default=False)
105
  imgurl = models.URLField()
106
  machine = models.ForeignKey('Machine')
107
  project = models.ForeignKey('Project')
108
  matuse = models.TextField()
109

    
110
# Project Model
111
class Project(models.Model)
112
  name = models.CharField(max_length=30)
113
  primuser = models.Foreignkey('RoboUser')
114
  users = models.ManyToManyField('RoboUser')
115
  charge = models.BooleanField(default=False)
116

    
117
# Roboclub Resources Model
118
class RoboResource
119
  type = models.CharField(max_length=30)
120
  id = models.CharField(max_length=20, unique=True)
121
  checked_out = models.BooleanField(default=False)
122
  user = models.ForeignKey('RoboUser')
123
  time_out = models.DateTimeField()
124
  time_due = models.DateTimeField()
125
  officer = models.ForeignKey('RoboUser')
126

    
127