changeset 2529:9d9f6a7be79e

Merged thomaswaldmann/moin-2.0 into default
author sharky93 <rishabhr123@gmail.com>
date Mon, 08 Jul 2013 15:01:02 +0530
parents 30a9456f3245 (current diff) 21bd8d987eda (diff)
children bfb653c10406
files MoinMoin/static/js/common.js MoinMoin/templates/base.html MoinMoin/templates/modify.html MoinMoin/templates/ticket.html
diffstat 10 files changed, 135 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Sun Jul 07 14:32:55 2013 +0530
+++ b/MoinMoin/items/__init__.py	Mon Jul 08 15:01:02 2013 +0530
@@ -394,11 +394,9 @@
             # just destroy this revision
             self.rev.item.destroy_revision(self.rev.revid)
 
-    def modify(self, meta, data, comment=u'', contenttype_guessed=None, contenttype_qs=None):
-        if contenttype_qs:
-            # we use querystring param to FORCE content type
-            meta[CONTENTTYPE] = contenttype_qs
-
+    def modify(self, meta, data, comment=u'', contenttype_guessed=None, **update_meta):
+        meta = dict(meta)  # we may get a read-only dict-like, copy it
+        meta.update(update_meta)
         return self._save(meta, data, contenttype_guessed=contenttype_guessed, comment=comment)
 
     class _ModifyForm(BaseModifyForm):
@@ -730,7 +728,7 @@
                 meta, data, contenttype_guessed, comment = form._dump(self)
                 contenttype_qs = request.values.get('contenttype')
                 try:
-                    self.modify(meta, data, comment, contenttype_guessed, contenttype_qs)
+                    self.modify(meta, data, comment, contenttype_guessed, **{CONTENTTYPE: contenttype_qs})
                 except AccessDenied:
                     abort(403)
                 else:
--- a/MoinMoin/items/_tests/test_Item.py	Sun Jul 07 14:32:55 2013 +0530
+++ b/MoinMoin/items/_tests/test_Item.py	Mon Jul 08 15:01:02 2013 +0530
@@ -352,6 +352,23 @@
             item.meta['test_key']
         assert item.meta['another_test_key'] == another_meta['another_test_key']
         assert item.content.data == another_data
+        # add/update meta
+        another_meta = {
+            'test_key': 'test_value',
+            'another_test_key': 'another_test_value',
+        }
+        item.modify(another_meta, another_data)
+        item = Item.create(name)
+        update_meta = {
+            'another_test_key': 'updated_test_value',
+            'new_test_key': 'new_test_value',
+        }
+        item.modify(another_meta, another_data, **update_meta)
+        item = Item.create(name)
+        assert item.name == u'Test_Item'
+        assert item.meta['test_key'] == another_meta['test_key']
+        assert item.meta['another_test_key'] == update_meta['another_test_key']
+        assert item.meta['new_test_key'] == update_meta['new_test_key']
 
 
 coverage_modules = ['MoinMoin.items']
--- a/MoinMoin/items/ticket.py	Sun Jul 07 14:32:55 2013 +0530
+++ b/MoinMoin/items/ticket.py	Mon Jul 08 15:01:02 2013 +0530
@@ -138,7 +138,8 @@
     itemtype = ITEMTYPE_TICKET
     display_name = L_('Ticket')
     description = L_('Ticket item')
-    modify_template = 'ticket.html'
+    submit_template = 'ticket/submit.html'
+    modify_template = 'ticket/modify.html'
 
     def do_show(self, revid):
         if revid != CURRENT:
@@ -169,7 +170,7 @@
         # XXX When creating new item, suppress the "foo doesn't exist. Create it?" dummy content
         data_rendered = None if is_new else Markup(self.content._render_data())
 
