changeset 2937:456c68761e96

merge
author RogerHaase <haaserd@gmail.com>
date Tue, 28 Apr 2015 12:17:55 -0700
parents 4ab27780d078 (current diff) cd48671a0488 (diff)
children dde4eb0904f7
files MoinMoin/apps/frontend/views.py MoinMoin/templates/utils.html MoinMoin/themes/__init__.py
diffstat 9 files changed, 94 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/apps/frontend/views.py	Tue Apr 28 12:17:55 2015 -0700
@@ -1580,6 +1580,10 @@
         return Response(flaskg._login_multistage, mimetype='text/html')
 
     if request.method in ['GET', 'HEAD']:
+        # we already have a logged-in user
+        if flaskg.user.valid:
+            flash(_("You are already logged in."), "info")
+            return redirect(url_for('.show_root'))
         form = LoginForm.from_defaults()
         for authmethod in app.cfg.auth:
             hint = authmethod.login_hint()
@@ -1589,7 +1593,8 @@
         form = LoginForm.from_flat(request.form)
         if form.validate():
             # we have a logged-in, valid user
-            return redirect(url_for('.show_root'))
+            next_url = request.args.get('next', default=url_for('.show_root'))
+            return redirect(next_url)
         # flash the error messages (if any)
         for msg in flaskg._login_messages:
             flash(msg, "error")
@@ -1604,7 +1609,8 @@
 def logout():
     flash(_("You are now logged out."), "info")
     flaskg.user.logout_session()
-    return redirect(url_for('.show_root'))
+    next_url = request.args.get('next', default=url_for('.show_root'))
+    return redirect(next_url)
 
 
 class ValidChangePass(Validator):
@@ -2330,18 +2336,19 @@
     current_timestamp = datetime.now().strftime("%Y_%m_%d-%H_%M_%S")
     idx_name = ALL_REVS
     qp = flaskg.storage.query_parser([TAGS, SUMMARY, CONTENT, ITEMID], idx_name=idx_name)
-    terms = [Term(ITEMTYPE, ITEMTYPE_TICKET)]
+    term1 = [Term(ITEMTYPE, ITEMTYPE_TICKET)]
+    term2 = []
     if query:
-        terms.append(qp.parse(query))
+        term2.append(qp.parse(query))
 
     if status == u'open':
-        terms.append(Term(CLOSED, False))
+        term1.append(Term(CLOSED, False))
     elif status == u'closed':
-        terms.append(Term(CLOSED, True))
+        term1.append(Term(CLOSED, True))
 
     selected_tags = set(request.args.getlist(u'selected_tags'))
-    terms.extend(Term(TAGS, tag) for tag in selected_tags)
-    assigned_username = request.args.get(ASSIGNED_TO)
+    term1.extend(Term(TAGS, tag) for tag in selected_tags)
+    assigned_username = request.args.get(ASSIGNED_TO) or query
     user = [Term(NAME, assigned_username)]
     user.append(Term(CONTENTTYPE, CONTENTTYPE_USER))
     user = And(user)
@@ -2351,11 +2358,24 @@
             selected_user = searcher.search(user, limit=None)
             if selected_user:
                 assigned_to = selected_user[0][ITEMID]
