changeset 2238:913c1b908070

Destroy view is now fqname friendly.
author Ashutosh Singla <ashu1461@gmail.com>
date Mon, 12 Aug 2013 20:49:37 +0530
parents 93080255a927
children d5ad38a42754
files MoinMoin/apps/frontend/views.py MoinMoin/templates/destroy.html
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Sat Aug 10 17:42:55 2013 +0530
+++ b/MoinMoin/apps/frontend/views.py	Mon Aug 12 20:49:37 2013 +0530
@@ -724,10 +724,11 @@
         item = Item.create(item_name, rev_id=_rev)
     except AccessDenied:
         abort(403)
-    if not flaskg.user.may.destroy(item_name):
+    fqname = item.fqname
+    if not flaskg.user.may.destroy(fqname):
         abort(403)
     if isinstance(item, NonExistent):
-        abort(404, item_name)
+        abort(404, fqname.fullname)
     if request.method in ['GET', 'HEAD']:
         form = DestroyItemForm.from_defaults()
         TextCha(form).amend_form()
@@ -740,9 +741,10 @@
                 item.destroy(comment=comment, destroy_item=destroy_item)
             except AccessDenied:
                 abort(403)
-            return redirect(url_for_item(item_name))
+            return redirect(url_for_item(fqname.fullname))
     return render_template(item.destroy_template,
                            item=item, item_name=item_name,
+                           fqname=fqname,
                            rev_id=rev,
                            form=form,
     )
--- a/MoinMoin/templates/destroy.html	Sat Aug 10 17:42:55 2013 +0530
+++ b/MoinMoin/templates/destroy.html	Mon Aug 12 20:49:37 2013 +0530
@@ -1,13 +1,13 @@
 {% import "forms.html" as forms %}
 {% extends theme("show.html") %}
 
-{% set title = _("DESTROY COMPLETE ITEM '%(item_name)s'", item_name=item.name) %}
+{% set title = _("DESTROY COMPLETE ITEM '%(item_name)s'", item_name=fqname.value) %}
 
 {% block content %}
 {% if rev_id == None %}
     <h1>{{ title }}</h1>
     <div class="moin-form">
-    {{ gen.form.open(form, method="post", action=url_for('frontend.destroy_item', item_name=item.name)) }}
+    {{ gen.form.open(form, method="post", action=url_for('frontend.destroy_item', item_name=fqname.fullname)) }}
       {{ forms.render_errors(form) }}
       <dl>
         {{ forms.render(form['comment']) }}
@@ -19,7 +19,7 @@
 {% else %}
     <h1>{{ _("DESTROY REVISION '%(item_name)s' (rev %(rev_id)s)", item_name=item.name, rev_id=rev_id | shorten_id) }}</h1>
     <div class="moin-form">
-    {{ gen.form.open(form, method="post", action=url_for('frontend.destroy_item', item_name=item.name, rev=rev_id)) }}
+    {{ gen.form.open(form, method="post", action=url_for('frontend.destroy_item', item_name=fqname.fullname, rev=rev_id)) }}
       {{ forms.render_errors(form) }}
       <dl>
         {{ forms.render(form['comment']) }}