mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
magic-removal: Fixed admin 'add' view so that after adding an object, the user is not redirected to a
confusing 'permission denied' page if they don't have 'change' rights. git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2562 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7335a12b48
commit
339a320226
@ -223,7 +223,7 @@ def index(request):
|
|||||||
return render_to_response('admin/index', {'title': _('Site administration')}, context_instance=template.RequestContext(request))
|
return render_to_response('admin/index', {'title': _('Site administration')}, context_instance=template.RequestContext(request))
|
||||||
index = staff_member_required(index)
|
index = staff_member_required(index)
|
||||||
|
|
||||||
def add_stage(request, app_label, model_name, show_delete=False, form_url='', post_url='../', post_url_continue='../%s/', object_id_override=None):
|
def add_stage(request, app_label, model_name, show_delete=False, form_url='', post_url=None, post_url_continue='../%s/', object_id_override=None):
|
||||||
model = models.get_model(app_label, model_name)
|
model = models.get_model(app_label, model_name)
|
||||||
if model is None:
|
if model is None:
|
||||||
raise Http404, "App %r, model %r, not found" % (app_label, model_name)
|
raise Http404, "App %r, model %r, not found" % (app_label, model_name)
|
||||||
@ -232,6 +232,14 @@ def add_stage(request, app_label, model_name, show_delete=False, form_url='', po
|
|||||||
if not request.user.has_perm(app_label + '.' + opts.get_add_permission()):
|
if not request.user.has_perm(app_label + '.' + opts.get_add_permission()):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
|
if post_url is None:
|
||||||
|
if request.user.has_perm(app_label + '.' + opts.get_change_permission()):
|
||||||
|
# redirect to list view
|
||||||
|
post_url = '../'
|
||||||
|
else:
|
||||||
|
# Object list will give 'Permission Denied', so go back to admin home
|
||||||
|
post_url = '../../../'
|
||||||
|
|
||||||
manipulator = model.AddManipulator()
|
manipulator = model.AddManipulator()
|
||||||
if request.POST:
|
if request.POST:
|
||||||
new_data = request.POST.copy()
|
new_data = request.POST.copy()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user