Commit f2de07f7c3fc68af171f2de61915556eab802fc8
1 parent
2ad34aec
Exists in
master
and in
5 other branches
Starting the view to create, delete and modify the link [Issues #120,#121,#122]
Showing
1 changed file
with
14 additions
and
8 deletions
Show diff stats
links/views.py
... | ... | @@ -10,23 +10,29 @@ from .forms import * |
10 | 10 | |
11 | 11 | # Create your views here. |
12 | 12 | class CreateLink(generic.CreateView): |
13 | - template_name = 'links/' | |
13 | + template_name = 'links/link_modal.html' | |
14 | 14 | form_class = CreateLinkForm |
15 | 15 | success_url = reverse_lazy() |
16 | + context_object_name = 'links' | |
17 | + | |
16 | 18 | def form_valid(self, form): |
17 | - form.save() | |
18 | - messages.success(self.request, _('Link created successfully!')) | |
19 | - return super(CreateLink, self).form_valid(form) | |
19 | + form.save() | |
20 | + messages.success(self.request, _('Link created successfully!')) | |
21 | + return super(CreateLink, self).form_valid(form) | |
22 | + def get_context_data(self, **kwargs): | |
23 | + context = {} | |
24 | + context['links'] = Link.objects.all() | |
25 | + return context | |
20 | 26 | |
21 | 27 | |
22 | 28 | class DeleteLink(generic.DeleteView): |
23 | - | |
29 | + pass | |
24 | 30 | class UpdateLink(generic.UpdateView): |
25 | 31 | template_name = 'links/' |
26 | 32 | form_class = UpdateLinkForm |
27 | 33 | success_url = reverse_lazy() |
28 | 34 | def form_valid(self, form): |
29 | - form.save() | |
30 | - messages.success(self.request, _('Link updated successfully!')) | |
35 | + form.save() | |
36 | + messages.success(self.request, _('Link updated successfully!')) | |
31 | 37 | |
32 | - return super(UpdateLink, self).form_valid(form) | |
38 | + return super(UpdateLink, self).form_valid(form) | ... | ... |