Add an admin view
Makes use of the new admin form and the as_readonly_table tag.
Patch by: Sverre Rabbelier
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/models/admin.html Sun Feb 15 14:57:03 2009 +0000
@@ -0,0 +1,36 @@
+{% extends "soc/models/edit.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% load forms_helpers %}
+
+{% block scripts %}{% endblock %}
+
+{% block body %}
+<p>
+<table>
+ {% as_readonly_table form %}
+</table>
+{% if export_link %}
+<table>
+<tr>
+ <td colspan="4"> </td>
+</tr>
+<td>
+ <input type="button" onclick="location.href='/{{ entity_type_url|lower }}/export/{{ entity.key.name }}'" value="Export"/>
+</td>
+</tr>
+</table>
+{% endif %}
+</p>
+{% endblock %}
--- a/app/soc/views/models/base.py Sun Feb 15 14:56:30 2009 +0000
+++ b/app/soc/views/models/base.py Sun Feb 15 14:57:03 2009 +0000
@@ -126,6 +126,45 @@
@decorators.merge_params
@decorators.check_access
+ def admin(self, request, access_type,
+ page_name=None, params=None, **kwargs):
+ """Displays the admin page for the entity specified by **kwargs.
+
+ Params usage:
+ rights: The rights dictionary is used to check if the user has
+ the required rights to view the public page for this entity.
+ See checkAccess for more details on how the rights dictionary
+ is used to check access rights.
+ name: The name value is used to set the entity_type in the
+ context so that the template can refer to it.
+ public_template: The public_template value is used as template
+ to display the public page of the found entity.
+
+ Args:
+ request: the standard Django HTTP request object
+ access_type : the name of the access type which should be checked
+ page_name: the page name displayed in templates as page and header title
+ params: a dict with params for this View
+ kwargs: the Key Fields for the specified entity
+ """
+
+ # create default template context for use with any templates
+ context = helper.responses.getUniversalContext(request)
+ context['page_name'] = page_name
+
+ try:
+ entity = self._logic.getFromKeyFieldsOr404(kwargs)
+ except out_of_band.Error, error:
+ return helper.responses.errorResponse(error, request, context=context)
+
+ form = params['admin_form'](instance=entity)
+ template = params['admin_template']
+
+ return self._constructResponse(request, entity, context, form,
+ params, template=template)
+
+ @decorators.merge_params
+ @decorators.check_access
def export(self, request, access_type,
page_name=None, params=None, **kwargs):
"""Displays the export page for the entity specified by **kwargs.