models.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from django.core.exceptions import ValidationError
  2. from django.db import models
  3. from django.template.defaultfilters import slugify
  4. from django.utils import timezone
  5. from django.utils.translation import ugettext_lazy as _
  6. from misago.conf import settings
  7. class Agreement(models.Model):
  8. TYPE_TOS = 'terms-of-service'
  9. TYPE_PRIVACY = 'privacy-policy'
  10. TYPE_CHOICES = [
  11. (TYPE_TOS, _('Terms of service')),
  12. (TYPE_PRIVACY, _('Privacy Policy')),
  13. ]
  14. type = models.CharField(
  15. max_length=20,
  16. default=TYPE_TOS,
  17. choices=TYPE_CHOICES,
  18. db_index=True,
  19. )
  20. version = models.SlugField(unique=True, blank=True)
  21. title = models.CharField(max_length=255)
  22. text = models.TextField()
  23. is_active = models.BooleanField(default=False)
  24. created_on = models.DateTimeField(default=timezone.now)
  25. created_by = models.ForeignKey(
  26. settings.AUTH_USER_MODEL,
  27. blank=True,
  28. null=True,
  29. related_name='+',
  30. )
  31. created_by_name = models.CharField(max_length=255, null=True, blank=True)
  32. last_modified_on = models.DateTimeField(default=timezone.now)
  33. last_modified_by = models.ForeignKey(
  34. settings.AUTH_USER_MODEL,
  35. blank=True,
  36. null=True,
  37. related_name='+',
  38. )
  39. last_modified_by_name = models.CharField(max_length=255, null=True, blank=True)
  40. class UserAgreement(models.Model):
  41. user = models.ForeignKey(
  42. settings.AUTH_USER_MODEL,
  43. blank=True,
  44. null=True,
  45. related_name='agreements'
  46. )
  47. agreement = models.ForeignKey(Agreement, related_name='agreements')
  48. accepted_on = models.DateTimeField(default=timezone.now)
  49. class Meta:
  50. ordering = ["-accepted_on"]