annotate data/plugin/macro/FormRadio.py @ 628:819c4121f9a0

FormCreate/FormSubmit: change to LF-only line endings
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 25 Mar 2013 19:48:31 +0100
parents e6a6740166c8
children
rev   line source
628
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
1 # -*- coding: iso-8859-1 -*-
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
2 """
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
3 MoinMoin - FormRadio Macro
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
4
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
5 @copyright: 2008 by Peter Bodi <petrdll@centrum.sk>
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
6 @license: GNU GPL, see COPYING for details.
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
7 """
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
8
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
9 from FormField import FormField
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
10
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
11
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
12 class FormRadio(FormField):
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
13
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
14 def __init(self, macro, args):
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
15 FormField.__init__(self, macro, args)
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
16
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
17 self.value = ""
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
18 self.checked = ""
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
19 self.size = ""
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
20
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
21 def parse_args(self):
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
22 FormField.parse_args(self)
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
23
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
24 self.value = self._main[1]
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
25
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
26 def validate(self):
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
27 FormField.validate(self)
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
28 if not self.value:
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
29 self.msg = self._("Field value is not defined")
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
30 raise FormValidationError(self.msg)
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
31
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
32 def build(self):
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
33 FormField.build(self)
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
34 self._attribs["value"] = self.value
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
35 self._attribs["checked"] = "checked"
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
36 #self.output += self._build_input("hidden", "labels[]", {'value':self.label})
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
37 self.output += self._build_input("radio", self.label, self._attribs)
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
38
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
39
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
40 def execute(macro, args):
819c4121f9a0 FormCreate/FormSubmit: change to LF-only line endings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 618
diff changeset
41 return FormRadio(macro, args).render()