-        return render_template(self.modify_template,
+        return render_template(self.submit_template if is_new else self.modify_template,
                                is_new=is_new,
                                closed=closed,
                                item_name=self.name,
--- a/MoinMoin/static/js/common.js	Sun Jul 07 14:32:55 2013 +0530
+++ b/MoinMoin/static/js/common.js	Mon Jul 08 15:01:02 2013 +0530
@@ -564,7 +564,7 @@
             // is option to scroll page after edit set?
             if (document.getElementById('moin-scroll-page-after-edit')) {
                 // add click handler to OK (save) button to capture position of caret in textarea
-                $("#f_submit").click(function () {
+                $("#moin-save-text-button").click(function () {
                     caretLineno = getCaretLineno(document.getElementById('f_content_form_data_text'));
                     // save lineno for use in "show" page load
                     if (caretLineno > 0) { sessionStorage.moinCaretLineNo = caretLineno; }
--- a/MoinMoin/templates/base.html	Sun Jul 07 14:32:55 2013 +0530
+++ b/MoinMoin/templates/base.html	Mon Jul 08 15:01:02 2013 +0530
@@ -41,6 +41,11 @@
     {% endblock %}
 
     {% block head_links %}
+
+    {% block bootstrap_stylesheet %}
+    <link rel="stylesheet" href="{{ url_for('serve.files', name='bootstrap', filename='bootstrap/css/bootstrap.css') }}" />
+    {% endblock %}
+
     <link rel="shortcut icon" href="{{ url_for('static', filename='logos/favicon.ico') }}" />
 
     {% block theme_stylesheets %}
--- a/MoinMoin/templates/modify.html	Sun Jul 07 14:32:55 2013 +0530
+++ b/MoinMoin/templates/modify.html	Mon Jul 08 15:01:02 2013 +0530
@@ -39,7 +39,7 @@
        POSTs originate from their respective applets.
     #}
     {% if not form['content_form'].is_draw %}
-        {{ forms.render_submit(form) }}
+        {{ forms.render_submit(form, id='moin-save-text-button') }}
         <dl>
             {{ forms.render_textcha(gen, form) }}
             {{ forms.render(form['comment']) }}
--- a/MoinMoin/templates/ticket.html	Sun Jul 07 14:32:55 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-{% import "forms.html" as forms %}
-{% extends theme("layout.html") %}
-
-{% if is_new %}
-    {% set title = _("Creating new ticket: '%(item_name)s'", item_name=item_name) %}
-{% else %}
-    {% set title = _("Ticket: '%(item_name)s'", item_name=item_name) %}
-{% endif %}
-
-{% block head %}
-    {{ super() }}
-    <link media="all" rel="stylesheet" href="{{ url_for('static', filename='css/ticket.css') }}" />
-{% endblock %}
-
-{% block content %}
-<h1>
-    {{ title }}
-    {% if closed %}
-        {# TODO style .moin-ticket-closed #}
-        <span class="moin-ticket-closed">{{ _("(Closed)") }}</span>
-    {% endif %}
-</h1>
-<div class="moin-form" id="moin-ticket-form">
-    {{ gen.form.open(form, method='post', enctype='multipart/form-data') }}
-
-    {% if data_rendered %}
-        <div id="moin-content-data">
-            {{ data_rendered }}
-        </div>
-    {% endif %}
-
-    {% if is_new %}
-        <h2>Describe the ticket</h2>
-    {% else %}
-        <h2>Add comment</h2>
-    {% endif %}
-    <dl>
-    {{ forms.render(form['message']) }}
-    </dl>
-
-    <h2>Edit metadata</h2>
-    <dl>
-    {{ forms.render_errors(form) }}
-    {% for e in [
-        'summary',
-        'effort',
-        'difficulty',
-        'severity',
-        'priority',
-        'tags',
-        'assigned_to',
-        'superseded_by',
-        'depends_on',
-        ] %}
-        {{ forms.render(form['meta'][e]) }}
-    {% endfor %}
-    </dl>
-
-    {# see comments concerning the submit button within TicketForm in items/ticket.py #}
-    {% if is_new %}
-        {{ forms.render_submit(form) }}
-    {% else %}
-        {{ forms.render(form['submit']) }}
-    {% endif %}
-
-    <h2>Back references</h2>
-    <dl>
-    {% for e in [
-        'supersedes',
-        'required_by',
-        'subscribers',
-        ] %}
-        {{ forms.render(form['backrefs'][e]) }}
-    {% endfor %}
-
-    {{ gen.form.close() }}
-</div>
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/ticket/base.html	Mon Jul 08 15:01:02 2013 +0530
@@ -0,0 +1,58 @@
+{% import "forms.html" as forms %}
+{% extends theme("layout.html") %}
+
+{% macro render_meta() %}
+    {% for e in [
+        'summary',
+        'effort',
+        'difficulty',
+        'severity',
+        'priority',
+        'tags',
+        'assigned_to',
+        'superseded_by',
+        'depends_on',
+        ] %}
+        {{ forms.render(form['meta'][e]) }}
+    {% endfor %}
+{% endmacro %}
+
+{% macro render_backref() %}
+    {% for e in [
+        'supersedes',
+        'required_by',
+        'subscribers',
+        ] %}
+        {{ forms.render(form['backrefs'][e]) }}
+    {% endfor %}
+{% endmacro %}
+
+{% block head %}
+    {{ super() }}
+    <link media="all" rel="stylesheet" href="{{ url_for('static', filename='css/ticket.css') }}" />
+{% endblock %}
+
+{% block content %}
+<h1>
+    {% block title_text %}
+    {% endblock %}
+    {% if closed %}
+        {# TODO style .moin-ticket-closed #}
+        <span class="moin-ticket-closed">{{ _("(Closed)") }}</span>
+    {% endif %}
+</h1>
+<div class="moin-form" id="moin-ticket-form">
+    {{ gen.form.open(form, method='post', enctype='multipart/form-data') }}
+
+    {% if data_rendered %}
+        <div id="moin-content-data">
+            {{ data_rendered }}
+        </div>
+    {% endif %}
+
+    {% block form_controls %}
+    {% endblock %}
+
+    {{ gen.form.close() }}
+</div>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/ticket/modify.html	Mon Jul 08 15:01:02 2013 +0530
@@ -0,0 +1,25 @@
+{% extends "ticket/base.html" %}
+
+{% block title_text %}
+    {{ _("Ticket: '%(item_name)s'", item_name=item_name) }}
+{% endblock %}
+
+{% block form_controls %}
+    <h2>{{ _("Add comment") }}</h2>
+    <dl>
+    {{ forms.render(form['message']) }}
+    </dl>
+
+    <h2>{{ _("Edit metadata") }}</h2>
+    <dl>
+    {{ forms.render_errors(form) }}
+    {{ render_meta() }}
+    </dl>
+
+    {{ forms.render(form['submit']) }}
+
+    <h2>{{ _("Back references") }}</h2>
+    <dl>
+    {{ render_backref() }}
+    </dl>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/ticket/submit.html	Mon Jul 08 15:01:02 2013 +0530
@@ -0,0 +1,21 @@
+{% extends "ticket/base.html" %}
+
+{% block title_text %}
+    {{ _("Creating new ticket: '%(item_name)s'", item_name=item_name) }}
+{% endblock %}
+
+{% block form_controls %}
+    <h2>{{ _("Describe the ticket") }}</h2>
+
+    <dl>
+    {{ forms.render(form['message']) }}
+    </dl>
+
+    <h2>{{ _("Provide metadata") }}</h2>
+    <dl>
+    {{ forms.render_errors(form) }}
+    {{ render_meta() }}
+    </dl>
+
+    {{ forms.render_submit(form) }}
+{% endblock %}