Commit 9f7fddb9a1490e7d4da35e3cbbd190de83cee574
1 parent
9e2d65b7
Exists in
master
and in
5 other branches
Including error messages in create view and in delete view [Issues: #120,#121]
Showing
1 changed file
with
9 additions
and
6 deletions
Show diff stats
links/views.py
... | ... | @@ -18,12 +18,13 @@ class CreateLink(generic.CreateView): |
18 | 18 | def form_valid(self, form): |
19 | 19 | form.save() |
20 | 20 | messages.success(self.request, _('Link created successfully!')) |
21 | + messages.error(self.request, _("An error occurred when trying to create the link")) | |
21 | 22 | return super(CreateLink, self).form_valid(form) |
22 | - def get_context_data(self, **kwargs): | |
23 | - context = {} | |
24 | - context['links'] = Link.objects.all() | |
25 | - | |
26 | - return context | |
23 | + def get_context_data(self,**kwargs): | |
24 | + context = {} | |
25 | + context['links'] = Link.objects.all() | |
26 | + context['form'] = CreateLinkForm | |
27 | + return context | |
27 | 28 | |
28 | 29 | |
29 | 30 | def deleteLink(request,linkname): |
... | ... | @@ -31,11 +32,13 @@ def deleteLink(request,linkname): |
31 | 32 | link.delete() |
32 | 33 | template_name = 'links/delete_link.html' |
33 | 34 | messages.success(request,_("Link deleted Successfully!")) |
35 | + messages.error(request, _("An error occurred when trying to delete the link")) | |
34 | 36 | return redirect('course:manage') |
37 | +#Referencia no delete link para adicionar quando resolver o problema do context {% url 'course:delete' link.name %} | |
35 | 38 | class UpdateLink(generic.UpdateView): |
36 | 39 | template_name = 'links/update_link.html' |
37 | 40 | form_class = UpdateLinkForm |
38 | - success_url = reverse_lazy() | |
41 | + success_url = reverse_lazy('course:manage') | |
39 | 42 | def form_valid(self, form): |
40 | 43 | form.save() |
41 | 44 | messages.success(self.request, _('Link updated successfully!')) | ... | ... |