Test coverage report: ftp_deploy.server.views.notification

# ftp_deploy.server.views.notification: 38 total statements, 68.8% covered

Generated: Thu 2013-12-19 21:13 GMT

Source file: /var/www/service.dev/service/ftp_deploy/server/views/notification.py

Stats: 22 executed, 10 missed, 6 excluded, 24 ignored

1. `from django.views.generic import ListView, UpdateView, DeleteView, DetailView, CreateView`
2. `from django.core.urlresolvers import reverse_lazy, reverse`
3. `from django.contrib import messages`
4. ``
5. `from braces.views import JSONResponseMixin, LoginRequiredMixin`
6. ``
7. `from ftp_deploy.models import Notification`
8. `from ftp_deploy.server.forms import NotificationForm`
9. ``
10. ``
11. `class NotificationView(LoginRequiredMixin, ListView):`
12. ``
13. `model = Notification`
14. `template_name = 'ftp_deploy/notification/notification.html'`
15. `context_object_name = 'notifications'`
16. ``
17. ``
18. `class NotificationAddView(LoginRequiredMixin, CreateView):`
19. ``
20. `"""View for add notifications"""`
21. ``
22. `model = Notification`
23. `form_class = NotificationForm`
24. `success_url = reverse_lazy('ftpdeploy_notification')`
25. `template_name = "ftp_deploy/notification/form.html"`
26. ``
27. `def form_valid(self, form):`
28. `messages.add_message(self.request, messages.SUCCESS, 'Notification has been added.')`
29. `return super(NotificationAddView, self).form_valid(form)`
30. ``
31. ``
32. `class NotificationEditView(LoginRequiredMixin, UpdateView):`
33. ``
34. `"""View for edit notifications"""`
35. ``
36. `model = Notification`
37. `form_class = NotificationForm`
38. `success_url = reverse_lazy('ftpdeploy_notification')`
39. `template_name = "ftp_deploy/notification/form.html"`
40. ``
41. `def get_context_data(self, **kwargs):`
42. `context = super(NotificationEditView, self).get_context_data(**kwargs)`
43. `emails = self.get_object().get_email_list()`
44. `context['emails'] = emails`
45. `return context`
46. ``
47. `def form_valid(self, form):`
48. `messages.add_message(self.request, messages.SUCCESS, 'Notification has been updated.')`
49. `return super(NotificationEditView, self).form_valid(form)`
50. ``
51. ``
52. `class NotificationDeleteView(LoginRequiredMixin, DeleteView):`
53. ``
54. `"""View for delete services"""`
55. ``
56. `model = Notification`
57. `success_url = reverse_lazy('ftpdeploy_notification')`
58. `template_name = "ftp_deploy/notification/delete.html"`
59. ``
60. `def delete(self, request, *args, **kwargs):`
61. `messages.add_message(request, messages.SUCCESS, 'Notification has been removed.')`
62. `return super(NotificationDeleteView, self).delete(request, *args, **kwargs)`