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

Generated: Sun 2014-01-12 11:05 GMT

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

Stats: 32 executed, 0 missed, 6 excluded, 46 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. def clean_ftp_path(self):
  45. data = self.cleaned_data['ftp_path']
  46. if not data.endswith('/'):
  47. data = '%s/' % data
  48. return data
  49. class Meta:
  50. model = Service
  51. exclude = ['status', 'status_date', 'status_message']
  52. widgets = {
  53. 'ftp_password': forms.PasswordInput(render_value=True),
  54. }
  55. class ServiceNotificationForm(forms.ModelForm):
  56. def __init__(self, *args, **kwargs):
  57. super(ServiceNotificationForm, self).__init__(*args, **kwargs)
  58. self.helper = FormHelper()
  59. self.helper.form_id = 'notification-form'
  60. self.helper.form_class = 'form-horizontal'
  61. self.helper.label_class = 'hide'
  62. self.helper.field_class = 'col-sm-12'
  63. self.helper.form_tag = False
  64. self.helper.layout = Layout(
  65. 'notification'
  66. )
  67. class Meta:
  68. model = Service
  69. fields = ['notification']