-                terms.append(Term(ASSIGNED_TO, assigned_to))
-            else:
-                terms = []
-
-        q = And(terms)
+                term2.append(Term(ASSIGNED_TO, assigned_to))
+            elif not query:
+                term2 = []
+                term1 = []
+        q = None
+        # There are two cases when the user uses the search box in the ticket tracker and other
+        # when user clicks on Assignee name in the ticket's table to view all tickets assigned to him
+        # E.g of link for second case is  +tickets?assigned_to=username
+        # for first case i.e while we are using search box, variable 'query' (i.e what ever is searched)  should be present either in
+        # TAGS, SUMMARY, CONTENT, ITEMID 'or' ASSIGNED_TO 'and' should be of given status (closed or open).
+        # while in second case we have to get all the results having given status 'and' Assigned_to =  request.args.get(ASSIGNED_TO).
+        # first case we use 'and'  while in second case we use 'or' while adding the assigned_to condition to retrieve the results.
+        if query:
+            term2 = Or(term2)
+            term1.extend([term2])
+        else:
+            term1.extend(term2)
+        q = And(term1)
         results = searcher.search(q, limit=None)
         tags = get_itemtype_specific_tags(ITEMTYPE_TICKET)
         return render_template('tickets.html',
--- a/MoinMoin/templates/atom.html	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/templates/atom.html	Tue Apr 28 12:17:55 2015 -0700
@@ -1,18 +1,4 @@
 {% import "utils.html" as utils %}
-{% macro show_meta(rev) %}
-    <div class="moin-diff-info moin-diff-info-rev-id">
-        <span class="moin-diff-info-caption">{{ _('Revision') }}:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['revid'] | shorten_id }}</span>
-    </div>
-    <div class="moin-diff-info moin-diff-info-rev-size">
-        <span class="moin-diff-info-caption">{{ _('Size') }}:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['size'] }}</span>
-    </div>
-    <div class="moin-diff-info moin-diff-info-rev-comment">
-        <span class="moin-diff-info-caption">{{ _('Comment') }}:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['comment'] }}</span>
-    </div>
-{% endmacro %}
 
 {# A few style rules to ensure the content doesn't overflow #}
 {% macro atom_style() %}
@@ -39,7 +25,7 @@
     <table class="moin-diff" cellpadding="10" width="100%">
         <tr>
             <td class="moin-diff-header" style="width: 100%;">
-                <strong>{{ show_meta(rev) }}</strong>
+                <strong>{{ utils.show_meta(rev) }}</strong>
             </td>
         </tr>
     </table>
@@ -50,10 +36,10 @@
     <table class="moin-diff" cellpadding="10" width="100%">
         <tr>
             <td class="moin-diff-header" style="width: 50%;">
-                <strong>{{ show_meta(oldrev) }}</strong>
+                <strong>{{ utils.show_meta(oldrev) }}</strong>
             </td>
             <td class="moin-diff-header" style="width: 50%;">
-                <strong>{{ show_meta(newrev) }}</strong>
+                <strong>{{ utils.show_meta(newrev) }}</strong>
             </td>
         </tr>
     </table>
--- a/MoinMoin/templates/diff_text.html	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/templates/diff_text.html	Tue Apr 28 12:17:55 2015 -0700
@@ -1,33 +1,12 @@
 {% import "utils.html" as utils %}
 
-{% macro show_meta(rev) %}
-    <div class="moin-diff-info moin-diff-info-rev-id">
-        <span class="moin-diff-info-caption">Revision:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['revid'] | shorten_id }}</span>
-    </div>
-    <div class="moin-diff-info moin-diff-info-rev-author">
-        <span class="moin-diff-info-caption">Editor:</span>
-        <span class="moin-diff-info-value">
-            {{ utils.editor_info(rev.meta) }}
-        </span>
-    </div>
-    <div class="moin-diff-info moin-diff-info-rev-size">
-        <span class="moin-diff-info-caption">Size:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['size'] }}</span>
-    </div>
-    <div class="moin-diff-info moin-diff-info-rev-comment">
-        <span class="moin-diff-info-caption">Comment:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['comment'] }}</span>
-    </div>
-{% endmacro %}
-
 <table class="moin-diff">
     <tr>
         <td class="moin-diff-header">
-            {{ show_meta(oldrev) }}
+            {{ utils.show_meta(oldrev) }}
         </td>
         <td class="moin-diff-header">
-            {{ show_meta(newrev) }}
+            {{ utils.show_meta(newrev) }}
         </td>
     </tr>
     <tr>
--- a/MoinMoin/templates/diff_text_atom.html	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/templates/diff_text_atom.html	Tue Apr 28 12:17:55 2015 -0700
@@ -1,19 +1,5 @@
 {% import "utils.html" as utils %}
 
-{% macro show_meta(rev) %}
-    <div class="moin-diff-info moin-diff-info-rev-id">
-        <span class="moin-diff-info-caption">{{ _('Revision') }}:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['revid'] | shorten_id }}</span>
-    </div>
-    <div class="moin-diff-info moin-diff-info-rev-size">
-        <span class="moin-diff-info-caption">{{ _('Size') }}:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['size'] }}</span>
-    </div>
-    <div class="moin-diff-info moin-diff-info-rev-comment">
-        <span class="moin-diff-info-caption">{{ _('Comment') }}:</span>
-        <span class="moin-diff-info-value">{{ rev.meta['comment'] }}</span>
-    </div>
-{% endmacro %}
 <table class="moin-diff" style="width: 100%;">
     {% for llineno, lcontent, rlineno, rcontent in diffs %}
         <tr>
@@ -27,12 +13,12 @@
         <td class="moin-diff-header-line" style="width: 3%;">
         </td>
         <td class="moin-diff-header" style="width: 47%;">
-            <strong>{{ show_meta(oldrev) }}</strong>
+            <strong>{{ utils.show_meta(oldrev) }}</strong>
         </td>
         <td class="moin-diff-header-line" style="width: 3%;">
         </td>
         <td class="moin-diff-header" style="width: 47%;">
-            <strong>{{ show_meta(newrev) }}</strong>
+            <strong>{{ utils.show_meta(newrev) }}</strong>
         </td>
     </tr>
 </table>
--- a/MoinMoin/templates/tickets.html	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/templates/tickets.html	Tue Apr 28 12:17:55 2015 -0700
@@ -73,7 +73,9 @@
                             {{ result.get('mtime', '').strftime('%Y-%m-%d') }}
                         </td>
                         <td>
