app/django/contrib/databrowse/plugins/objects.py
author Daniel Diniz <ajaksu@gmail.com>
Tue, 23 Jun 2009 20:43:22 +0200
changeset 2419 82ce842da661
parent 54 03e267d67478
permissions -rw-r--r--
Patch that touches 'upstream' templates, for use in surveys. Consists out of three changes. 1 - Move the </head> placement in base.hmtl to after the closing of scripts_block, so templates that extend base.html can add scripts to the <head>. 2 - Add tooltips for checkboxes inside fieldsets. 3 - Comment out an empty table row in templatetags/_as_table.html, which probably has an arcane reason to stay empty :) Reviewed by: Lennard de Rijk, Pawel Solyga Patch by: Daniel Diniz, James Levy

from django import http
from django.contrib.databrowse.datastructures import EasyModel
from django.contrib.databrowse.sites import DatabrowsePlugin
from django.shortcuts import render_to_response
import urlparse

class ObjectDetailPlugin(DatabrowsePlugin):
    def model_view(self, request, model_databrowse, url):
        # If the object ID wasn't provided, redirect to the model page, which is one level up.
        if url is None:
            return http.HttpResponseRedirect(urlparse.urljoin(request.path, '../'))
        easy_model = EasyModel(model_databrowse.site, model_databrowse.model)
        obj = easy_model.object_by_pk(url)
        return render_to_response('databrowse/object_detail.html', {'object': obj, 'root_url': model_databrowse.site.root_url})