X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c0a7799619e217e2eac724b1a688ad37f0182253..ce3795b6c4f878c496b4d46193e3379f8efb077b:/src/contact/forms.py?ds=sidebyside diff --git a/src/contact/forms.py b/src/contact/forms.py index ff1687adb..ecdc47d54 100644 --- a/src/contact/forms.py +++ b/src/contact/forms.py @@ -1,3 +1,7 @@ +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +import json from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.core.files.uploadedfile import UploadedFile @@ -25,9 +29,8 @@ class ContactFormMeta(forms.Form.__class__): return model -class ContactForm(forms.Form): +class ContactForm(forms.Form, metaclass=ContactFormMeta): """Subclass and define some fields.""" - __metaclass__ = ContactFormMeta form_tag = None form_title = _('Contact form') @@ -56,7 +59,7 @@ class ContactForm(forms.Form): body.setdefault(f.form_tag, []).append(sub_body) contact = Contact.objects.create( - body=body, + body=json.dumps(body), ip=request.META['REMOTE_ADDR'], contact=self.cleaned_data['contact'], form_tag=self.form_tag)