Beispiel #1
0
def bound_schema(pyramid_csrf_request, org, third_party_org, user_svc):
    schema = AdminGroupSchema().bind(
        request=pyramid_csrf_request,
        user_svc=user_svc,
        organizations={org.pubid: org, third_party_org.pubid: third_party_org},
    )
    return schema
Beispiel #2
0
    def test_it_does_not_raise_if_group_type_is_same(self, group_data,
                                                     pyramid_csrf_request, org,
                                                     user_service):
        group = mock.Mock(type="open")
        group_data["group_type"] = "open"
        schema = AdminGroupSchema().bind(
            request=pyramid_csrf_request,
            group=group,
            user_svc=user_service,
            organizations={org.pubid: org},
        )

        schema.deserialize(group_data)
Beispiel #3
0
    def test_it_raises_if_group_type_changed(self, group_data,
                                             pyramid_csrf_request, org,
                                             user_service):
        group = mock.Mock(type="open")
        group_data["group_type"] = "restricted"
        schema = AdminGroupSchema().bind(
            request=pyramid_csrf_request,
            group=group,
            user_svc=user_service,
            organizations={org.pubid: org},
        )

        with pytest.raises(colander.Invalid, match="Changing group type"):
            schema.deserialize(group_data)
Beispiel #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 = AdminGroupSchema().bind(request=request,
                                              organizations=self.organizations,
                                              user_svc=self.user_svc)
        self.form = _create_form(self.request, self.schema,
                                 (_("Create New Group"), ))
Beispiel #5
0
    def __init__(self, context, request):
        self.group = context.group
        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 = AdminGroupSchema().bind(
            request=self.request,
            group=self.group,
            organizations=self.organizations,
            user_svc=self.user_svc,
        )
        self.form = _create_form(self.request, self.schema, (_("Save"), ))