Ejemplo n.º 1
0
 def __init__(self, group, request):
     super(GroupSearchController, self).__init__(request)
     self.group = group
     if group.organization:
         self._organization_context = OrganizationContext(
             group.organization, request)
     else:
         self._organization_context = None
Ejemplo n.º 2
0
    def test_default_organization(self, db_session, routes, pyramid_request):
        organization = Organization.default(db_session)
        organization_context = OrganizationContext(organization, pyramid_request)

        presenter = OrganizationJSONPresenter(organization_context)
        presented = presenter.asdict()

        assert presented['default'] is True
Ejemplo n.º 3
0
    def test_organization_asdict_with_logo(self, factories, routes, pyramid_request):
        organization = factories.Organization(name='My Org', logo='<svg>H</svg>')
        organization_context = OrganizationContext(organization, pyramid_request)

        presenter = OrganizationJSONPresenter(organization_context)

        assert presenter.asdict() == {
            'name': 'My Org',
            'id': organization_context.id,
            'default': False,
            'logo': pyramid_request.route_url('organization_logo', pubid=organization.pubid)
        }
Ejemplo n.º 4
0
    def test_organization_asdict_no_logo(self, factories, pyramid_request):
        organization = factories.Organization(name='My Org', logo=None)
        organization_context = OrganizationContext(organization, pyramid_request)

        presenter = OrganizationJSONPresenter(organization_context)

        assert presenter.asdict() == {
            'name': 'My Org',
            'id': organization.pubid,
            'default': False,
            'logo': None,
        }
Ejemplo n.º 5
0
    def test_organization_asdict_no_logo(self, factories, pyramid_request):
        organization = factories.Organization(name="My Org", logo=None)
        organization_context = OrganizationContext(organization,
                                                   pyramid_request)

        presenter = OrganizationJSONPresenter(organization_context)

        assert presenter.asdict() == {
            "name": "My Org",
            "id": organization.pubid,
            "default": False,
            "logo": None,
        }
Ejemplo n.º 6
0
    def test_organization_asdict_with_logo(self, factories, routes,
                                           pyramid_request):
        organization = factories.Organization(name="My Org",
                                              logo="<svg>H</svg>")
        organization_context = OrganizationContext(organization,
                                                   pyramid_request)

        presenter = OrganizationJSONPresenter(organization_context)

        assert presenter.asdict() == {
            "name":
            "My Org",
            "id":
            organization_context.id,
            "default":
            False,
            "logo":
            pyramid_request.route_url("organization_logo",
                                      pubid=organization.pubid),
        }
Ejemplo n.º 7
0
 def get_controller():
     organization_context = OrganizationContext(
         request=pyramid_request, organization=organization)
     return OrganizationEditController(organization_context,
                                       pyramid_request)
Ejemplo n.º 8
0
 def organization_context(self, factories, pyramid_request):
     return OrganizationContext(factories.Organization(), pyramid_request)
Ejemplo n.º 9
0
 def get_controller():
     return OrganizationEditController(
         OrganizationContext(organization), pyramid_request
     )
Ejemplo n.º 10
0
 def organization_context(self, factories):
     return OrganizationContext(factories.Organization())