From 0e39bad8d61b8c1cb90f072beb58c8b5320a5a11 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 19 Aug 2016 12:04:58 +0200 Subject: Operations: check PATRIARCHE unicity inside forms (refs #2930) --- archaeological_operations/widgets.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'archaeological_operations/widgets.py') diff --git a/archaeological_operations/widgets.py b/archaeological_operations/widgets.py index 3a4c458f6..bb219ab76 100644 --- a/archaeological_operations/widgets.py +++ b/archaeological_operations/widgets.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2013 Étienne Loks +# Copyright (C) 2013-2016 Étienne Loks # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,7 +17,9 @@ # See the file COPYING for details. +from django import forms from django.forms import widgets +from django.template import Context, loader from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ @@ -52,3 +54,17 @@ class SelectParcelWidget(widgets.TextInput): render += u" " \ % _(u"Add") return mark_safe(render) + + +class OAWidget(forms.TextInput): + def render(self, name, value, attrs=None): + if not value: + value = u"" + final_attrs = widgets.flatatt( + self.build_attrs(attrs, name=name, value=value)) + dct = {'final_attrs': final_attrs, + 'id': attrs['id'], + "safe_id": attrs['id'].replace('-', '_')} + t = loader.get_template('ishtar/blocks/OAWidget.html') + rendered = t.render(Context(dct)) + return mark_safe(rendered) -- cgit v1.2.3