summaryrefslogtreecommitdiff
path: root/archaeological_operations/widgets.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-08-23 11:07:45 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-08-23 11:07:45 +0200
commit7924c43af9044cfd40f36bd8a84378417223d95b (patch)
tree78197ea5c36baaff4fcc1a53580eb3d586630b39 /archaeological_operations/widgets.py
parent54b87741a26a2bd805ed32200b082ca07ee0e27d (diff)
parent0bdaa7c90017b436b3baf026c9710a8d49c9420a (diff)
downloadIshtar-7924c43af9044cfd40f36bd8a84378417223d95b.tar.bz2
Ishtar-7924c43af9044cfd40f36bd8a84378417223d95b.zip
Merge branch 'master' into v0.9
Conflicts: ishtar_common/migrations/0053_auto__add_field_ishtarsiteprofile_currency.py
Diffstat (limited to 'archaeological_operations/widgets.py')
-rw-r--r--archaeological_operations/widgets.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/archaeological_operations/widgets.py b/archaeological_operations/widgets.py
index e3c0cd2ea..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 _
@@ -33,6 +35,7 @@ class ParcelWidget(widgets.MultiWidget):
_widgets = (
widgets.TextInput(attrs=attrs),
widgets.TextInput(attrs=attrs),
+ widgets.CheckboxInput(),
)
super(ParcelWidget, self).__init__(_widgets, attrs)
@@ -51,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)