Ticket #2104: 2104.diff

File 2104.diff, 6.7 KB (added by garthk@…, 18 years ago)

[patch] permit wrapping of change_list et al

Line 
1diff -rc --exclude=.svn --exclude='*.pyc' --exclude='*~' --exclude='*.orig' ../django-svn/django/contrib/admin/views/main.py django/contrib/admin/views/main.py
2*** ../django-svn/django/contrib/admin/views/main.py Fri Jun 9 12:02:59 2006
3--- django/contrib/admin/views/main.py Fri Jun 9 12:25:05 2006
4***************
5*** 226,232 ****
6 return render_to_response('admin/index.html', {'title': _('Site administration')}, context_instance=template.RequestContext(request))
7 index = staff_member_required(never_cache(index))
8
9! def add_stage(request, app_label, model_name, show_delete=False, form_url='', post_url=None, post_url_continue='../%s/', object_id_override=None):
10 model = models.get_model(app_label, model_name)
11 if model is None:
12 raise Http404, "App %r, model %r, not found" % (app_label, model_name)
13--- 226,232 ----
14 return render_to_response('admin/index.html', {'title': _('Site administration')}, context_instance=template.RequestContext(request))
15 index = staff_member_required(never_cache(index))
16
17! def _add_stage(request, app_label, model_name, show_delete=False, form_url='', post_url=None, post_url_continue='../%s/', object_id_override=None):
18 model = models.get_model(app_label, model_name)
19 if model is None:
20 raise Http404, "App %r, model %r, not found" % (app_label, model_name)
21***************
22*** 297,305 ****
23 c['object_id'] = object_id_override
24
25 return render_change_form(model, manipulator, c, add=True)
26! add_stage = staff_member_required(never_cache(add_stage))
27
28! def change_stage(request, app_label, model_name, object_id):
29 model = models.get_model(app_label, model_name)
30 object_id = unquote(object_id)
31 if model is None:
32--- 297,305 ----
33 c['object_id'] = object_id_override
34
35 return render_change_form(model, manipulator, c, add=True)
36! add_stage = staff_member_required(never_cache(_add_stage))
37
38! def _change_stage(request, app_label, model_name, object_id):
39 model = models.get_model(app_label, model_name)
40 object_id = unquote(object_id)
41 if model is None:
42***************
43*** 396,402 ****
44 'is_popup': request.REQUEST.has_key('_popup'),
45 })
46 return render_change_form(model, manipulator, c, change=True)
47! change_stage = staff_member_required(never_cache(change_stage))
48
49 def _nest_help(obj, depth, val):
50 current = obj
51--- 396,402 ----
52 'is_popup': request.REQUEST.has_key('_popup'),
53 })
54 return render_change_form(model, manipulator, c, change=True)
55! change_stage = staff_member_required(never_cache(_change_stage))
56
57 def _nest_help(obj, depth, val):
58 current = obj
59***************
60*** 482,488 ****
61 if not user.has_perm(p):
62 perms_needed.add(related.opts.verbose_name)
63
64! def delete_stage(request, app_label, model_name, object_id):
65 import sets
66 model = models.get_model(app_label, model_name)
67 object_id = unquote(object_id)
68--- 482,488 ----
69 if not user.has_perm(p):
70 perms_needed.add(related.opts.verbose_name)
71
72! def _delete_stage(request, app_label, model_name, object_id):
73 import sets
74 model = models.get_model(app_label, model_name)
75 object_id = unquote(object_id)
76***************
77*** 518,524 ****
78 return render_to_response(["admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower() ),
79 "admin/%s/delete_confirmation.html" % app_label ,
80 "admin/delete_confirmation.html"], extra_context, context_instance=template.RequestContext(request))
81! delete_stage = staff_member_required(never_cache(delete_stage))
82
83 def history(request, app_label, model_name, object_id):
84 model = models.get_model(app_label, model_name)
85--- 518,524 ----
86 return render_to_response(["admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower() ),
87 "admin/%s/delete_confirmation.html" % app_label ,
88 "admin/delete_confirmation.html"], extra_context, context_instance=template.RequestContext(request))
89! delete_stage = staff_member_required(never_cache(_delete_stage))
90
91 def history(request, app_label, model_name, object_id):
92 model = models.get_model(app_label, model_name)
93***************
94*** 725,736 ****
95 def url_for_result(self, result):
96 return "%s/" % quote(getattr(result, self.pk_attname))
97
98! def change_list(request, app_label, model_name):
99 model = models.get_model(app_label, model_name)
100 if model is None:
101 raise Http404, "App %r, model %r, not found" % (app_label, model_name)
102! if not request.user.has_perm(app_label + '.' + model._meta.get_change_permission()):
103! raise PermissionDenied
104 try:
105 cl = ChangeList(request, model)
106 except IncorrectLookupParameters:
107--- 725,737 ----
108 def url_for_result(self, result):
109 return "%s/" % quote(getattr(result, self.pk_attname))
110
111! def _change_list(request, app_label, model_name, require_change_permission=True):
112 model = models.get_model(app_label, model_name)
113 if model is None:
114 raise Http404, "App %r, model %r, not found" % (app_label, model_name)
115! if require_change_permission:
116! if not request.user.has_perm(app_label + '.' + model._meta.get_change_permission()):
117! raise PermissionDenied
118 try:
119 cl = ChangeList(request, model)
120 except IncorrectLookupParameters:
121***************
122*** 741,746 ****
123--- 742,749 ----
124 # is screwed up with the database, so display an error page.
125 if ERROR_FLAG in request.GET.keys():
126 return render_to_response('admin/invalid_setup.html', {'title': _('Database error')})
127+ if hasattr(request.user, 'message_set'):
128+ request.user.message_set.create("Invalid lookup parameters were embedded in your last request.")
129 return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')
130 c = template.RequestContext(request, {
131 'title': cl.title,
132***************
133*** 751,754 ****
134 return render_to_response(['admin/%s/%s/change_list.html' % (app_label, cl.opts.object_name.lower()),
135 'admin/%s/change_list.html' % app_label,
136 'admin/change_list.html'], context_instance=c)
137! change_list = staff_member_required(never_cache(change_list))
138--- 754,757 ----
139 return render_to_response(['admin/%s/%s/change_list.html' % (app_label, cl.opts.object_name.lower()),
140 'admin/%s/change_list.html' % app_label,
141 'admin/change_list.html'], context_instance=c)
142! change_list = staff_member_required(never_cache(_change_list))
Back to Top