27 lines
830 B
Python
27 lines
830 B
Python
from django.contrib import admin
|
|
from import_export.admin import ImportExportModelAdmin
|
|
from .models import *
|
|
|
|
# Register your models here.
|
|
@admin.register(SupersetExercise)
|
|
class SupersetExerciseAdmin(ImportExportModelAdmin):
|
|
search_fields = ['exercise']
|
|
|
|
|
|
class SupersetExerciseInline(admin.StackedInline):
|
|
model = SupersetExercise
|
|
ordering = ("pk",)
|
|
extra = 0
|
|
|
|
@admin.register(Superset)
|
|
class SupersetAdmin(ImportExportModelAdmin):
|
|
list_display = ("name", "workout", "order", "rounds", "get_workout_id",)
|
|
ordering = ("order",)
|
|
inlines = [
|
|
SupersetExerciseInline,
|
|
]
|
|
|
|
def get_workout_id(self, obj):
|
|
return obj.workout.id
|
|
get_workout_id.admin_order_field = 'workout_id' #Allows column order sorting
|
|
get_workout_id.short_description = 'Workout id' #Renames column head |