changeset 160:8b811bdef521

merged bb://sinha/moin-2.0
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 21 Mar 2011 21:31:21 +0100
parents 4d706850ec7c (current diff) a84d782f38e9 (diff)
children 65e5f723b17d
files
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Mon Mar 21 19:46:42 2011 +0100
+++ b/MoinMoin/apps/frontend/views.py	Mon Mar 21 21:31:21 2011 +0100
@@ -349,14 +349,26 @@
         item = Item.create(item_name)
     except AccessDeniedError:
         abort(403)
+    form = TextChaizedForm.from_flat(request.form)
+    TextCha(form).amend_form()
     if request.method == 'GET':
         return render_template(item.copy_template,
                                item=item, item_name=item_name,
+                               form=form, target=item.name,
+                               gen=make_generator(),
                               )
     if request.method == 'POST':
         if 'button_ok' in request.form:
             target = request.form.get('target')
             comment = request.form.get('comment')
+            valid = form.validate()
+            if not valid:
+                return render_template(item.copy_template,
+                                       item=item, item_name=item_name,
+                                       form=form, target=target,
+                                       gen=make_generator(),
+                                       comment=comment,
+                                      )
             item.copy(target, comment)
             redirect_to = target
         else:
--- a/MoinMoin/templates/copy.html	Mon Mar 21 19:46:42 2011 +0100
+++ b/MoinMoin/templates/copy.html	Mon Mar 21 21:31:21 2011 +0100
@@ -1,3 +1,4 @@
+{% import "forms.html" as forms %}
 {% extends theme("layout.html") %}
 {% block content %}
 <h1>{{ _("Copy '%(item_name)s'", item_name=item.name) }}</h1>
@@ -5,14 +6,16 @@
 <form action="{{ url_for('frontend.copy_item', item_name=item.name) }}" method="POST" enctype="multipart/form-data">
     <dl>
         <dt><label for="target">{{ _("Target") }}</label></dt>
-        <dd><input type="text" id="target" name="target" size="80" maxlength="200" value="{{ item.name }}" /></dd>
+        <dd><input type="text" id="target" name="target" size="80" maxlength="200" value="{{ target }}" /></dd>
         
         <dt><label for="comment">{{ _("Comment") }}</label></dt>
-        <dd><input type="text" id="comment" name="comment" size="80" maxlength="200" value="" /></dd>
+        <dd><input type="text" id="comment" name="comment" size="80" maxlength="200" value="{{ comment }}" /></dd>
     </dl>
 
     <input class="button" type="submit" name="button_ok" value="{{ _('Copy') }}" />
     <input class="button" type="submit" name="button_cancel" value="{{ _('Cancel') }}" />
+    <br/>
+    {{ forms.render_textcha(gen, form) }}
 </form>
 </div>
 {% endblock %}