some admin stuff

This commit is contained in:
James Turk 2015-04-02 18:24:34 -04:00
parent d930beaa4e
commit cba5b721ca
2 changed files with 17 additions and 2 deletions

View File

@ -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.

View File

@ -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)