-# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
-# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
#
from functools import wraps
import json
from django.shortcuts import render
from django.utils.encoding import force_str
from django.utils.functional import Promise
-from django.utils.translation import gettext_lazy as _
from django.views.decorators.vary import vary_on_headers
from honeypot.decorators import verify_honeypot_value
from wolnelektury.utils import is_ajax
return HttpResponseRedirect('/uzytkownicy/zaloguj') # next?=request.build_full_path())
-def placeholdized(form):
- for field in form.fields.values():
- field.widget.attrs['placeholder'] = field.label + ('*' if field.required else '')
- return form
-
-
class AjaxableFormView:
"""Subclass this to create an ajaxable view for any form.
"""
form_class = None
- placeholdize = False
# override to customize form look
template = "ajaxable/form.html"
- submit = _('Send')
+ submit = 'Send'
action = ''
title = ''
cd = self.context_description(request, obj)
if cd:
title += ": " + cd
- if self.placeholdize:
- form = placeholdized(form)
context = {
self.formname: form,
"title": title,
"honeypot": self.honeypot,
- "placeholdize": self.placeholdize,
"submit": self.submit,
"action": self.action,
"response_data": response_data,