Exemplo n.º 1
0
class Gyms(models.Model):
    name = models.TextField()
    last_check_in = models.TimeStampField(default=datetime.datetime.utcnow())
    location = models.TextField()

    class Meta:
        collection_name = GYM_COLLECTION
Exemplo n.º 2
0
class Member(BaseModel):
    last_name = models.TextField()
    first_name = models.TextField()
    refresh_token = models.TextField(blank=True)
    access_token = models.TextField(blank=True)
    access_token_expiry = models.IntegerField(blank=True)

    @staticmethod
    def add(athlete,
            refresh_token=None,
            access_token=None,
            access_token_expiry=None):
        """Takes a stravalib.model.Athlete object and adds it """
        m = Member.objects.create(id=athlete.id,
                                  last_name=athlete.lastname,
                                  first_name=athlete.firstname,
                                  refresh_token=refresh_token,
                                  access_token=access_token,
                                  access_token_expiry=access_token_expiry,
                                  audit_inserted=datetime.utcnow())
        m.save()
        Handicap.add(m)
        Activity.add(Activity.MEMBER_CONNECTED, member_id=m.id)

        return m

    def update_handicap(self, new_handicap):
        Handicap.add(self, new_handicap)

    def jsonify(self):
        return {
            "id": self.id,
            "first_name": self.first_name,
            "last_name": self.last_name
        }
Exemplo n.º 3
0
class Usage(models.Model):
    date = models.TextField()
    machine_id = models.TextField()
    name = models.TextField()
    times = models.ListField(default=list())
    total_time = models.IntegerField(default=0)

    class Meta:
        collection_name = USAGE_COLLECTION
Exemplo n.º 4
0
class Challenge(BaseModel):
    date_from = models.TimeStampField()
    date_to = models.TimeStampField()
    segment_id = models.IntegerField()
    segment_name = models.TextField()
    audit_inserted = models.TimeStampField(datetime.now())

    @staticmethod
    def add(segment, year, month):
        """Takes a stravalib.model.Segment object and adds it as the target challenege to cover the given month of the given year"""
        _, end_day = calendar.monthrange(year, month)

        date_from = datetime.combine(date(year, month, 1), datetime.min.time())
        date_to = datetime.combine(date(year, month, end_day),
                                   datetime.min.time())

        c = Challenge.objects.create(segment_id=segment.id,
                                     segment_name=segment.name,
                                     date_from=date_from,
                                     date_to=date_to,
                                     audit_inserted=datetime.utcnow())
        c.save()
        Activity.add(Activity.CHALLENGE_ADDED, challenge_id=c.id)

        return c

    def jsonify(self):
        return {
            "id": self.id,
            "date_from": self.date_from,
            "date_to": self.date_to,
            "segment_id": self.segment_id,
            "segment_name": self.segment_name
        }
Exemplo n.º 5
0
class BaseClass(models.Model):
    name = models.TextField()
    active = models.BooleanField(column_name='is_active')
    list_f = models.ListField(blank=True, column_name='lista')

    class Meta:
        abstract = True
        collection_name = 'collection_name'
Exemplo n.º 6
0
class NewBaseClass(models.Model):
    name = models.TextField(default='aaaaa')
    active = models.BooleanField(column_name='is_active', default=False)
    list_f = models.ListField(default=[], column_name='lista')
    map_f = models.MapField(default={}, column_name='mapa')

    class Meta:
        abstract = True
        collection_name = 'collection_name'
Exemplo n.º 7
0
class Activity(BaseModel):
    message = models.TextField(blank=True)
    member_id = models.TextField(blank=True)
    challenge_id = models.TextField(blank=True)
    attempt_id = models.TextField(blank=True)

    MEMBER_CONNECTED = "MEMBER_CONNECTED"
    CHALLENGE_ADDED = "CHALLENGE_ADDED"
    CHALLENGE_ATTEMPTED = "CHALLENGE_ATTEMPTED"

    @staticmethod
    def add(message, member_id=None, challenge_id=None, attempt_id=None):
        a = Activity.objects.create(message=message,
                                    member_id=member_id,
                                    challenge_id=challenge_id,
                                    attempt_id=attempt_id,
                                    audit_inserted=datetime.utcnow())
        a.save()

        return a
Exemplo n.º 8
0
class Class(models.Model):
    name = models.TextField()
    active = models.BooleanField(column_name='is_active')
    list_f = models.ListField(blank=True)
    map_f = models.MapField(blank=True)
Exemplo n.º 9
0
        class TestModelClass(models.Model):
            name = models.TextField()
            age = models.IntegerField()

            class Meta:
                collection_name = 'tmc'
Exemplo n.º 10
0
 class TestModelClassParent(models.Model):
     name = models.TextField()
     age = models.IntegerField()
Exemplo n.º 11
0
        class AClass(models.Model):
            name = models.TextField()
            age = models.IntegerField()

            class Meta:
                abstract = True
Exemplo n.º 12
0
 class AClass(models.Model):
     name = models.TextField()
     age = models.IntegerField()
Exemplo n.º 13
0
class User(models.Model):
    name = models.TextField()
Exemplo n.º 14
0
class C(models.Model):
    name = models.TextField()
    active = models.BooleanField()
Exemplo n.º 15
0
class B(models.Model):
    name = models.TextField()
Exemplo n.º 16
0
class Room(models.Model):
    name = models.TextField()

    class Meta:
        collection_name = 'rooms'
Exemplo n.º 17
0
class Message(models.Model):
    msg = models.TextField()
    user = models.ReferenceField(User)

    class Meta:
        collection_name = 'messages'