summaryrefslogtreecommitdiff
path: root/nop/models.py
blob: e9b23e666d5bd69decffbe529ab2babc4178fefd (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from django.db import models

class CartTypeField(models.Field):
    def __init__(self, *args, **kwargs):
        self.types = [('show', 'Show'),
                      ('pool', 'Musicpool'),
                      ('jingle', 'Jingle'),
                     ]
        super(CartTypeField, self).__init__(*args, **kwargs)

    def db_type(self, connection):
        return "ENUM({})".format(','.join("'{}'".format(col)
                                          for col, _ in self.types))

class Master(models.Model):
    timestamp = models.BigIntegerField(primary_key=True)
    cart = models.IntegerField()
    len = models.IntegerField(null=True, blank=True)
    showtitle = models.CharField(max_length=765, blank=True)
    title = models.CharField(max_length=765, blank=True)
    artist = models.CharField(max_length=765, blank=True)
    album = models.CharField(max_length=765, blank=True)
    carttype = CartTypeField(max_length=64, blank=True)

    class Meta:
        db_table = u'master'
        ordering = ['-timestamp']


class Standby(models.Model):
    timestamp = models.BigIntegerField(primary_key=True)
    cart = models.IntegerField()
    len = models.IntegerField(null=True, blank=True)
    showtitle = models.CharField(max_length=765, blank=True)
    title = models.CharField(max_length=765, blank=True)
    artist = models.CharField(max_length=765, blank=True)
    album = models.CharField(max_length=765, blank=True)
    carttype = CartTypeField(max_length=64, blank=True)

    class Meta:
        db_table = u'standby'
        ordering = ['-timestamp']


class State(models.Model):
    timestamp = models.BigIntegerField(primary_key=True)
    state = models.CharField(max_length=96, blank=True)

    class Meta:
        db_table = u'state'
        ordering = ['-timestamp']