X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/98b2c09ef1f1c8288a31517f61423264c6b3291c..29f694eea94d09bd66976321ddfd80ac30b73d38:/src/contact/models.py?ds=sidebyside diff --git a/src/contact/models.py b/src/contact/models.py index adffafa38..0ab8201f4 100644 --- a/src/contact/models.py +++ b/src/contact/models.py @@ -36,6 +36,17 @@ class Contact(models.Model): data = '%s%s%s%s%s' % (self.id, self.contact, serialized_body, self.ip, self.form_tag) return sha1(data).hexdigest() + def keys(self): + try: + from .views import contact_forms + orig_fields = contact_forms[self.form_tag]().fields + except KeyError: + orig_fields = {} + return list(orig_fields.keys()) + + def items(self): + return [(key, self.body[key]) for key in self.keys() if key in self.body] + class Attachment(models.Model): contact = models.ForeignKey(Contact)