Switch to unified view

a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
...
...
136
def projects(category=None, display_mode='grid', sort='last_updated',
136
def projects(category=None, display_mode='grid', sort='last_updated',
137
        show_total=False, limit=100, labels='', award='', private=False):
137
        show_total=False, limit=100, labels='', award='', private=False):
138
    from allura.lib.widgets.project_list import ProjectList
138
    from allura.lib.widgets.project_list import ProjectList
139
    from allura.lib import utils
139
    from allura.lib import utils
140
    from allura import model as M
140
    from allura import model as M
141
    # 'trove' is internal substitution for 'category' filter in wiki macro
142
    trove = category
141
    limit = int(limit)
143
    limit = int(limit)
142
    q = dict(
144
    q = dict(
143
        neighborhood_id=c.project.neighborhood_id,
145
        neighborhood_id=c.project.neighborhood_id,
144
        deleted=False,
146
        deleted=False,
145
        shortname={'$ne':'--init--'})
147
        shortname={'$ne':'--init--'})
146
    if labels:
148
    if labels:
147
        or_labels = labels.split('|')
149
        or_labels = labels.split('|')
148
        q['$or'] = [{'labels': {'$all': l.split(',')}} for l in or_labels]
150
        q['$or'] = [{'labels': {'$all': l.split(',')}} for l in or_labels]
149
    if category is not None:
151
    if trove is not None:
150
        category = M.ProjectCategory.query.get(name=category)
152
        trove = M.TroveCategory.query.get(fullpath=trove)
151
    if award:
153
    if award:
152
        aw = M.Award.query.find(dict(
154
        aw = M.Award.query.find(dict(
153
            created_by_neighborhood_id=c.project.neighborhood_id,
155
            created_by_neighborhood_id=c.project.neighborhood_id,
154
            short=award)).first()
156
            short=award)).first()
155
        if aw:
157
        if aw:
156
            q['_id'] = {'$in': [grant.granted_to_project_id for grant in
158
            q['_id'] = {'$in': [grant.granted_to_project_id for grant in
157
                M.AwardGrant.query.find(dict(
159
                M.AwardGrant.query.find(dict(
158
                    granted_by_neighborhood_id=c.project.neighborhood_id,
160
                    granted_by_neighborhood_id=c.project.neighborhood_id,
159
                    award_id=aw._id))]}
161
                    award_id=aw._id))]}
160
    if category is not None:
162
    if trove is not None:
161
        q['category_id'] = category._id
163
        q['trove_' + trove.type] = trove._id
162
    sort_key, sort_dir = 'last_updated', pymongo.DESCENDING
164
    sort_key, sort_dir = 'last_updated', pymongo.DESCENDING
163
    if sort == 'alpha':
165
    if sort == 'alpha':
164
        sort_key, sort_dir = 'name', pymongo.ASCENDING
166
        sort_key, sort_dir = 'name', pymongo.ASCENDING
165
    elif sort == 'random':
167
    elif sort == 'random':
166
        sort_key, sort_dir = None, None
168
        sort_key, sort_dir = None, None