BO 1.18 clone training_plan_id sort = max(sort) + 1
This commit is contained in:
parent
1812fc4d52
commit
b5425a74d8
@ -12,9 +12,9 @@ class TranslationTrainingPlanInline(admin.TabularInline):
|
||||
|
||||
|
||||
class TrainingPlanAdmin(admin.ModelAdmin):
|
||||
list_display = ('training_plan_id', 'name','internal_name', 'free')
|
||||
fields = ('tree', 'name','description', 'internal_name', 'free')
|
||||
list_editable = ('name','internal_name', 'free')
|
||||
list_display = ('training_plan_id', 'name', 'internal_name', 'free')
|
||||
fields = ('tree', 'name', 'description', 'internal_name', 'free')
|
||||
list_editable = ('name', 'internal_name', 'free')
|
||||
|
||||
inlines = [
|
||||
TranslationTrainingPlanInline
|
||||
@ -27,7 +27,7 @@ class TrainingPlanDetailAdmin(admin.ModelAdmin):
|
||||
'resting_time', 'parallel', 'day')
|
||||
list_filter = ('training_plan__name', 'exercise_type__name')
|
||||
list_editable = (
|
||||
'exercise_type', 'sort', 'set', 'repeats', 'weight', 'resting_time', 'parallel', 'day')
|
||||
'exercise_type', 'sort', 'set', 'repeats', 'weight', 'resting_time', 'parallel', 'day')
|
||||
ordering = ('sort',)
|
||||
|
||||
def repeat_max(self, obj):
|
||||
@ -53,28 +53,37 @@ class TrainingPlanDetailAdmin(admin.ModelAdmin):
|
||||
return response
|
||||
|
||||
def copy_attributes(self, request, queryset):
|
||||
name = str(queryset[0].training_plan)
|
||||
details = TrainingPlanDetail.objects.filter(training_plan__name=name).order_by('sort')
|
||||
new_sort = details[len(details)-1].sort + 1
|
||||
|
||||
for objectAttr in reversed(queryset):
|
||||
|
||||
objectAttr.pk = None
|
||||
objectAttr.sort = objectAttr.sort + 1
|
||||
objectAttr.sort = new_sort
|
||||
objectAttr.save()
|
||||
new_sort = new_sort + 1
|
||||
|
||||
copy_attributes.short_description = _("Clone the selected Training Plan Detail")
|
||||
|
||||
def select_max_repeat(self, request, queryset):
|
||||
for obj in queryset:
|
||||
obj.repeats = -1
|
||||
obj.save()
|
||||
|
||||
select_max_repeat.short_description = _("Select the exercises with MAX repeats")
|
||||
|
||||
def select_weight_calc(self, request, queryset):
|
||||
for obj in queryset:
|
||||
obj.weight = -1
|
||||
obj.save()
|
||||
|
||||
select_weight_calc.short_description = _("Select the exercises CALCULATED weight")
|
||||
|
||||
def max(self, obj):
|
||||
color_code = "000000"
|
||||
if obj.repeats and obj.repeats == -1:
|
||||
color_code = 'C20000'
|
||||
color_code = 'C20000'
|
||||
|
||||
html = '<span style="color: #{};font-size:32px">{}</span>'.format(color_code, "*")
|
||||
return format_html(html)
|
||||
|
@ -139,4 +139,3 @@ volumes:
|
||||
media:
|
||||
wordpress:
|
||||
mautic_data:
|
||||
xwiki-data:
|
Loading…
Reference in New Issue
Block a user