Example #1
0
    def _read(self, id, limit):
        # FIXME: copied and modified from GroupController to collect
        # sub organizations, create c.fields_grouped and hard-code
        # search facets
        ''' This is common code used by both read and bulk_process'''
        
        group_type = self._get_group_type(id.split('@')[0])
        context = {'model': model, 'session': model.Session,
                   'user': c.user or c.author,
                   'schema': self._db_to_form_schema(group_type=group_type),
                   'for_view': True, 'extras_as_string': True}

        # Get the subgorgs of this org
        org_id = c.group_dict.get('id')
        
        q = c.q = request.params.get('q', '')
        
        suborgs = ['"' + org + '"' for org in get_suborgs(org_id)]
        if suborgs != []:
            q += ' owner_org:("' + org_id + '" OR ' + ' OR '.join(suborgs) + ')'
        else :
            q += ' owner_org:"%s"' % org_id
        
        c.description_formatted = h.render_markdown(c.group_dict.get('description'))

        context['return_query'] = True

        try:
            page = int(request.params.get('page', 1))
        except ValueError, e:
            abort(400, ('"page" parameter must be an integer'))
Example #2
0
    def about(self, id):
        c.group_dict = self._get_group_dict(id)
        group_type = c.group_dict['type']

        context = {'model': model, 'session': model.Session,
                   'user': c.user or c.author, 'for_view': True,
                   'with_private': False}

        if c.userobj:
            context['user_id'] = c.userobj.id
            context['user_is_admin'] = c.userobj.sysadmin

        org_id = c.group_dict.get('id')
        q = c.q = request.params.get('q', '')
        suborgs = ['"' + org + '"' for org in get_suborgs(org_id)]
        if suborgs != []:
            q += ' owner_org:("' + org_id + '" OR ' + ' OR '.join(suborgs) + ')'
        else:
            q += ' owner_org:"%s"' % org_id

        data_dict = {
            'q': q
        }

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

        c.group_dict['package_count'] = query['count']

        self._setup_template_variables(context, {'id': id},
                                       group_type=group_type)
        return render(self._about_template(group_type))
Example #3
0
    def about(self, id):
        c.group_dict = self._get_group_dict(id)
        group_type = c.group_dict['type']

        context = {
            'model': model,
            'session': model.Session,
            'user': c.user or c.author,
            'for_view': True,
            'with_private': False
        }

        if c.userobj:
            context['user_id'] = c.userobj.id
            context['user_is_admin'] = c.userobj.sysadmin

        org_id = c.group_dict.get('id')
        q = c.q = request.params.get('q', '')
        suborgs = ['"' + org + '"' for org in get_suborgs(org_id)]
        if suborgs != []:
            q += ' owner_org:("' + org_id + '" OR ' + ' OR '.join(
                suborgs) + ')'
        else:
            q += ' owner_org:"%s"' % org_id

        data_dict = {'q': q}

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

        c.group_dict['package_count'] = query['count']

        self._setup_template_variables(context, {'id': id},
                                       group_type=group_type)
        return render(self._about_template(group_type))
Example #4
0
    def _read(self, id, limit, group_type='organization'):
        # FIXME: copied and modified from GroupController to collect
        # sub organizations, create c.fields_grouped and hard-code
        # search facets
        ''' This is common code used by both read and bulk_process'''

        #group_type = self._get_group_type(id.split('@')[0])
        context = {
            'model': model,
            'session': model.Session,
            'user': c.user or c.author,
            'schema': self._db_to_form_schema(group_type=group_type),
            'for_view': True,
            'extras_as_string': True
        }

        # Get the subgorgs of this org
        org_id = c.group_dict.get('id')
        hide_desc = False

        q = c.q = request.params.get('q', '')

        # XXX: unfortunate hack, copy sort default behaviour from
        # before_search because we're using the q parameter below
        # even when no text query was submitted
        if not q and request.params.get('sort') in (None, 'rank'):
            sort_by = 'record_publish_date desc, metadata_modified desc'
        else:
            sort_by = request.params.get('sort', None)

        suborgs = ['"' + org + '"' for org in get_suborgs(org_id)]
        if suborgs != []:
            q += ' owner_org:("' + org_id + '" OR ' + ' OR '.join(
                suborgs) + ')'
        else:
            q += ' owner_org:"%s"' % org_id

        c.description_formatted = h.render_markdown(
            c.group_dict.get('description'))

        context['return_query'] = True

        try:
            page = int(request.params.get('page', 1))
        except ValueError, e:
            abort(400, ('"page" parameter must be an integer'))
    def _read(self, id, limit):
        # FIXME: copied and modified from GroupController to collect
        # sub organizations, create c.fields_grouped and hard-code
        # search facets
        ''' This is common code used by both read and bulk_process'''
        
        group_type = self._get_group_type(id.split('@')[0])
        context = {'model': model, 'session': model.Session,
                   'user': c.user or c.author,
                   'schema': self._db_to_form_schema(group_type=group_type),
                   'for_view': True, 'extras_as_string': True}

        # Get the subgorgs of this org
        org_id = c.group_dict.get('id')
        
        q = c.q = request.params.get('q', '')

        # XXX: unfortunate hack, copy sort default behaviour from
        # before_search because we're using the q parameter below
        # even when no text query was submitted
        if not q and request.params.get('sort') in (None, 'rank'):
            sort_by = 'record_publish_date desc, metadata_modified desc'
        else:
            sort_by = request.params.get('sort', None)


        suborgs = ['"' + org + '"' for org in get_suborgs(org_id)]
        if suborgs != []:
            q += ' owner_org:("' + org_id + '" OR ' + ' OR '.join(suborgs) + ')'
        else :
            q += ' owner_org:"%s"' % org_id
        
        c.description_formatted = h.render_markdown(c.group_dict.get('description'))

        context['return_query'] = True

        try:
            page = int(request.params.get('page', 1))
        except ValueError, e:
            abort(400, ('"page" parameter must be an integer'))