models.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: utf-8 -*-
  2. from django.contrib.contenttypes.models import ContentType
  3. from django.db import models
  4. from django.contrib.auth.models import User
  5. class Application(models.Model):
  6. name = models.CharField(max_length=60, unique=True, verbose_name=u"nome")
  7. python_name = models.CharField(max_length=255, unique=True, verbose_name=u"Nome no Python")
  8. managers = models.ManyToManyField(User, verbose_name=u'gestores', related_name='managed_applications')
  9. enabled = models.BooleanField(default=True, verbose_name=u"ativa")
  10. def __unicode__(self):
  11. return self.name
  12. url_name = 'aplicacao'
  13. class Meta(object):
  14. verbose_name = u'aplicação'
  15. verbose_name_plural = u'aplicações'
  16. class Profile(models.Model):
  17. id = models.AutoField(primary_key=True)
  18. application = models.ForeignKey(Application, verbose_name=u'aplicação')
  19. name = models.CharField(max_length=60, verbose_name=u'nome')
  20. description = models.TextField(verbose_name=u'descrição')
  21. users = models.ManyToManyField(User, verbose_name=u'usuários', blank=True)
  22. def __unicode__(self):
  23. return self.name
  24. class Meta(object):
  25. verbose_name = u'perfil'
  26. verbose_name_plural = u'perfis'
  27. unique_together = (('application', 'name'),)
  28. class DocumentTemplate(models.Model):
  29. name = models.CharField(max_length=60, verbose_name=u'nome')
  30. model = models.ForeignKey(ContentType)
  31. template = models.FileField(upload_to='rapid/document_templates')
  32. def __unicode__(self):
  33. return self.name
  34. class Meta(object):
  35. verbose_name = u'template de documento'
  36. verbose_name_plural = u'templates de documento'