def group_id(self):
     if IDoc.providedBy(self.context):
         if hasattr(self.context, "group_id") and self.context.group is not None:
             return IDCDescriptiveProperties(self.context.group).short_title
         elif hasattr(self.context, "chamber_id"):
             return IDCDescriptiveProperties(self.context.chamber).short_tile
     return translate("n/a", context=get_request())
Ejemplo n.º 2
0
 def group_id(self):
     if IDoc.providedBy(self.context):
         if hasattr(self.context, "group_id") and self.context.group is not None:
             return IDCDescriptiveProperties(self.context.group).short_title
         elif hasattr(self.context, "chamber_id"):
             return IDCDescriptiveProperties(self.context.chamber).short_tile
     return translate("n/a", context=get_request())
Ejemplo n.º 3
0
def propagate_parent_assigned_group_role(child_doc):
    """Propagate the role of the group that is assigned to the parent doc of 
    this child doc.
    """
    from bungeni.models.interfaces import IDoc
    assert IDoc.providedBy(child_doc), "Not a Doc: %s" % (child_doc)

    def get_parent_doc_assigned_group(child_doc):
        parent_group_assignments = child_doc.head.sa_group_assignments
        for group_assignment in parent_group_assignments:
            # !+QUALIFIED_FEATURES(mr, apr-2013) may need to "qualify" each assignment!
            # !+MULTI_ASSIGNMENTS_MULTI_MEMBERSHIPS(mr, apr-2013) for now we just
            # take the first assigned group we find, but this is obvioulsy
            # incorrect! Need to determine: in case doc has been assigned to
            # more than one group, within which is the current user acting
            # (keeping in mind, also that the current user may be member of more
            # than one group that the doc is assigned to!).
            #!+GROUP_ASSIGNMENT.GROUP assert isinstance(group, domain.Group), group
            return group_assignment.principal

    pag = parent_assigned_group = get_parent_doc_assigned_group(child_doc)
    assert pag is not None, child_doc
    # !+ is this constraint correct?
    assert child_doc.group is pag, \
        "!+GROUP child doc [%s] group [%s] must be the assigned group [%s] for parent doc [%s]" % (
            child_doc, child_doc.group, pag, child_doc.head)
    utils.set_role(pag.group_role, pag.principal_name, child_doc)
Ejemplo n.º 4
0
def assign_role_group(doc):
    """Assign the role of the doc's group, to the group itself, onto doc.
    """
    # !+PrincipalRoleMapContextData infer role from context data
    from bungeni.models.interfaces import IDoc
    assert IDoc.providedBy(doc), "Not a Doc: %s" % (doc)
    if doc.group is not None:
        utils.assign_role(doc.group.group_role, doc.group.principal_name, doc)
Ejemplo n.º 5
0
def propagate_parent_assigned_group_role(child_doc):
    """Propagate the role of the group that is assigned to the parent doc of 
    this child doc.
    """
    from bungeni.models.interfaces import IDoc
    assert IDoc.providedBy(child_doc), "Not a Doc: %s" % (child_doc)
    assert child_doc.group is None, "!+GROUP_ID must be unset! %s" % (child_doc)
    def get_parent_doc_assigned_group(child_doc):
        parent_group_assignments = child_doc.head.group_assignment
        for ag in parent_group_assignments:
            # !+QUALIFIED_FEATURES(mr, apr-2013) may need to "qualify" each assignment!
            # !+MULTI_ASSIGNMENTS_MULTI_MEMBERSHIPS(mr, apr-2013) for now we just
            # take the first assigned group we find, but this is obvioulsy 
            # incorrect! Need to determine: in case doc has been assigned to 
            # more than one group, within which is the current user acting
            # (keeping in mind, also that the current user may be member of more
            # than one group that the doc is assigned to!).
            return ag.group
    pag = parent_assigned_group = get_parent_doc_assigned_group(child_doc)
    assert pag is not None, child_doc
    utils.assign_role(pag.group_role, pag.principal_name, child_doc)