-                            {{ get_assigned_to_info(result) }}
+                            <a href="{{ url_for('frontend.tickets', assigned_to= get_assigned_to_info(result)) }}">
+                                {{ get_assigned_to_info(result) }}
+                            </a>
                         </td>
                         <td>
                             {{ result.get('effort', '') }}
--- a/MoinMoin/templates/utils.html	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/templates/utils.html	Tue Apr 28 12:17:55 2015 -0700
@@ -274,3 +274,46 @@
        </a>
     </li>
 {% endmacro %}
+
+{% macro show_meta(rev) %}
+    <div>
+        <span class="moin-diff-info-caption">
+            {{ _('Revision') }}
+        </span>
+        <span class="moin-diff-info-value">
+            {{ rev.meta['revid'] | shorten_id }}
+        </span>
+    </div>
+    <div>
+        <span class="moin-diff-info-caption">
+            {{ _('Editor') }}:
+        </span>
+        <span class="moin-diff-info-value">
+            {{ editor_info(rev.meta) }}
+        </span>
+    </div>
+    <div>
+        <span class="moin-diff-info-caption">
+            {{ _('Size') }}:
+        </span>
+        <span class="moin-diff-info-value">
+            {{ rev.meta['size'] }}
+        </span>
+    </div>
+    <div>
+        <span class="moin-diff-info-caption">
+            {{ _('Time') }}:
+        </span>
+        <span class="moin-diff-info-value">
+            {{ rev.meta.mtime|datetimeformat }}
+        </span>
+    </div>
+    <div>
+        <span class="moin-diff-info-caption">
+            {{ _('Comment') }}:
+        </span>
+        <span class="moin-diff-info-value">
+            {{ rev.meta['comment'] }}
+        </span>
+    </div>
+{% endmacro %}
--- a/MoinMoin/themes/__init__.py	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/themes/__init__.py	Tue Apr 28 12:17:55 2015 -0700
@@ -439,7 +439,7 @@
 
     # Properties ##############################################################
 
-    def login_url(self):
+    def login_url(self, next_url=None):
         """
         Return URL usable for user login
 
@@ -448,9 +448,9 @@
         """
         url = None
         if self.cfg.auth_login_inputs == ['special_no_input']:
-            url = url_for('frontend.login', login=1)
+            url = url_for('frontend.login', login=1, next=next_url)
         if self.cfg.auth_have_login:
-            url = url or url_for('frontend.login')
+            url = url or url_for('frontend.login', next=next_url)
         return url
 
     def get_fqnames(self, fqname):
--- a/MoinMoin/themes/basic/templates/layout.html	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/themes/basic/templates/layout.html	Tue Apr 28 12:17:55 2015 -0700
@@ -15,7 +15,7 @@
 {% set current_url = request.url %}
 {% set current_path = request.path %}
 {% set current_url_showview = url_for_item(endpoint='frontend.show_item', item_name=item_name) %}
-{% set login_url = theme_supp.login_url() %}
+{% set login_url = theme_supp.login_url(current_path) %}
 
 {# Helper macro to generate the local panel #}
 {% macro local_panel_main(panelname) -%}
@@ -41,7 +41,8 @@
         rel="nofollow"
         {% if title %} title="{{ title }}" {% endif %}>
         {% if iconcls %} <i class="{{ iconcls }}"> </i> {% endif %}
-        {% if href == login_url %}
+        {# needs a login url without next #}
+        {% if href == theme_supp.login_url() %}
             {{ label }}
         {% else %}
             <span class="hidden-sm hidden-xs">{{ label }}</span>
@@ -165,7 +166,7 @@
                                         {%- endif %}
                                         {% if user.auth_method in cfg.auth_can_logout %}
                                             <li title="{{ _('Logout') }}">
-                                                {{ hyperlink(url_for('frontend.logout', logout_submit=1), None, True,
+                                                {{ hyperlink(url_for('frontend.logout', logout_submit=1, next=current_path), None, True,
                                                         _('Logout'), "fa fa-sign-out fa-inverse", None) }}
                                             </li>
                                         {% endif %}
--- a/MoinMoin/themes/basic/templates/login.html	Mon Apr 27 22:07:21 2015 +0200
+++ b/MoinMoin/themes/basic/templates/login.html	Tue Apr 28 12:17:55 2015 -0700
@@ -8,7 +8,7 @@
             {{ forms.render_errors(form) }}
 
             {% if 'username' in login_inputs or 'password' in login_inputs %}
-                {{ gen.form.open(form, method="post", action=url_for('frontend.login')) }}
+                {{ gen.form.open(form, method="post", action=url_for('frontend.login', next=request.args.get('next'))) }}
 
                     {% if 'username' in login_inputs %}
                         <div class="form-group">