Commit 3f292faf10ecdfa0ad604da4907fe01fac1213d1
1 parent
f1326667
Exists in
master
and in
3 other branches
Fixing update category error
Showing
3 changed files
with
36 additions
and
7 deletions
Show diff stats
categories/views.py
| @@ -193,12 +193,7 @@ class UpdateCategory(LogMixin, UpdateView): | @@ -193,12 +193,7 @@ class UpdateCategory(LogMixin, UpdateView): | ||
| 193 | 193 | ||
| 194 | super(UpdateCategory, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | 194 | super(UpdateCategory, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
| 195 | 195 | ||
| 196 | - objeto = self.object.name | ||
| 197 | - | ||
| 198 | - if not self.object.visible: | ||
| 199 | - for subject in self.object.subjects: | ||
| 200 | - subject.visible = self.object.visible | ||
| 201 | - messages.success(self.request, _('Category "%s" updated successfully!')%(objeto)) | 196 | + messages.success(self.request, _('Category "%s" updated successfully!')%(self.object.name)) |
| 202 | 197 | ||
| 203 | if self.request.user.is_staff: | 198 | if self.request.user.is_staff: |
| 204 | return reverse_lazy('categories:index') | 199 | return reverse_lazy('categories:index') |
security/views.py
| 1 | +from django.views import generic | ||
| 1 | from django.shortcuts import render | 2 | from django.shortcuts import render |
| 3 | +from django.contrib import messages | ||
| 4 | +from django.core.urlresolvers import reverse, reverse_lazy | ||
| 5 | +from django.utils.translation import ugettext_lazy as _ | ||
| 2 | 6 | ||
| 3 | -# Create your views here. | 7 | +from braces import views as braces_mixins |
| 8 | + | ||
| 9 | +from .models import Security | ||
| 10 | +from .forms import SecurityForm | ||
| 11 | + | ||
| 12 | +class SecuritySettings(braces_mixins.LoginRequiredMixin, braces_mixins.StaffuserRequiredMixin, generic.UpdateView): | ||
| 13 | + login_url = reverse_lazy("users:login") | ||
| 14 | + redirect_field_name = 'next' | ||
| 15 | + | ||
| 16 | + template_name = 'security/update.html' | ||
| 17 | + model = Security | ||
| 18 | + form_class = SecurityForm | ||
| 19 | + success_url = reverse_lazy("subjects:home") | ||
| 20 | + | ||
| 21 | + def get_object(self, queryset = None): | ||
| 22 | + return Security.objects.get(id = 1) | ||
| 23 | + | ||
| 24 | + def form_valid(self, form): | ||
| 25 | + form.save() | ||
| 26 | + | ||
| 27 | + messages.success(self.request, _("Security settings updated successfully!")) | ||
| 28 | + | ||
| 29 | + return super(SecuritySettings, self).form_valid(form) | ||
| 30 | + | ||
| 31 | + def get_context_data(self, **kwargs): | ||
| 32 | + context = super(SecuritySettings, self).get_context_data(**kwargs) | ||
| 33 | + | ||
| 34 | + context['title'] = _('Security') | ||
| 35 | + context['settings_menu_active'] = "settings_menu_active" | ||
| 36 | + | ||
| 37 | + return context |