ftp_deploy.server.forms.service: 33 total statements, 100.0% covered

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

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

Stats: 27 executed, 0 missed, 6 excluded, 45 ignored

  1. from django import forms
  2. from django.core.urlresolvers import reverse
  3. from crispy_forms.helper import FormHelper
  4. from crispy_forms.bootstrap import FormActions
  5. from crispy_forms.layout import Layout, Fieldset, Field, Submit, Div
  6. from ftp_deploy.models import Service
  7. class ServiceForm(forms.ModelForm):
  8. """Add/Edit service form"""
  9. def __init__(self, *args, **kwargs):
  10. super(ServiceForm, self).__init__(*args, **kwargs)
  11. self.helper = FormHelper()
  12. self.helper.form_id = 'service-form'
  13. self.helper.form_class = 'form-horizontal'
  14. self.helper.label_class = 'col-sm-3'
  15. self.helper.field_class = 'col-sm-9'
  16. self.helper.html5_required = True
  17. self.helper.layout = Layout(
  18. Fieldset('FTP Settings',
  19. 'ftp_host',
  20. 'ftp_username',
  21. 'ftp_password',
  22. 'ftp_path'
  23. ),
  24. Fieldset('Repository',
  25. Field('repo_source', data_action=reverse('ftpdeploy_bb_api', args=(0,))),
  26. 'repo_name',
  27. 'repo_slug_name',
  28. 'repo_branch'
  29. ),
  30. Fieldset('Notification',
  31. 'notification'
  32. ),
  33. Fieldset('Security',
  34. 'secret_key'
  35. ),
  36. Div(
  37. Div(
  38. Submit('save', 'Submit', css_class='pull-right'),
  39. css_class='col-sm-12'
  40. ),
  41. css_class='row'
  42. )
  43. )
  44. class Meta:
  45. model = Service
  46. exclude = ['status', 'status_date', 'status_message']
  47. widgets = {
  48. 'ftp_password': forms.PasswordInput(render_value=True),
  49. }
  50. class ServiceNotificationForm(forms.ModelForm):
  51. def __init__(self, *args, **kwargs):
  52. super(ServiceNotificationForm, self).__init__(*args, **kwargs)
  53. self.helper = FormHelper()
  54. self.helper.form_id = 'notification-form'
  55. self.helper.form_class = 'form-horizontal'
  56. self.helper.label_class = 'hide'
  57. self.helper.field_class = 'col-sm-12'
  58. self.helper.form_tag = False
  59. self.helper.layout = Layout(
  60. 'notification'
  61. )
  62. class Meta:
  63. model = Service
  64. fields = ['notification']