1 # -*- coding: utf-8 -*-
2 from django.core.files.storage import FileSystemStorage
3 from django.db import models
4 from django.utils.translation import ugettext_lazy as _
5 from jsonfield import JSONField
6 from . import app_settings
9 class Contact(models.Model):
10 created_at = models.DateTimeField(_('submission date'), auto_now_add=True)
11 ip = models.IPAddressField(_('IP address'))
12 contact = models.CharField(_('contact'), max_length=128)
13 form_tag = models.CharField(_('form'), max_length=32, db_index=True)
14 body = JSONField(_('body'))
17 ordering = ('-created_at',)
18 verbose_name = _('submitted form')
19 verbose_name_plural = _('submitted forms')
21 def __unicode__(self):
22 return unicode(self.created_at)
25 class Attachment(models.Model):
26 contact = models.ForeignKey(Contact)
27 tag = models.CharField(max_length=64)
28 file = models.FileField(upload_to='contact/attachment')
31 def get_absolute_url(self):
32 return ('contact_attachment', [self.contact_id, self.tag])
35 __import__(app_settings.FORMS_MODULE)