~fabricematrat/charmworld/redirect-charm

« back to all changes in this revision

Viewing changes to charmworld/views/charms.py

  • Committer: Fabrice Matrat
  • Date: 2015-02-09 11:37:32 UTC
  • Revision ID: fabricematrat@gmail.com-20150209113732-pocsisg9z3lsw2ua
Redirect for series added

Show diffs side-by-side

added added

removed removed

Lines of Context:
250
250
    query, sub_only = sub_filter({}, request)
251
251
    return found_charm_collection(
252
252
        request.db, query, sub_only, only_promulgated=True)
 
253
    redirect_url = request.registry.settings.get('redirect_jujucharms')
 
254
    location = ('{url}/solutions'.format(url=redirect_url))
 
255
    raise HTTPMovedPermanently(location=location)
253
256
 
254
257
 
255
258
@cached_view_config(
256
259
    route_name="personal-collection",
257
260
    renderer="charmworld:templates/charm-collection.pt")
258
261
def personal_collection(request):
259
 
    query, sub_only = sub_filter({
260
 
        "owner": request.matchdict["owner"]
261
 
    }, request)
262
 
    return found_charm_collection(request.db, query, sub_only)
 
262
    redirect_url = request.registry.settings.get('redirect_jujucharms')
 
263
    location = ('{url}/q/{owner}'.format(url=redirect_url,
 
264
                                         owner=request.matchdict["owner"]))
 
265
    raise HTTPMovedPermanently(location=location)
263
266
 
264
267
 
265
268
@cached_view_config(
266
269
    route_name="series-collection",
267
270
    renderer="charmworld:templates/charm-collection.pt")
268
271
def series_collection(request):
269
 
    query, sub_only = sub_filter(
270
 
        {"series": request.matchdict["series"]}, request)
271
 
    return found_charm_collection(
272
 
        request.db, query, sub_only, only_promulgated=True)
 
272
    redirect_url = request.registry.settings.get('redirect_jujucharms')
 
273
    location = ('{url}/q/{series}'.format(url=redirect_url,
 
274
                                          series=request.matchdict["series"]))
 
275
    raise HTTPMovedPermanently(location=location)
273
276
 
274
277
 
275
278
@cached_view_config(
276
279
    route_name="personal-series",
277
280
    renderer="charmworld:templates/charm-collection.pt")
278
281
def personal_series_collection(request):
279
 
    query, sub_only = sub_filter(
280
 
        {
281
 
            "owner": request.matchdict["owner"],
282
 
            "series": request.matchdict["series"]
283
 
        },
284
 
        request)
285
 
    return found_charm_collection(request.db, query, sub_only)
 
282
    redirect_url = request.registry.settings.get('redirect_jujucharms')
 
283
    location = ('{url}/q/{owner}/{series}'.format(
 
284
        url=redirect_url,
 
285
        owner=request.matchdict["owner"],
 
286
        series=request.matchdict["series"])
 
287
    )
 
288
    raise HTTPMovedPermanently(location=location)
286
289
 
287
290
 
288
291
@cached_view_config(
294
297
def personal_charm(request):
295
298
    _reconcile_revision(request)
296
299
    redirect_url = request.registry.settings.get('redirect_jujucharms')
297
 
 
298
300
    match = request.matchdict
299
301
    if 'revision' in match:
300
302
        location = ('{url}/u/{owner}/{charm}/{series}/{revision}'.