Commit e73bc2d0c87bf2b3ba1a44ff55411245a7245e6f
1 parent
02a35e7c
Exists in
master
and in
3 other branches
Adding not visible propagation
Showing
1 changed file
with
11 additions
and
0 deletions
Show diff stats
categories/views.py
@@ -201,6 +201,17 @@ class UpdateCategory(LogMixin, UpdateView): | @@ -201,6 +201,17 @@ class UpdateCategory(LogMixin, UpdateView): | ||
201 | 201 | ||
202 | return reverse_lazy('subjects:index') | 202 | return reverse_lazy('subjects:index') |
203 | 203 | ||
204 | + def form_valid(self, form): | ||
205 | + category = form.save() | ||
206 | + | ||
207 | + if not category.visible: | ||
208 | + for subjects in category.subject_category.all(): | ||
209 | + subjects.visible = False | ||
210 | + | ||
211 | + subjects.save() | ||
212 | + | ||
213 | + return super(UpdateCategory, self).form_valid(form) | ||
214 | + | ||
204 | def get_context_data(self, **kwargs): | 215 | def get_context_data(self, **kwargs): |
205 | context = super(UpdateCategory, self).get_context_data(**kwargs) | 216 | context = super(UpdateCategory, self).get_context_data(**kwargs) |
206 | context['title'] = _('Update Category') | 217 | context['title'] = _('Update Category') |