Statistics
| Branch: | Revision:

root / crm / robocrm / models.py @ 3e2fcd4e

History | View | Annotate | Download (4.18 KB)

1 988e217a Julian Binder
from django.db import models
2 03f9c52d Julian Binder
from django.contrib.auth.models import User
3 3e2fcd4e Tom Mullins
from django.contrib import admin
4 03f9c52d Julian Binder
from django.db.models.signals import post_save
5
6 b2863bff Julian Binder
# Machine Model
7
class Machine(models.Model):
8
  type = models.CharField(max_length=20)
9
  id = models.CharField(max_length=10, primary_key=True)
10
  maint = models.BooleanField(default=False)
11 7976b167 Julian Binder
  dstart = models.DateTimeField(blank=True, null=True)
12
  dend = models.DateTimeField(blank=True, null=True)
13 bb0c65c6 Julian Binder
  
14
  def __unicode__(self):
15
    return u'%s %s' % (self.type, self.id)
16 988e217a Julian Binder
17
# User Model
18 03f9c52d Julian Binder
class RoboUser(models.Model):
19
  # Field is required when using profiles 
20
  user = models.OneToOneField(User)
21
22
  # Roboclub RFID Card number
23 3e2fcd4e Tom Mullins
  rfid = models.CharField(max_length=10, blank=True, null=True)
24 cd771306 Julian Binder
  
25 03f9c52d Julian Binder
  # Roboclub Shop Access Permissions
26 75228955 Julian Binder
  machines = models.ManyToManyField(Machine, blank=True, null=True)
27 03f9c52d Julian Binder
28
  # Cell Phone
29 7976b167 Julian Binder
  cell = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
30 cd771306 Julian Binder
31 03f9c52d Julian Binder
  # Class Level
32 63244bd1 Julian Binder
  UNDERGRAD = 'UG'
33
  GRADUATE = 'GR'
34
  AFFILIATE = 'AF'
35
  OTHER = 'OH'
36 03f9c52d Julian Binder
  CLASS_LEVEL_CHOICES = (
37 049ebb6e Tom Mullins
      (UNDERGRAD, 'Undergraduate'),
38
      (GRADUATE, 'Graduate Student'),
39
      (AFFILIATE, 'Non-Student CMU Affiliate'),
40
      (OTHER, 'Other User'),
41 03f9c52d Julian Binder
  )
42
  class_level = models.CharField(max_length=2, 
43
                                 choices=CLASS_LEVEL_CHOICES,
44 63244bd1 Julian Binder
                                 default=UNDERGRAD)
45 cd771306 Julian Binder
46 03f9c52d Julian Binder
  # Graduation Year
47 63244bd1 Julian Binder
  #grad_year = models.DecimalField(max_digits=4, decimal_places=0)
48
  grad_year = models.IntegerField(blank=True, null=True)
49 cd771306 Julian Binder
50 03f9c52d Julian Binder
  # Primary and Secondary Major/Minors
51
  major = models.CharField(max_length=20)
52 7976b167 Julian Binder
  sec_major_one = models.CharField(max_length=20, blank=True, null=True)
53
  sec_major_two = models.CharField(max_length=20, blank=True, null=True)
54 03f9c52d Julian Binder
55
  #Club Rank
56
  JUNIOR_MEM = 'JM'
57
  SENIOR_MEM = 'SM'
58
  OFFICER = 'OM'
59
  CLUB_RANK_CHOICES = (
60
      (JUNIOR_MEM, 'Junior Member'),
61
      (SENIOR_MEM, 'Senior Member'),
62
      (OFFICER, 'Officer'),
63
  )
64
  club_rank = models.CharField(max_length=2, 
65
                               choices=CLUB_RANK_CHOICES,
66
                               default=JUNIOR_MEM)
67
  
68
  # Roboclub Transaction Info
69 63244bd1 Julian Binder
  dues_paid = models.DateField(blank=True, null=True)
70 03f9c52d Julian Binder
  tshirt_rec = models.BooleanField(default=False)
71 988e217a Julian Binder
  
72 03f9c52d Julian Binder
  # Shop and E-Bench Status
73
  GOOD = 'GD'
74
  FIRST_WARN = 'FS'
75
  SECOND_WARN = 'SD'
76
  SEM_BAN = 'SB'
77
  CLUB_BAN = 'CB'
78
  STATUS_CHOICES = (
79
      (GOOD, 'Good Standing'),
80
      (FIRST_WARN, 'First Warning Recieved'),
81
      (SECOND_WARN, 'Second Warning Recieved'),
82
      (SEM_BAN, 'Semester Ban'),
83
      (CLUB_BAN, 'Club Ban')
84
  )
85
  bench_status = models.CharField(max_length=2,
86
                                  choices=STATUS_CHOICES,
87
                                  default=GOOD)
88
  shop_status = models.CharField(max_length=2,
89 3e2fcd4e Tom Mullins
                                 choices=STATUS_CHOICES,
90
                                 default=GOOD)
91 bb0c65c6 Julian Binder
  def __unicode__(self):
92 e0657267 Tom Mullins
    return self.user.username
93 bb0c65c6 Julian Binder
94 03f9c52d Julian Binder
# Event Model
95 b2863bff Julian Binder
class Event(models.Model):
96 03f9c52d Julian Binder
  type = models.CharField(max_length=30)
97
  tstart = models.DateTimeField()
98
  tend = models.DateTimeField()
99
  user = models.ForeignKey('RoboUser')
100
  succ = models.BooleanField(default=False)
101
  imgurl = models.URLField()
102
  machine = models.ForeignKey('Machine')
103 e0657267 Tom Mullins
  project = models.ForeignKey('Project', null=True)
104 03f9c52d Julian Binder
  matuse = models.TextField()
105 bb0c65c6 Julian Binder
  
106
  def __unicode__(self):
107 e0657267 Tom Mullins
    return u'%s %s %s'%(self.type, self.user.user.username, self.succ)
108 03f9c52d Julian Binder
109
# Project Model
110 b2863bff Julian Binder
class Project(models.Model):
111 03f9c52d Julian Binder
  name = models.CharField(max_length=30)
112 b2863bff Julian Binder
  primuser = models.ForeignKey('RoboUser', related_name='pri+')
113
  users = models.ManyToManyField('RoboUser', related_name='u+')
114 03f9c52d Julian Binder
  charge = models.BooleanField(default=False)
115 bb0c65c6 Julian Binder
  def __unicode__(self):
116
    return self.name
117 03f9c52d Julian Binder
118
# Roboclub Resources Model
119 b2863bff Julian Binder
class RoboResource(models.Model):
120 03f9c52d Julian Binder
  type = models.CharField(max_length=30)
121 b2863bff Julian Binder
  id = models.CharField(max_length=20, primary_key=True)
122 03f9c52d Julian Binder
  checked_out = models.BooleanField(default=False)
123 a048cd77 Julian Binder
  user = models.ForeignKey('RoboUser', related_name='u+', blank=True)
124 7976b167 Julian Binder
  time_out = models.DateTimeField(blank=True,null=True)
125
  time_due = models.DateTimeField(blank=True,null=True)
126 a048cd77 Julian Binder
  officer = models.ForeignKey('RoboUser', related_name='o+', blank=True)
127 bb0c65c6 Julian Binder
  def __unicode__(self):
128
    return u'%s %s %s' (self.type, self.id, self.checked_out)