Commit 99cfa4deadb09ce705b3006b406e2d8d0b439f3e
1 parent
14fa7c5d
Exists in
master
and in
2 other branches
resolvendo bug no modal de subscribe
Showing
2 changed files
with
5 additions
and
3 deletions
Show diff stats
subjects/templates/subjects/subscribe.html
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <!-- Modal Body --> |
8 | 8 | <div class="modal-body"> |
9 | 9 | <!-- Put ONLY your content here!!! --> |
10 | - <form id="subscribe" action="" method="post"> | |
10 | + <form id="subscribe" action="{% url 'subjects:subscribe' subject.slug %}" method="post"> | |
11 | 11 | {% csrf_token %} |
12 | 12 | <p>{% trans 'Are you sure you want to subscribe to the subject' %} "{{subject.name}}"?</p> |
13 | 13 | </form> | ... | ... |
subjects/views.py
... | ... | @@ -558,7 +558,9 @@ class SubjectSubscribeView(LoginRequiredMixin, LogMixin, TemplateView): |
558 | 558 | def post(self, request, *args, **kwargs): |
559 | 559 | subject = get_object_or_404(Subject, slug= kwargs.get('slug')) |
560 | 560 | |
561 | - if subject.subscribe_end < datetime.datetime.today().date(): | |
561 | + print ("Deu Certo ", subject) | |
562 | + | |
563 | + if subject.subscribe_end <= datetime.datetime.today().date(): | |
562 | 564 | messages.error(self.request, _('Subscription date is due!')) |
563 | 565 | else: |
564 | 566 | self.log_context['category_id'] = subject.category.id |
... | ... | @@ -574,7 +576,7 @@ class SubjectSubscribeView(LoginRequiredMixin, LogMixin, TemplateView): |
574 | 576 | subject.save() |
575 | 577 | messages.success(self.request, _('Subscription was successfull!')) |
576 | 578 | |
577 | - return JsonResponse({'url':reverse_lazy('subjects:index')}) | |
579 | + return redirect(reverse_lazy('subjects:view',kwargs={"slug": subject.slug})) | |
578 | 580 | |
579 | 581 | |
580 | 582 | class SubjectSearchView(LoginRequiredMixin, LogMixin, ListView): | ... | ... |