diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-08-19 12:04:58 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-08-19 12:04:58 +0200 |
commit | 0e39bad8d61b8c1cb90f072beb58c8b5320a5a11 (patch) | |
tree | de69c2af87cef1e2c7f89feae3c53aaa860c96d8 /archaeological_operations/widgets.py | |
parent | d1fb3d446ccfe8b7eec27a85726cd8dd0cf36f6e (diff) | |
download | Ishtar-0e39bad8d61b8c1cb90f072beb58c8b5320a5a11.tar.bz2 Ishtar-0e39bad8d61b8c1cb90f072beb58c8b5320a5a11.zip |
Operations: check PATRIARCHE unicity inside forms (refs #2930)
Diffstat (limited to 'archaeological_operations/widgets.py')
-rw-r--r-- | archaeological_operations/widgets.py | 18 |
1 files changed, 17 insertions, 1 deletions
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 <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2013-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # 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" <button name='formset_add' value='add'>%s</button>" \ % _(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) |