Test coverage report: ftp_deploy.server.views.log

# ftp_deploy.server.views.log: 30 total statements, 82.6% covered

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

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

Stats: 19 executed, 4 missed, 7 excluded, 16 ignored

1. `from django.views.generic import ListView`
2. `from django.views.generic.detail import SingleObjectMixin`
3. `from django.views.generic.base import View`
4. `from django.shortcuts import render_to_response`
5. `from django.template import RequestContext`
6. `from braces.views import JSONResponseMixin, LoginRequiredMixin`
7. ``
8. `from ftp_deploy.models import Log, Service`
9. ``
10. ``
11. `class LogView(LoginRequiredMixin, ListView):`
12. ``
13. `"""View for display logs"""`
14. ``
15. `model = Log`
16. `context_object_name = 'logs'`
17. `template_name = "ftp_deploy/log/log.html"`
18. `paginate_by = 25`
19. ``
20. `def get_context_data(self, **kwargs):`
21. `context = super(LogView, self).get_context_data(**kwargs)`
22. `context['service_list'] = Service.objects.all().values('repo_name', 'pk')`
23. `return context`
24. ``
25. `def post(self, request, *args, **kwargs):`
26. `logs = self.get_queryset()`
27. `if self.request.POST['services']:`
28. `logs = logs.filter(service__pk=self.request.POST['services'])`
29. ``
30. `if not int(self.request.POST['status']):`
31. `logs = logs.filter(status=self.request.POST['status'])`
32. ``
33. `return render_to_response('ftp_deploy/log/list.html', locals(), context_instance=RequestContext(request))`
34. ``
35. ``
36. `class LogSkipDeployView(LoginRequiredMixin, JSONResponseMixin, SingleObjectMixin, View):`
37. ``
38. `"""View for skip fail logs"""`
39. ``
40. `model = Log`
41. ``
42. `def post(self, request, *args, **kwargs):`
43. `log = self.object`
44. `log.skip = 1`
45. `log.save()`
46. `return self.render_json_response({'status': 'success'})`