Commit 57fef8493d970593899fe0b63334fbd86188a538
1 parent
d8a5d4ad
Exists in
master
and in
2 other branches
Included bulletin create check and fix for reports
Showing
1 changed file
with
10 additions
and
0 deletions
Show diff stats
bulletin/views.py
... | ... | @@ -7,6 +7,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin |
7 | 7 | from django.http import JsonResponse |
8 | 8 | |
9 | 9 | from amadeus.permissions import has_subject_permissions, has_resource_permissions |
10 | +from .utils import brodcast_dificulties | |
11 | +from goals.models import Goals | |
10 | 12 | |
11 | 13 | import time |
12 | 14 | import datetime |
... | ... | @@ -145,6 +147,13 @@ class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
145 | 147 | slug = self.kwargs.get('slug', '') |
146 | 148 | topic = get_object_or_404(Topic, slug = slug) |
147 | 149 | |
150 | + existe = Goals.objects.filter(topic=topic).exists() | |
151 | + | |
152 | + if not existe: | |
153 | + messages.error(request,_("The topic has no goals, so you can't create a Bulletin") ) | |
154 | + caminho = request.META['HTTP_REFERER'] | |
155 | + return redirect(caminho) | |
156 | + | |
148 | 157 | if not has_subject_permissions(request.user, topic.subject): |
149 | 158 | return redirect(reverse_lazy('subjects:home')) |
150 | 159 | |
... | ... | @@ -199,6 +208,7 @@ class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
199 | 208 | |
200 | 209 | self.object.topic = topic |
201 | 210 | self.object.order = topic.resource_topic.count() + 1 |
211 | + self.object.all_students = True | |
202 | 212 | |
203 | 213 | if not self.object.topic.visible and not self.object.topic.repository: |
204 | 214 | self.object.visible = False | ... | ... |