|
1 | 1 | from django.db import models
|
| 2 | +from django.contrib.auth.models import User |
2 | 3 |
|
3 | 4 | # Create your models here.
|
| 5 | + |
| 6 | + |
| 7 | +class Rota(models.Model): |
| 8 | + """Class for each invdividual 'rota'. This is assumed to |
| 9 | + consist of a purpose .e.g. music group, and have associated with it |
| 10 | + a number of slots for which members of the rota are asked to |
| 11 | + signup to.""" |
| 12 | + |
| 13 | + label = models.CharField(max_length=30) |
| 14 | + description = models.TextField(max_length=500) |
| 15 | + owners = models.ManyToManyField(User, related_name='owner_set') |
| 16 | + users = models.ManyToManyField(User, related_name='user_set') |
| 17 | + |
| 18 | +class RotaSlot(models.Model): |
| 19 | + """A particular labeled slot for a chosen day. This must |
| 20 | + be associated with a particular rota.""" |
| 21 | + |
| 22 | + rota = models.ForeignKey(Rota) |
| 23 | + label = models.CharField(max_length=30) |
| 24 | + date = models.DateField() |
| 25 | + |
| 26 | + |
| 27 | +class UserSlotAssoc(models.Model): |
| 28 | + """The data structure used to link together users and a particular |
| 29 | + rota slot as there may well be more than one person signing up for a particular |
| 30 | + rota slot.""" |
| 31 | + |
| 32 | + user = models.ForeignKey(User) |
| 33 | + rota_slot = models.ForeignKey(RotaSlot) |
| 34 | + |
| 35 | + # 0 = No, 1 = yes, 2 = maybe |
| 36 | + option = models.SmallIntegerField() |
| 37 | + |
| 38 | + # Indicating whether the user has been 'selected' for this slot, and |
| 39 | + # so composed on any lists that are produced for this slot. |
| 40 | + selected = models.BooleanField() |
0 commit comments