コード例 #1
0
class AnalyticsEvent(BaseModel):
    type = models.IntegerField(_("type"), choices=EventType.choices())

    order = models.ForeignKey(Order,
                              verbose_name=_("order"),
                              related_name="events",
                              null=True,
                              blank=True)
    order_assignment = models.ForeignKey(OrderAssignment,
                                         verbose_name=_("order assignment"),
                                         related_name="events",
                                         null=True,
                                         blank=True)
    work_station = models.ForeignKey(WorkStation,
                                     verbose_name=_("work station"),
                                     related_name="events",
                                     null=True,
                                     blank=True)
    station = models.ForeignKey(Station,
                                verbose_name=_("station"),
                                related_name="events",
                                null=True,
                                blank=True)
    passenger = models.ForeignKey(Passenger,
                                  verbose_name=_("passenger"),
                                  related_name="events",
                                  null=True,
                                  blank=True)
    country = models.ForeignKey(Country,
                                verbose_name=_("country"),
                                related_name="events",
                                null=True,
                                blank=True)
    city = models.ForeignKey(City,
                             verbose_name=_("city"),
                             related_name="events",
                             null=True,
                             blank=True)
    rating = models.IntegerField(verbose_name=_("ratings"),
                                 null=True,
                                 blank=True)

    lat = models.FloatField(verbose_name=("lat"), null=True, blank=True)
    lon = models.FloatField(verbose_name=("lon"), null=True, blank=True)

    def save(self, force_insert=False, force_update=False, using=None):
        self.full_clean()  # validates model
        super(AnalyticsEvent, self).save()

    def get_label(self):
        return EventType.get_label(self.type)

    def __str__(self):
        return self.get_label()
コード例 #2
0
ファイル: models.py プロジェクト: WAYbetter/waybetter
 def get_label(self):
     return EventType.get_label(self.type)
コード例 #3
0
 def get_label(self):
     return EventType.get_label(self.type)