BO 1.18 clone training_plan_id sort = max(sort) + 1
This commit is contained in:
parent
1812fc4d52
commit
b5425a74d8
@ -53,22 +53,31 @@ class TrainingPlanDetailAdmin(admin.ModelAdmin):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
def copy_attributes(self, request, queryset):
|
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):
|
for objectAttr in reversed(queryset):
|
||||||
|
|
||||||
objectAttr.pk = None
|
objectAttr.pk = None
|
||||||
objectAttr.sort = objectAttr.sort + 1
|
objectAttr.sort = new_sort
|
||||||
objectAttr.save()
|
objectAttr.save()
|
||||||
|
new_sort = new_sort + 1
|
||||||
|
|
||||||
copy_attributes.short_description = _("Clone the selected Training Plan Detail")
|
copy_attributes.short_description = _("Clone the selected Training Plan Detail")
|
||||||
|
|
||||||
def select_max_repeat(self, request, queryset):
|
def select_max_repeat(self, request, queryset):
|
||||||
for obj in queryset:
|
for obj in queryset:
|
||||||
obj.repeats = -1
|
obj.repeats = -1
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
select_max_repeat.short_description = _("Select the exercises with MAX repeats")
|
select_max_repeat.short_description = _("Select the exercises with MAX repeats")
|
||||||
|
|
||||||
def select_weight_calc(self, request, queryset):
|
def select_weight_calc(self, request, queryset):
|
||||||
for obj in queryset:
|
for obj in queryset:
|
||||||
obj.weight = -1
|
obj.weight = -1
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
select_weight_calc.short_description = _("Select the exercises CALCULATED weight")
|
select_weight_calc.short_description = _("Select the exercises CALCULATED weight")
|
||||||
|
|
||||||
def max(self, obj):
|
def max(self, obj):
|
||||||
|
@ -139,4 +139,3 @@ volumes:
|
|||||||
media:
|
media:
|
||||||
wordpress:
|
wordpress:
|
||||||
mautic_data:
|
mautic_data:
|
||||||
xwiki-data:
|
|
Loading…
Reference in New Issue
Block a user