Self hosted FLOSS fitness/workout, nutrition and weight tracker
Don't allow deleting the set unit with the ID 1
Roland Geider01ad5605c510
diff --git a/wger/core/templates/setting_unit/list.html b/wger/core/templates/setting_unit/list.htmlindex 7fee57b85..c4ceb42ec 100644--- a/wger/core/templates/setting_unit/list.html+++ b/wger/core/templates/setting_unit/list.html@@ -8,6 +8,7 @@<ul class="list-group">{% for unit in object_list %}<li class="list-group-item ">+ {% if unit.id != 1 %}<div class="btn-group pull-right"><button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span>@@ -21,6 +22,7 @@</li></ul></div>+ {% endif %}{{unit}}</li>{% empty %}diff --git a/wger/core/views/setting_units.py b/wger/core/views/setting_units.pyindex a78deecc6..eed374040 100644--- a/wger/core/views/setting_units.py+++ b/wger/core/views/setting_units.py@@ -19,6 +19,7 @@ import loggingfrom django.core.urlresolvers import reverse, reverse_lazyfrom django.utils.translation import ugettext as _from django.utils.translation import ugettext_lazy+from django.http import HttpResponseForbiddenfrom django.views.generic import (ListView,DeleteView,@@ -89,6 +90,17 @@ class DeleteView(WgerDeleteMixin, DeleteView, WgerPermissionMixin):permission_required = 'core.delete_settingunit'form_action_urlname = 'core:setting_unit:delete'+ def dispatch(self, request, *args, **kwargs):+ '''+ Deleting the unit with ID 1 (repetitions) is not allowed++ This is the default and is hard coded in a couple of places+ '''+ if self.kwargs['pk'] == '1':+ return HttpResponseForbidden()++ return super(DeleteView, self).dispatch(request, *args, **kwargs)+def get_context_data(self, **kwargs):'''Send some additional data to the template