-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathbit_byte_group.py
More file actions
34 lines (28 loc) · 1005 Bytes
/
bit_byte_group.py
File metadata and controls
34 lines (28 loc) · 1005 Bytes
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
from django.db import models
from django.conf import settings
from hknweb.coursesemester.models import Semester
class BitByteGroup(models.Model):
"""
Model for bit byte group.
Each bit byte group has a semester associated with it, if it is unknown the field is none.
"""
class Meta:
verbose_name = "Bit Byte Group"
verbose_name_plural = "Bit Byte Groups"
semester = models.ForeignKey(
Semester,
on_delete=models.CASCADE,
related_name="bit_byte_groups",
)
bytes = models.ManyToManyField(
settings.AUTH_USER_MODEL, related_name="bitbyte_groups_as_byte"
)
bits = models.ManyToManyField(
settings.AUTH_USER_MODEL, related_name="bitbyte_groups_as_bit"
)
def __str__(self):
return (
f"Bit byte group {self.semester}; "
+ f"Bytes: {', '.join([c.username for c in self.bytes.all()])}; "
+ f"Bits: {', '.join([c.username for c in self.bits.all()])}"
)