contact_form.models: 15 total statements, 87.5% covered

Generated: Wed 2013-12-04 16:44 CET

Source file: /home/dkaufhold/projects/bitmazk-contact-form/src/contact_form/models.py

Stats: 7 executed, 1 missed, 7 excluded, 26 ignored

  1. """Models for the ``contact_form`` app."""
  2. from django.db import models
  3. from django.utils.translation import ugettext_lazy as _
  4. from django_libs.models_mixins import SimpleTranslationMixin
  5. class ContactFormCategory(SimpleTranslationMixin, models.Model):
  6. """
  7. The category of the users contact request.
  8. Is created as translatable master data by the admin.
  9. For translatable fields check the ``ContactFormCategoryTranslation`` model.
  10. """
  11. slug = models.SlugField(
  12. max_length=256,
  13. verbose_name=_('Slug'),
  14. )
  15. def __unicode__(self):
  16. return self.get_translation().name
  17. @property
  18. def name(self):
  19. return self.get_translation().name
  20. class ContactFormCategoryTranslation(models.Model):
  21. """Translatable fields of the ``ContactFormCategory`` model."""
  22. name = models.CharField(
  23. max_length=256,
  24. verbose_name=_('Name'),
  25. )
  26. # needed by simple-translation
  27. contact_form_category = models.ForeignKey(ContactFormCategory)
  28. language = models.CharField(max_length=16)
  29. def __unicode__(self):
  30. return '{0} ({1})'.format(self.name, self.language)