From fabff7659e0f8f07c5be34383a056555939f0ac8 Mon Sep 17 00:00:00 2001 From: Kerim Mansour Date: Sat, 28 Nov 2015 09:49:57 +0100 Subject: [PATCH] Started working on group_membership_type --- controllers/pr.py | 5 ++++ modules/s3db/pr.py | 44 ++++++++++++++++++++++++++++++++- modules/templates/DRK/tasks.cfg | 1 + 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/controllers/pr.py b/controllers/pr.py index b45d9899cd..82965c8c0e 100755 --- a/controllers/pr.py +++ b/controllers/pr.py @@ -100,6 +100,11 @@ def postp(r, output): response.title = module_name return output +def group_membership_type(): + """ Group Membership Type: RESTful CRUD Controller """ + + return s3_rest_controller() + # ----------------------------------------------------------------------------- def person(): """ RESTful CRUD controller """ diff --git a/modules/s3db/pr.py b/modules/s3db/pr.py index 1560e8448d..f77b3111e9 100644 --- a/modules/s3db/pr.py +++ b/modules/s3db/pr.py @@ -1894,7 +1894,8 @@ class S3GroupModel(S3Model): names = ("pr_group", "pr_group_id", - "pr_group_membership" + "pr_group_membership", + "pr_group_membership_type", ) def model(self): @@ -2052,6 +2053,45 @@ def model(self): }, ) + # Case Appointment Type + # + tablename = "pr_group_membership_type" + define_table(tablename, + Field("name", length=64, notnull=True, unique=True, + requires = IS_NOT_EMPTY(), + ), + Field("type", "integer", + requires = IS_NOT_EMPTY(), + ), + s3_comments(), + *s3_meta_fields()) + + # CRUD Strings + crud_strings[tablename] = Storage( + label_create = T("Create Group Membership Type"), + title_display = T("Group Membership Type Details"), + title_list = T("Group Membership Types"), + title_update = T("Edit Group Membership Types"), + label_list_button = T("List Group Membership Types"), + label_delete_button = T("Delete Group Membership Type"), + msg_record_created = T("Group Membership Type added"), + msg_record_modified = T("Group Membership Type updated"), + msg_record_deleted = T("Group Membership Type deleted"), + msg_list_empty = T("No Group Membership Types currently registered"), + ) + + # Reusable Field + represent = S3Represent(lookup=tablename, translate=True) + group_membership_type_id = S3ReusableField("type_id", "reference %s" % tablename, + label = T("Group Membership Type"), + ondelete = "RESTRICT", + represent = represent, + requires = IS_EMPTY_OR( + IS_ONE_OF(db, "pr_group_membership_type.id", + represent, + )), + ) + # --------------------------------------------------------------------- # Group membership # @@ -2071,6 +2111,8 @@ def model(self): represent = lambda group_head: \ (group_head and [T("yes")] or [""])[0] ), + group_membership_type_id(empty = False, + ), s3_comments(), *s3_meta_fields()) diff --git a/modules/templates/DRK/tasks.cfg b/modules/templates/DRK/tasks.cfg index 0350c6a833..08e3eaeebd 100644 --- a/modules/templates/DRK/tasks.cfg +++ b/modules/templates/DRK/tasks.cfg @@ -47,3 +47,4 @@ dvr,case_status,dvr_case_status.csv,case_status.xsl dvr,case_appointment_type,dvr_case_appointment_type.csv,case_appointment_type.xsl dvr,need,dvr_need.csv,need.xsl # ============================================================================= +pr,group_membership_type,group_membership_type.csv,group_membership_type.xsl \ No newline at end of file