Improve admin
This commit is contained in:
parent
fef799a837
commit
e85d38529f
2 changed files with 16 additions and 8 deletions
20
gym/admin.py
20
gym/admin.py
|
@ -5,27 +5,37 @@ from gym.models import Room, Equipment, TheoreticalMax, Session, Round, Unit, Wo
|
||||||
|
|
||||||
@admin.register(Room)
|
@admin.register(Room)
|
||||||
class RoomAdmin(admin.ModelAdmin):
|
class RoomAdmin(admin.ModelAdmin):
|
||||||
pass
|
list_display = ['name']
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Equipment)
|
@admin.register(Equipment)
|
||||||
class EquipmentAdmin(admin.ModelAdmin):
|
class EquipmentAdmin(admin.ModelAdmin):
|
||||||
pass
|
list_display = ['name', 'room', 'unit', 'last_theoretical_max', 'default_work_form', 'default_repetition_number']
|
||||||
|
list_editable = ['default_work_form', 'default_repetition_number']
|
||||||
|
list_filter = ['room', 'unit', 'default_work_form']
|
||||||
|
|
||||||
|
|
||||||
@admin.register(TheoreticalMax)
|
@admin.register(TheoreticalMax)
|
||||||
class TheoreticalMaxAdmin(admin.ModelAdmin):
|
class TheoreticalMaxAdmin(admin.ModelAdmin):
|
||||||
pass
|
list_display = ['equipment', 'date', 'value']
|
||||||
|
list_display_links = ['equipment', 'date']
|
||||||
|
list_filter = ['equipment']
|
||||||
|
date_hierarchy = 'date'
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Session)
|
@admin.register(Session)
|
||||||
class SessionAdmin(admin.ModelAdmin):
|
class SessionAdmin(admin.ModelAdmin):
|
||||||
pass
|
list_display = ['start', 'room', 'default_theoretical_max_percentage']
|
||||||
|
list_filter = ['room']
|
||||||
|
date_hierarchy = 'start'
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Round)
|
@admin.register(Round)
|
||||||
class RoundAdmin(admin.ModelAdmin):
|
class RoundAdmin(admin.ModelAdmin):
|
||||||
pass
|
list_display = ['equipment', 'session', 'repetition_number', 'theoretical_max_percentage', 'chosen_weight', 'work_form']
|
||||||
|
list_display_links = ['equipment', 'session']
|
||||||
|
list_filter = ['equipment', 'work_form']
|
||||||
|
date_hierarchy = 'session__start'
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Unit)
|
@admin.register(Unit)
|
||||||
|
|
|
@ -106,7 +106,7 @@ class TheoreticalMax(models.Model):
|
||||||
value = models.FloatField('valeur')
|
value = models.FloatField('valeur')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.value} {self.equipment.unit.name} le {self.date}'
|
return f'{self.value} {self.equipment.unit.name} le {self.date:%d/%m/%Y}'
|
||||||
|
|
||||||
|
|
||||||
class Session(models.Model):
|
class Session(models.Model):
|
||||||
|
@ -127,10 +127,8 @@ class Session(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
import pytz
|
import pytz
|
||||||
print(self.start)
|
|
||||||
server_timezone = pytz.timezone(settings.TIME_ZONE)
|
server_timezone = pytz.timezone(settings.TIME_ZONE)
|
||||||
server = server_timezone.normalize(self.start.astimezone(server_timezone))
|
server = server_timezone.normalize(self.start.astimezone(server_timezone))
|
||||||
print(server)
|
|
||||||
return f'{self.room} {server:%d/%m/%Y %H:%M} ({settings.TIME_ZONE})'
|
return f'{self.room} {server:%d/%m/%Y %H:%M} ({settings.TIME_ZONE})'
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue