class Card(models.Model): rank = models.OneToManyField(Rank, null=None, default=None) value = models.OneToManyField(Value, null=None, default=None) suit = models.TextField(Suit, null=None, default=None) isVisible = models.BooleanField(null=None, default=False) def __str__(self): return self.suit + self.rank
class LaboralYear(models.Model): year = models.IntegerField() num_hours = models.DecimalField() holidays_days = models.OneToManyField(LaboralHolidays) # Calculamos horas totales - horas convenio = dias libres def calculate_hours(self): total = 0.0 for single_date in self.daterange(self.year): if single_date.today().weekday() == 0: if single_date not in self.holidays_days.date: total += 8.5 elif single_date.today().weekday() == 1: if single_date not in self.holidays_days.date: total += 8.5 elif single_date.today().weekday() == 2: if single_date not in self.holidays_days.date: total += 8.5 elif single_date.today().weekday() == 3: if single_date not in self.holidays_days.date: total += 8.5 elif single_date.today().weekday() == 4: if single_date not in self.holidays_days.date: total += 6 return total def daterange(year): start_date = datetime.date(year, 1, 1) end_date = datetime.date(year + 1, 1, 1) for n in range(int((end_date - start_date).days)): yield start_date + timedelta(n)
class ModuleDefinition(models.Model): """ A ModuleDefinition includes - user (creator) - name - node_count - svg_path - instances - wires - ports """ creator = models.ForeignKey(User) editors = models.ManyToManyField(User, related_name='editable_definitions') comments = models.OneToManyField(Comment) name = models.CharField(max_length=64) # Number of nodes in the definition. Nodes are represented as integers. # Nodes are allocated from 0 to (node_count-1), so node_counter # is guaranteed not to be referenced by any existing wires or instances. # Therefore node_count should be used and then incremented whenever a new # node is needed. node_count = models.PositiveIntegerField() svg_path = models.CharField(max_length=64) def dict(self): """ Get a dictionary representation of the ModuleDefinition suitable for JSON serialization """ return { "id": self.id, "name": self.name, "node_count": self.node_count, "svg_path": self.svg_path, "instances": [ instance.dict() for instance in ModuleInstance.objecs.filter(parent=self) ], "wires": [wire.dict() for wire in Wire.objects.filter(parent=self)], "ports": [port.dict() for port in Port.objects.filter(parent=self)] }
class Student(models.Model): """Model for representing a student (but not specific students)""" #Foriegn key will be used since students can only have one name but can qualify for many programs/languages etc name = model.ForiegnKey.CharField(max_length=350) #One to Many since students can only have one native language but many students can speak the same languages nativeLanguage = models.OneToManyField( nativeLanguage, help_text='Enter your native language') def __str__(self): """String for representing the Model object.""" return self.name def get_absolute_url(self): """Returns the url to access a detail record for this student.""" return reverse('student-detail', args=[str(self.id)])
class ItemWatch(models.Model): category = models.CharField(max_length=30) price = models.IntegerField currency = models.CharField(max_length=30) modifiers = models.OneToManyField(ModifierWatch)
class Userinfo(models.Model): user = models.OneToOneField(User) room=models.OneToManyField(rooms,related_name='players',default=None)) #status = models.CharField(max_length=100,blank=True) def __str__(self): return self.user.username
class Order(models.Model): orderNumber = models.CharField(max_length=28) toppingsCost = models.OneToManyField(models.ForeignKey(Topping)) pizzasCost = models.OneToManyField(models.ForeignKey(Pizza)) totalCost = toppingsCost + pizzasCost
class TestCase(models.Model): name = models.CharField(max_length=100) creator = models.ForeignKey(User) creation_time = models.DateTimeField(auto_now_add=True) definition = models.ForeignKey(ModuleDefinition) comments = models.OneToManyField(Comment)
class Deck(models.Model): cards = models.OneToManyField(Card, on_delete=models.CASCADE, default=None)
class User(models.Model): name = models.CharField(max_length=50) tasks = models.OneToManyField('Task') isTeacher = models.BooleanField(default=False)
class Motif(models.Model): """A consensus motif which has multiple matches in the genome.""" pattern = models.CharField(max_length=250) # Consensus sequence. matches = models.OneToManyField(Match) # Sequence matches.