Skip to content

Commit

Permalink
CCC progress inc new models to allow linking of Groups to Tags, Locat…
Browse files Browse the repository at this point in the history
…ions & Skills
  • Loading branch information
flavour committed Jul 12, 2019
1 parent 96ab4c5 commit 26e128e
Show file tree
Hide file tree
Showing 14 changed files with 431 additions and 17 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bc6ee3dea (2019-07-12 11:50:55)
96ab4c5ac (2019-07-12 16:05:15)
7 changes: 5 additions & 2 deletions modules/s3db/hrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,7 @@ class S3HRSkillModel(S3Model):
"hrm_skill",
"hrm_competency_rating",
"hrm_competency",
#"hrm_competency_id",
"hrm_credential",
"hrm_training",
"hrm_trainings",
Expand Down Expand Up @@ -3522,7 +3523,8 @@ def model(self):
# ---------------------------------------------------------------------
# Pass names back to global scope (s3.*)
#
return {"hrm_course_id": course_id,
return {#"hrm_competency_id": competency_id,
"hrm_course_id": course_id,
"hrm_skill_id": skill_id,
"hrm_multi_skill_id": multi_skill_id,
"hrm_multi_skill_represent": multi_skill_represent,
Expand All @@ -3545,7 +3547,8 @@ def defaults():
readable = False,
writable = False)

return {"hrm_course_id": lambda **attr: dummy("course_id"),
return {#"hrm_competency_id": lambda **attr: dummy("competency_id"),
"hrm_course_id": lambda **attr: dummy("course_id"),
"hrm_skill_id": lambda **attr: dummy("skill_id"),
"hrm_multi_skill_id": lambda **attr: dummy_listref("skill_id"),
}
Expand Down
3 changes: 2 additions & 1 deletion modules/s3db/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,12 +1978,13 @@ def model(self):
requires = IS_LOCATION(),
widget = S3LocationAutocompleteWidget()
),
s3_comments(),
*s3_meta_fields()
)

