Beispiel #1
0
 def __before__(self, action, **env):
     OrganizationController.__before__(self, action, **env)
     check1 = request.params.get("ext_field-filters")
     ps = request.params.get("ext_field-filters-select")
     check2 = request.params.get("ext_field-actions")
     ac = request.params.get("ext_field-actions-select")
     if check1:
         c.process_state = ps
     if check2:
         c.action_multi = ac
 def read(self, id, limit=20):
     # We do not want to perform read operation on organization id "new",
     # where it results in a NotFound error
     if id!="new":
         try:
             org = toolkit.get_action('organization_show')({},{'id':id})
             org_title = org.get('title')
             self._post_analytics(c.user,"Organization", "View", org_title)
         except:
             log.debug('Organization not found: ' + id)
     else:
         return OrganizationController.new(self)
     return OrganizationController.read(self, id, limit=20)
Beispiel #3
0
 def read(self, id, limit=20):
     # We do not want to perform read operation on organization id "new",
     # where it results in a NotFound error
     if id != "new":
         try:
             org = toolkit.get_action('organization_show')({}, {'id': id})
             org_title = org.get('title')
             self._post_analytics(c.user, "Organization", "View", org_title)
         except:
             log.debug('Organization not found: ' + id)
     else:
         return OrganizationController.new(self)
     return OrganizationController.read(self, id, limit=20)
    def embed(self, id, limit=5):
        """
            Fetch given organization's packages and show them in an embeddable list view.
            See Nginx config for X-Frame-Options SAMEORIGIN header modifications.
        """

        def make_pager_url(q=None, page=None):
            ctrlr = 'ckanext.ytp.controller:YtpOrganizationController'
            url = h.url_for(controller=ctrlr, action='embed', id=id)
            return url + u'?page=' + str(page)

        try:
            context = {
                'model': model,
                'session': model.Session,
                'user': c.user or c.author
            }
            check_access('group_show', context, {'id': id})
        except NotFound:
            abort(404, _('Group not found'))
        except NotAuthorized:
            g = model.Session.query(model.Group).filter(model.Group.name == id).first()
            if g is None or g.state != 'active':
                return self._render_template('group/organization_not_found.html')

        page = OrganizationController._get_page_number(self, request.params)

        group_dict = {'id': id}
        group_dict['include_datasets'] = False
        c.group_dict = self._action('group_show')(context, group_dict)
        c.group = context['group']

        q = c.q = request.params.get('q', '')
        q += ' owner_org:"%s"' % c.group_dict.get('id')

        data_dict = {
            'q': q,
            'rows': limit,
            'start': (page - 1) * limit,
            'extras': {}
        }

        query = get_action('package_search')(context, data_dict)

        c.page = h.Page(
            collection=query['results'],
            page=page,
            url=make_pager_url,
            item_count=query['count'],
            items_per_page=limit
        )

        c.page.items = query['results']

        return render("organization/embed.html")
Beispiel #5
0
    def embed(self, id, limit=5):
        """
            Fetch given organization's packages and show them in an embeddable list view.
            See Nginx config for X-Frame-Options SAMEORIGIN header modifications.
        """
        def make_pager_url(q=None, page=None):
            ctrlr = 'ckanext.ytp.organizations.controller:YtpOrganizationController'
            url = h.url_for(controller=ctrlr, action='embed', id=id)
            return url + u'?page=' + str(page)

        try:
            context = {
                'model': model,
                'session': model.Session,
                'user': c.user or c.author
            }
            check_access('group_show', context, {'id': id})
        except NotFound:
            abort(404, _('Group not found'))
        except NotAuthorized:
            g = model.Session.query(
                model.Group).filter(model.Group.name == id).first()
            if g is None or g.state != 'active':
                return self._render_template(
                    'group/organization_not_found.html')

        page = OrganizationController._get_page_number(self, request.params)

        group_dict = {'id': id}
        group_dict['include_datasets'] = False
        c.group_dict = self._action('group_show')(context, group_dict)
        c.group = context['group']

        q = c.q = request.params.get('q', '')
        q += ' owner_org:"%s"' % c.group_dict.get('id')

        data_dict = {
            'q': q,
            'rows': limit,
            'start': (page - 1) * limit,
            'extras': {}
        }

        query = get_action('package_search')(context, data_dict)

        c.page = h.Page(collection=query['results'],
                        page=page,
                        url=make_pager_url,
                        item_count=query['count'],
                        items_per_page=limit)

        c.page.items = query['results']

        return render("organization/embed.html")
Beispiel #6
0
    def read(self, id, limit=20):
        try:
            context = {
                'model': model,
                'session': model.Session,
                'user': c.user or c.author
            }
            check_access('group_show', context, {'id': id})
        except NotFound:
            abort(404, _('Group not found'))
        except NotAuthorized:
            g = model.Session.query(
                model.Group).filter(model.Group.name == id).first()
            if g is None or g.state != 'active':
                return self._render_template(
                    'group/organization_not_found.html')

        return OrganizationController.read(self, id, limit)
    def read(self, id, limit=20):
        group_type = self._ensure_controller_matches_group_type(
            id.split('@')[0])
        try:
            context = {
                'model': model,
                'session': model.Session,
                'user': c.user or c.author
            }
            check_access('group_show', context, {'id': id})
        except NotFound:
            abort(404, _('Group not found'))
        except NotAuthorized:
            g = model.Session.query(model.Group).filter(model.Group.name == id).first()
            if g is None or g.state != 'active':
                return self._render_template('group/organization_not_found.html', group_type=group_type)

        return OrganizationController.read(self, id, limit)
Beispiel #8
0
 def index(self):
     log.error('in the publisher controller')
     log.error(self._guess_group_type())
     return OrganizationController.index(self)
Beispiel #9
0
 def index(self):
     log.error('in the publisher controller')
     log.error(self._guess_group_type())
     return OrganizationController.index(self)