コード例 #1
0
ファイル: models.py プロジェクト: William-Barry-Aix/BlackJack
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
コード例 #2
0
ファイル: models.py プロジェクト: DrGonzoIII/hoolidays
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)
コード例 #3
0
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)]
        }
コード例 #4
0
ファイル: models.py プロジェクト: sonetteira/DjangoWTCP
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)])
コード例 #5
0
class ItemWatch(models.Model):
    category = models.CharField(max_length=30)
    price = models.IntegerField
    currency = models.CharField(max_length=30)
    modifiers = models.OneToManyField(ModifierWatch)
コード例 #6
0
ファイル: models - Copy.py プロジェクト: 404bhatt/guno2
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
コード例 #7
0
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
コード例 #8
0
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)
コード例 #9
0
ファイル: models.py プロジェクト: William-Barry-Aix/BlackJack
class Deck(models.Model):
    cards = models.OneToManyField(Card, on_delete=models.CASCADE, default=None)
コード例 #10
0
ファイル: models.py プロジェクト: NaNi335/web_itmo
class User(models.Model):
    name = models.CharField(max_length=50)
    tasks = models.OneToManyField('Task')
    isTeacher = models.BooleanField(default=False)
コード例 #11
0
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.