From cba5b721ca14c1f336ad5d2c0d15f9cb48498589 Mon Sep 17 00:00:00 2001 From: James Turk Date: Thu, 2 Apr 2015 18:24:34 -0400 Subject: [PATCH] some admin stuff --- lifting/admin.py | 14 +++++++++++++- lifting/models.py | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lifting/admin.py b/lifting/admin.py index 8c38f3f..a8dfee1 100644 --- a/lifting/admin.py +++ b/lifting/admin.py @@ -1,3 +1,15 @@ from django.contrib import admin +from .models import Exercise, Set + +@admin.register(Exercise) +class ExerciseAdmin(admin.ModelAdmin): + pass + + +@admin.register(Set) +class SetAdmin(admin.ModelAdmin): + date_hierarchy = 'date' + readonly_fields = ('user', 'exercise', 'date') + list_filter = ('user__username', 'exercise') + fields = ('user', 'exercise', 'date', 'weight_kg', 'reps', 'source') -# Register your models here. diff --git a/lifting/models.py b/lifting/models.py index 9dae07a..1d69a2a 100644 --- a/lifting/models.py +++ b/lifting/models.py @@ -12,7 +12,7 @@ class Exercise(models.Model): names = ArrayField(models.CharField(max_length=200)) def __str__(self): - return self.names + return ', '.join(self.names) class Set(models.Model): @@ -22,3 +22,6 @@ class Set(models.Model): weight_kg = models.DecimalField(max_digits=7, decimal_places=3) reps = models.PositiveIntegerField() source = models.CharField(max_length=100) + + def __str__(self): + return '{} - {} @ {}kg - {}'.format(self.exercise, self.reps, self.weight_kg, self.date)