Ejemplo n.º 1
0
 def __init__(self, request):
     user_svc = request.find_service(name='user')
     list_org_svc = request.find_service(name='list_organizations')
     self.organizations = {o.pubid: o for o in list_org_svc.organizations()}
     self.schema = CreateAdminGroupSchema().bind(
         request=request,
         organizations=self.organizations,
         user_svc=user_svc)
     self.request = request
     self.form = _create_form(self.request, self.schema,
                              (_('Create New Group'), ))
Ejemplo n.º 2
0
    def test_it_does_not_raise_if_group_type_is_same(self, group_data,
                                                     pyramid_csrf_request, org,
                                                     user_svc):
        group = mock.Mock(type='open')
        group_data['group_type'] = 'open'
        schema = CreateAdminGroupSchema().bind(request=pyramid_csrf_request,
                                               group=group,
                                               user_svc=user_svc,
                                               organizations={org.pubid: org})

        schema.deserialize(group_data)
Ejemplo n.º 3
0
    def test_it_raises_if_group_type_changed(self, group_data,
                                             pyramid_csrf_request, org,
                                             user_svc):
        group = mock.Mock(type='open')
        group_data['group_type'] = 'restricted'
        schema = CreateAdminGroupSchema().bind(request=pyramid_csrf_request,
                                               group=group,
                                               user_svc=user_svc,
                                               organizations={org.pubid: org})

        with pytest.raises(colander.Invalid, match='Changing group type'):
            schema.deserialize(group_data)
Ejemplo n.º 4
0
    def __init__(self, request):
        self.request = request

        self.user_svc = self.request.find_service(name="user")
        self.list_org_svc = self.request.find_service(name="list_organizations")
        self.group_create_svc = self.request.find_service(name="group_create")
        self.group_members_svc = self.request.find_service(name="group_members")

        self.organizations = {o.pubid: o for o in self.list_org_svc.organizations()}
        self.default_org_id = Organization.default(self.request.db).pubid

        self.schema = CreateAdminGroupSchema().bind(
            request=request, organizations=self.organizations, user_svc=self.user_svc
        )
        self.form = _create_form(self.request, self.schema, (_("Create New Group"),))
Ejemplo n.º 5
0
    def __init__(self, context, request):
        self.group = context
        self.request = request

        self.list_org_svc = request.find_service(name="list_organizations")
        self.user_svc = request.find_service(name="user")
        self.group_update_svc = self.request.find_service(name="group_update")
        self.group_members_svc = self.request.find_service(name="group_members")

        self.organizations = {
            o.pubid: o for o in self.list_org_svc.organizations(self.group.authority)
        }

        self.schema = CreateAdminGroupSchema().bind(
            request=self.request,
            group=self.group,
            organizations=self.organizations,
            user_svc=self.user_svc,
        )
        self.form = _create_form(self.request, self.schema, (_("Save"),))
Ejemplo n.º 6
0
    def __init__(self, request):
        # Look up the group here rather than using traversal in the route
        # definition as that would apply `Group.__acl__` which will not match if
        # the current (admin) user is not the creator of the group.
        try:
            pubid = request.matchdict.get('pubid')
            self.group = GroupRoot(request)[pubid]
        except KeyError:
            raise HTTPNotFound()

        list_org_svc = request.find_service(name='list_organizations')
        self.organizations = {
            o.pubid: o
            for o in list_org_svc.organizations(self.group.authority)
        }

        user_svc = request.find_service(name='user')
        self.request = request
        self.schema = CreateAdminGroupSchema().bind(
            request=request,
            group=self.group,
            organizations=self.organizations,
            user_svc=user_svc)
        self.form = _create_form(self.request, self.schema, (_('Save'), ))
Ejemplo n.º 7
0
def bound_schema(pyramid_csrf_request, org, user_svc):
    schema = CreateAdminGroupSchema().bind(
        request=pyramid_csrf_request, user_svc=user_svc, organizations={org.pubid: org}
    )
    return schema