Changeset 2045
- Timestamp:
- 06/18/09 09:40:36 (9 months ago)
- Location:
- branches/0.9/pylucid_project
- Files:
-
- 1 added
- 4 modified
-
apps/pylucid/decorators.py (added)
-
apps/pylucid/templates/admin/base_site.html (modified) (1 diff)
-
apps/pylucid_update/urls.py (modified) (1 diff)
-
apps/pylucid_update/views.py (modified) (7 diffs)
-
pylucid_plugins/page_admin/views.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/apps/pylucid/templates/admin/base_site.html
r2032 r2045 83 83 <a href="#TODO">{% trans 'admin menu' %}</a> 84 84 </li> 85 {% if user.is_superuser %} 85 86 <li> 86 87 <a href="{% url PyLucidUpdate-menu %}">{% trans 'update section' %}</a> 87 88 </li> 89 {% endif %} 88 90 </ul> 89 91 {% endif %} -
branches/0.9/pylucid_project/apps/pylucid_update/urls.py
r1931 r2045 8 8 9 9 from pylucid_project.apps.pylucid_update import views 10 from pylucid.decorators import superuser_only 10 11 11 12 urlpatterns = patterns('', 12 url(r'^$', views.menu, name='PyLucidUpdate-menu'), 13 url(r'^update08/$', views.update08, name='PyLucidUpdate-update08'), 14 url(r'^update08templates/$', views.update08templates, name='PyLucidUpdate-update08templates'), 15 url(r'^update08styles/$', views.update08styles, name='PyLucidUpdate-update08styles'), 13 url(r'^$', 14 superuser_only(views.menu), 15 name='PyLucidUpdate-menu' 16 ), 17 url(r'^update08/$', 18 superuser_only(views.update08), 19 name='PyLucidUpdate-update08' 20 ), 21 url(r'^update08templates/$', 22 superuser_only(views.update08templates), 23 name='PyLucidUpdate-update08templates' 24 ), 25 url(r'^update08styles/$', 26 superuser_only(views.update08styles), 27 name='PyLucidUpdate-update08styles' 28 ), 16 29 ) -
branches/0.9/pylucid_project/apps/pylucid_update/views.py
r2040 r2045 1 1 # coding: utf-8 2 3 """ 4 PyLucid update views 5 ~~~~~~~~~~~~~~~~~~~~ 6 7 Last commit info: 8 ~~~~~~~~~~~~~~~~~ 9 $LastChangedDate:$ 10 $Rev:$ 11 $Author: JensDiemer $ 12 13 :copyleft: 2009 by the PyLucid team, see AUTHORS for more details. 14 :license: GNU GPL v3 or above, see LICENSE for more details. 15 """ 2 16 3 17 import posixpath … … 8 22 from django.shortcuts import render_to_response 9 23 from django.template.loader import find_template_source 10 from django.contrib.auth.decorators import login_required11 24 12 25 from dbtemplates.models import Template … … 20 33 21 34 22 @login_required23 35 def menu(request): 24 36 """ Display a menu with all update view links """ … … 27 39 } 28 40 return render_to_response('pylucid_update/menu.html', context, context_instance=RequestContext(request)) 29 30 31 32 41 33 42 … … 225 234 226 235 227 @login_required228 236 def update08(request): 229 237 """ Update PyLucid v0.8 model data to v0.9 models """ … … 247 255 248 256 249 @login_required250 257 def update08templates(request): 251 258 title = "Update PyLucid v0.8 templates" … … 346 353 347 354 348 @login_required 355 349 356 def update08styles(request): 350 357 title = "Update PyLucid v0.8 styles" -
branches/0.9/pylucid_project/pylucid_plugins/page_admin/views.py
r2043 r2045 1 # coding: utf-81 # coding: utf-8 2 2 3 import warnings 3 """ 4 PyLucid page admin 5 ~~~~~~~~~~~~~~~~~~ 6 7 Last commit info: 8 ~~~~~~~~~~~~~~~~~ 9 $LastChangedDate:$ 10 $Rev:$ 11 $Author: JensDiemer $ 12 13 :copyleft: 2009 by the PyLucid team, see AUTHORS for more details. 14 :license: GNU GPL v3 or above, see LICENSE for more details. 15 """ 4 16 5 17 from django.conf import settings 6 18 from django.template import RequestContext 7 19 from django.utils.translation import ugettext as _ 8 from django.core.exceptions import PermissionDenied9 20 from django.http import HttpResponse, HttpResponseRedirect 10 21 11 22 from pylucid.markup.converter import apply_markup 12 23 from pylucid.shortcuts import render_pylucid_response 24 from pylucid.decorators import check_permissions 13 25 14 26 from page_admin.forms import EditPageForm 15 27 16 28 17 EDIT_PERMISSIONS = (29 PAGE_EDIT_PERMISSIONS = ( 18 30 u'pylucid.change_pagecontent', 19 31 u'pylucid.change_pagemeta' 20 ) 32 ) 21 33 22 34 23 def check_permissions(request, permissions): 24 """ 25 TODO: Add a log entry, if user has not all permissions. 26 """ 27 assert isinstance(permissions, (list, tuple)) 28 user = request.user 29 30 if not user.is_authenticated(): 31 if settings.DEBUG: # Usefull?? 32 warnings.warn("Anonymous can't edit page.") 33 raise PermissionDenied 34 35 if not user.has_perms(permissions): 36 if settings.DEBUG: # Usefull?? 37 msg = "User %r has not all permissions: %r (existing permissions: %r)" % ( 38 user, permissions, user.get_all_permissions() 39 ) 40 warnings.warn(msg) 41 raise PermissionDenied() 42 43 44 45 def _edit_page(request, form_url): 46 check_permissions(request, EDIT_PERMISSIONS) 47 35 def _edit_page(request, form_url): 48 36 pagemeta_instance = request.PYLUCID.pagemeta 49 37 pagecontent_instance = request.PYLUCID.pagecontent … … 93 81 94 82 83 @check_permissions(permissions=PAGE_EDIT_PERMISSIONS) 95 84 def http_get_view(request): 96 85 action = request.GET["page_admin"]