Add list-single field type

darcs-hash:20070117175956-86b55-1d833aae947a048e6240a393837cfde02e918b6f.gz
This commit is contained in:
David Rousselie
2007-01-17 18:59:56 +01:00
parent 56209ddff1
commit 583679b6ed
4 changed files with 51 additions and 29 deletions

View File

@@ -437,7 +437,8 @@ class JCLComponent_TestCase(unittest.TestCase):
self.assertEquals(fields[4].prop("type"), "list-single")
self.assertEquals(fields[4].prop("var"), "test_enum")
self.assertEquals(fields[4].prop("label"), "test_enum")
# TODO : test options
self.assertEquals(fields[5].prop("type"), "text-single")
self.assertEquals(fields[5].prop("var"), "test_int")
self.assertEquals(fields[5].prop("label"), "test_int")
@@ -572,6 +573,7 @@ class JCLComponent_TestCase(unittest.TestCase):
self.assertEquals(field.prop("label"), "test_enum")
self.assertEquals(field.children.name, "value")
self.assertEquals(field.children.content, "choice3")
# TODO : test options
field = fields[5]
self.assertEquals(field.prop("type"), "text-single")
self.assertEquals(field.prop("var"), "test_int")

View File

@@ -44,15 +44,16 @@ class AccountExample(Account):
return password
return Account.get_register_fields() + \
[("login", "text-single", account.string_not_null_post_func, \
[("login", "text-single", None, account.string_not_null_post_func, \
account.mandatory_field), \
("password", "text-private", password_post_func, \
("password", "text-private", None, password_post_func, \
(lambda field_name: None)), \
("store_password", "boolean", account.boolean_post_func, \
("store_password", "boolean", None, account.boolean_post_func, \
lambda field_name: True), \
("test_enum", "list-single",account.string_not_null_post_func,\
("test_enum", "list-single", ["choice1", "choice2", "choice3"], \
account.string_not_null_post_func,\
lambda field_name: "choice2"), \
("test_int", "text-single", account.int_post_func, \
("test_int", "text-single", None, account.int_post_func, \
lambda field_name: 44)]
get_register_fields = classmethod(_get_register_fields)
@@ -60,7 +61,9 @@ class AccountExample(Account):
class PresenceAccountExample(PresenceAccount):
DO_SOMETHING_ELSE = 2
possibles_actions = [DO_SOMETHING_ELSE]
possibles_actions = [PresenceAccount.DO_NOTHING, \
PresenceAccount.DO_SOMETHING, \
DO_SOMETHING_ELSE]
def _get_presence_actions_fields(cls):
"""See PresenceAccount._get_presence_actions_fields