cms.plugins.googlemap.forms: 19 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/cms/plugins/googlemap/forms.py

Stats: 0 executed, 15 missed, 4 excluded, 8 ignored

  1. # coding: utf-8
  2. import re
  3. from django.forms.models import ModelForm
  4. from .models import GoogleMap
  5. from django.utils.translation import ugettext_lazy as _
  6. CSS_WIDTH_RE = re.compile(r'^\d+(?:px|%)$')
  7. CSS_HEIGHT_RE = re.compile(r'^\d+px$')
  8. class GoogleMapForm(ModelForm):
  9. class Meta:
  10. model = GoogleMap
  11. def clean(self):
  12. cleaned_data = super(GoogleMapForm, self).clean()
  13. width = cleaned_data.get('width', '')
  14. height = cleaned_data.get('height', '')
  15. if width or height:
  16. if width and not CSS_WIDTH_RE.match(width):
  17. self._errors['width'] = self.error_class([
  18. _(u'Must be a positive integer followed by “px” or “%”.')])
  19. if height and not CSS_HEIGHT_RE.match(height):
  20. self._errors['height'] = self.error_class([
  21. _(u'Must be a positive integer followed by “px”.')])
  22. return cleaned_data