fix affichage admin

This commit is contained in:
Ludovic Stephan 2016-07-23 22:21:30 +02:00
parent f44b3fc33c
commit 6793194adc
2 changed files with 8 additions and 5 deletions

View file

@ -214,7 +214,8 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
return obj.attribution.participant
list_display = ("spectacle", "participant", "date", "sold")
readonly_fields = ("shotgun",)
raw_id_fields = ("attribution",)
readonly_fields = ("shotgun", "expiration_time")
list_filter = ("sold", )
search_fields = ("spectacle__title",
"participant__user__username",

View file

@ -179,7 +179,8 @@ class Attribution(models.Model):
given = models.BooleanField("Donnée", default=False)
def __str__(self):
return "%s -- %s" % (self.participant, self.spectacle)
return "%s -- %s, %s" % (self.participant.user, self.spectacle.title,
self.spectacle.date)
@python_2_unicode_compatible
@ -192,13 +193,14 @@ class SpectacleRevente(models.Model):
def get_expiration_time(self):
remaining_time = (self.attribution.spectacle.date - self.date)
delay = max(datetime.timedelta(hours=2),
min(remaining_time/2, datetime.timedelta(days=2)))
min(remaining_time//2, datetime.timedelta(days=2)))
return self.date + delay
expiration_time = property(get_expiration_time)
def get_shotgun(self):
return timezone.now > self.expiration_time
return timezone.now() > self.expiration_time
shotgun = property(get_shotgun)
def __str__(self):
return "%s" % self.attribution
return "%s -- %s" % (self.attribution.participant.user,
self.attribution.spectacle.title)