# CRUD Strings
current.response.s3.crud_strings[tablename] = Storage(
label_create = T("New Location"),
label_create = T("Add Location"),
title_display = T("Location"),
title_list = T("Locations"),
title_update = T("Edit Location"),
Expand Down
162 changes: 162 additions & 0 deletions modules/s3db/pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@

"PRReligionModel",

# Group Components
"PRGroupCompetencyModel",
"PRGroupLocationModel",
"PRGroupTagModel",

# S3 Models
"S3ImageLibraryModel",
"S3RoleDelegationModel",
Expand Down Expand Up @@ -2513,6 +2518,20 @@ def model(self):
self.add_components(tablename,
pr_group_membership = "group_id",

# Tags
pr_group_tag = {"name": "tag",
"joinby": "group_id",
},

# Locations
gis_location = {"link": "pr_group_location",
"joinby": "group_id",
"key": "location_id",
"actuate": "hide",
"autodelete": False,
},
pr_group_location = "group_id",

# Shelter (Camp) Registry
cr_shelter_allocation = {"joinby": "group_id",
# A group can be assigned to only one shelter
Expand Down Expand Up @@ -2560,6 +2579,15 @@ def model(self):
},
org_organisation_team = "group_id",

# Skills
hrm_skill = {"link": "pr_group_competency",
"joinby": "group_id",
"key": "skill_id",
"actuate": "hide",
"autodelete": False,
},
pr_group_competency = "group_id",

# Posts
cms_post = {"link": "cms_post_team",
"joinby": "group_id",
Expand Down Expand Up @@ -3032,6 +3060,140 @@ def group_membership_realm_entity(table, row):
# => Set to default of None
return None

# =============================================================================
class PRGroupCompetencyModel(S3Model):
"""
Group Competency Model
- Skills available in a Group
"""

names = ("pr_group_competency",)

def model(self):

T = current.T

# ---------------------------------------------------------------------
# Groups <> Skills Link Table
#
tablename = "pr_group_competency"
self.define_table(tablename,
self.pr_group_id(),
self.hrm_skill_id(),
#self.hrm_competency_id(),
s3_comments(),
*s3_meta_fields()
)

# CRUD Strings
current.response.s3.crud_strings[tablename] = Storage(
label_create = T("Add Skill"),
title_display = T("Skill"),
title_list = T("Skills"),
title_update = T("Edit Skill"),
title_upload = T("Import Skills"),
label_list_button = T("List Skills"),
msg_record_created = T("Skill added to Group"),
msg_record_modified = T("Skill updated"),
msg_record_deleted = T("Skill removed from Group"),
msg_list_empty = T("No Skills found for this Group"))

self.configure(tablename,
deduplicate = S3Duplicate(primary = ("group_id",
"skill_id",
),
),
)

# Pass names back to global scope (s3.*)
return {}


# =============================================================================
class PRGroupLocationModel(S3Model):
"""
Group Location Model
- Locations served by a Group
"""

names = ("pr_group_location",)

def model(self):

T = current.T

# ---------------------------------------------------------------------
# Groups <> Locations Link Table
#
tablename = "pr_group_location"
self.define_table(tablename,
self.pr_group_id(),
self.gis_location_id(
#represent = self.gis_LocationRepresent(sep=", "),
requires = IS_LOCATION(),
widget = S3LocationAutocompleteWidget()
),
s3_comments(),
*s3_meta_fields()
)

# CRUD Strings
current.response.s3.crud_strings[tablename] = Storage(
label_create = T("Add Location"),
title_display = T("Location"),
title_list = T("Locations"),
title_update = T("Edit Location"),
title_upload = T("Import Location data"),
label_list_button = T("List Locations"),
msg_record_created = T("Location added to Group"),
msg_record_modified = T("Location updated"),
msg_record_deleted = T("Location removed from Group"),
msg_list_empty = T("No Locations found for this Group"))

self.configure(tablename,
deduplicate = S3Duplicate(primary = ("group_id",
"location_id",
),
),
)

# Pass names back to global scope (s3.*)
return {}

# =============================================================================
class PRGroupTagModel(S3Model):
"""
Group Tags
"""

names = ("pr_group_tag",
)

def model(self):

T = current.T

tablename = "pr_group_tag"
self.define_table(tablename,
self.pr_group_id(ondelete = "CASCADE"),
Field("tag",
label = T("Key"),
),
Field("value",
label = T("Value"),
),
#s3_comments(),
*s3_meta_fields())

self.configure(tablename,
deduplicate = S3Duplicate(primary = ("group_id", "tag"),
ignore_case = True,
),
)

# Pass names back to global scope (s3.*)
return {}

# =============================================================================
class PRForumModel(S3Model):
"""
Expand Down
2 changes: 2 additions & 0 deletions modules/templates/CCC/Demo/pr_group.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uuid,Name,Type,Comments
,Helpers,,
2 changes: 2 additions & 0 deletions modules/templates/CCC/Demo/pr_group_membership.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Group Name,Group Type,First Name,Middle Name,Last Name,Email,Mobile Phone
Helpers,,Group,,Leader,,
2 changes: 2 additions & 0 deletions modules/templates/CCC/Demo/tasks.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# s3import::S3BulkImporter
# =============================================================================
org,organisation,organisation.csv,organisation.xsl
pr,group,pr_group.csv,group.xsl
*,import_user,users.csv
cms,post,cms_post.csv,post.xsl
doc,document,doc_document.csv,document.xsl
pr,group_membership,pr_group_membership.csv,group_membership.xsl
# =============================================================================
1 change: 1 addition & 0 deletions modules/templates/CCC/Demo/users.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Eden,Volunteer,[email protected],eden,VOLUNTEER,Eden Community Organisation,s
Eden,OrgAdmin,[email protected],eden,ORG_ADMIN,Eden Community Organisation,staff
Reserve,Volunteer,[email protected],eden,"RESERVE/pr_forum.name=Reserves",,
Corporate,Donor,[email protected],eden,"DONOR/pr_forum.name=Donors",,
Group,Leader,[email protected],eden,"GROUP_ADMIN/pr_group.name=Helpers",,
4 changes: 4 additions & 0 deletions modules/templates/CCC/auth_roles.csv
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ ORG_ADMIN,"Organisation Administrator",,,,org_facility,ALL,,,
ORG_ADMIN,"Organisation Administrator",,,,org_organisation,READ|UPDATE,,,
ORG_ADMIN,"Organisation Administrator",,,,org_organisation_organisation_type,ALL,,,
ORG_ADMIN,"Organisation Administrator",,pr,contact,,CREATE|READ|UPDATE|DELETE,,,
ORG_ADMIN,"Organisation Administrator",,pr,group,,CREATE|READ|UPDATE|DELETE,,any,
ORG_ADMIN,"Organisation Administrator",,pr,person,,CREATE|READ|UPDATE|DELETE,,,
ORG_ADMIN,"Organisation Administrator",,,,pr_address,CREATE|READ|UPDATE|DELETE,,,
ORG_ADMIN,"Organisation Administrator",,,,pr_contact,CREATE|READ|UPDATE|DELETE,,,
ORG_ADMIN,"Organisation Administrator",,,,pr_contact_emergency,CREATE|READ|UPDATE|DELETE,,,
ORG_ADMIN,"Organisation Administrator",,,,pr_group,CREATE|READ|UPDATE,,,
ORG_ADMIN,"Organisation Administrator",,,,pr_person,CREATE|READ|UPDATE|DELETE,,,
ORG_ADMIN,"Organisation Administrator",,project,task,,ALL,,,
ORG_ADMIN,"Organisation Administrator",,project,comments,,ALL,,,
ORG_ADMIN,"Organisation Administrator",,req,need,,CREATE|READ|UPDATE|DELETE,,,
DONOR,"Donor",,dummy,dummy,,READ,,,
GROUP_ADMIN,"Volunteer Group Leader",,pr,group,,CREATE|READ|UPDATE,,,
GROUP_ADMIN,"Volunteer Group Leader",,,,pr_group,CREATE|READ|UPDATE,,,
RESERVE,"Reserve Volunteer",,cms,post,,READ,,,
VOLUNTEER,"Community Volunteer",,cms,post,,READ,,,
VOLUNTEER,"Community Volunteer",,doc,document,,READ,,,
Expand Down
Loading

0 comments on commit 26e128e

Please sign in to comment.