Commit 4002c470e7bbeaff76062bc75ddaf8f3069a0e39
1 parent
247bfeee
Exists in
master
and in
3 other branches
Making webpage invisible if topic invisible
Showing
1 changed file
with
6 additions
and
0 deletions
Show diff stats
webpage/views.py
... | ... | @@ -123,6 +123,9 @@ class CreateView(LoginRequiredMixin, generic.edit.CreateView): |
123 | 123 | self.object.topic = topic |
124 | 124 | self.object.order = topic.resource_topic.count() + 1 |
125 | 125 | |
126 | + if not self.object.topic.visible and not self.object.topic.repository: | |
127 | + self.object.visible = False | |
128 | + | |
126 | 129 | self.object.save() |
127 | 130 | |
128 | 131 | pendencies_form.instance = self.object |
... | ... | @@ -201,6 +204,9 @@ class UpdateView(LoginRequiredMixin, generic.UpdateView): |
201 | 204 | def form_valid(self, form, pendencies_form): |
202 | 205 | self.object = form.save(commit = False) |
203 | 206 | |
207 | + if not self.object.topic.visible and not self.object.topic.repository: | |
208 | + self.object.visible = False | |
209 | + | |
204 | 210 | self.object.save() |
205 | 211 | |
206 | 212 | pendencies_form.instance = self.object | ... | ... |