Skip to content

Commit 612465f

Browse files
committed
Defining rota app class models
Defining the classes for the rota app model. This corresponds to the relationships that we're creating between Rota's users, and intermediate store for capturing whether a user has said yes/no/maybe. Should make sense from looking at the code and the respective comments.
1 parent ca8001f commit 612465f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

control/rotarise/rotas/models.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
11
from django.db import models
2+
from django.contrib.auth.models import User
23

34
# 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

Comments
 (0)