You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2019/01/03 14:57:08 UTC

[03/11] allura git commit: [#5461] subscribe option on tickets, and tighten up new/edit form

[#5461] subscribe option on tickets, and tighten up new/edit form


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b451b99c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b451b99c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b451b99c

Branch: refs/heads/master
Commit: b451b99c7ecdaa8e23a4fbe78fa74b0f02462ca9
Parents: 98aed3e
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Dec 18 17:52:34 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Dec 19 12:08:05 2018 -0500

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py         |  8 +++++---
 .../templates/tracker_widgets/ticket_form.html    | 18 +++++++++---------
 ForgeTracker/forgetracker/widgets/ticket_form.py  |  6 +-----
 3 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b451b99c/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 580bd51..3e37ea6 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -867,7 +867,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
         return False
     discussion_disabled = property(_get_discussion_disabled, _set_discussion_disabled)
 
-    def commit(self, **kwargs):
+    def commit(self, subscribe=False, **kwargs):
         VersionedArtifact.commit(self)
         monitoring_email = self.app.config.options.get('TicketMonitoringEmail')
         if self.version > 1:
@@ -911,7 +911,8 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                         tofile='description-new')))
             description = '\n'.join(changes)
         else:
-            self.subscribe()
+            if subscribe:
+                self.subscribe()
             if self.assigned_to_id:
                 user = User.query.get(_id=self.assigned_to_id)
                 g.statsUpdater.ticketEvent(
@@ -955,6 +956,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
     def update(self, ticket_form):
         # update is not allowed to change the ticket_num
         ticket_form.pop('ticket_num', None)
+        subscribe = ticket_form.pop('subscribe', False)
         self.labels = ticket_form.pop('labels', [])
         custom_users = set()
         other_custom_fields = set()
@@ -997,7 +999,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             # flush the session to make attachments available in the
             # notification email
             ThreadLocalORMSession.flush_all()
-        self.commit()
+        self.commit(subscribe=subscribe)
 
     def _move_attach(self, attachments, attach_metadata, app_config):
         for attach in attachments:

http://git-wip-us.apache.org/repos/asf/allura/blob/b451b99c/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
index cfa90ab..be256c1 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
@@ -45,8 +45,8 @@
   {% set min_c_fields = widget.fields['_milestone'] and 1 or 0 %}
   {% if c.app.globals.custom_fields and c.app.globals.custom_fields.__len__() > min_c_fields %}
     {{widget.display_field_by_name('custom_fields', ignore_errors=True)}}
+    <div style="clear:both">&nbsp;</div>
   {% endif %}
-  <div style="clear:both">&nbsp;</div>
   <div class="grid-12">
     <label class="cr">Labels:</label>
     {{widget.display_field_by_name('labels')|safe}}
@@ -90,7 +90,8 @@
   </div>
   <div style="clear:both">&nbsp;</div>
   <div class="grid-18">
-    {% if ticket %}
+    <label class="simple">Attachments:</label>
+    {% if ticket and ticket.attachments %}
       <div class="clearfix">
       {% for att in ticket.attachments %}
           <div class="attachment_thumb">
@@ -104,15 +105,8 @@
           </div>
       {% endfor %}
       </div>
-      <div style="clear:both">&nbsp;</div>
     {% endif %}
-    <div>
-      <a href="#" id="show_attach">Add attachments</a>
-    </div>
-    <div style="clear:both">&nbsp;</div>
-    <div id="view_attach" style="display:none">
       {{widget.display_field_by_name('attachment')|safe}}
-    </div>
   </div>
   <div style="clear:both">&nbsp;</div>
   <div class="reply" style="position:relative;{% if not show_comment %} display:none{% endif %}">
@@ -132,6 +126,12 @@
   <div style="clear:both">&nbsp;</div>
   <div class="grid-18">
     {{widget.display_field_by_name('submit')|safe}}
+    {% if c.user and c.user != c.user.anonymous() and not ticket %}
+        {# TODO: if not already subscribed to whole tool #}
+        <label class="subscribe">
+          <input type="checkbox" checked name="ticket_form.subscribe">Subscribe to this ticket
+        </label>
+    {% endif %}
     <a href="{{c.app.url}}" class="btn link cancel_form">Cancel</a>
   </div>
   {{lib.csrf_token()}}

http://git-wip-us.apache.org/repos/asf/allura/blob/b451b99c/ForgeTracker/forgetracker/widgets/ticket_form.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/ticket_form.py b/ForgeTracker/forgetracker/widgets/ticket_form.py
index 24b97cb..5481eb2 100644
--- a/ForgeTracker/forgetracker/widgets/ticket_form.py
+++ b/ForgeTracker/forgetracker/widgets/ticket_form.py
@@ -129,6 +129,7 @@ class GenericTicketForm(ew.SimpleForm):
                                 'class': "ui-button ui-widget ui-state-default ui-button-text-only"}),
             ew.HiddenField(name='ticket_num',
                            validator=fev.Int(if_missing=None)),
+            ew.Checkbox(name='subscribe', label='Subscribe'),
         ]
         # milestone is kind of special because of the layout
         # add it to the main form rather than handle with the other customs
@@ -157,11 +158,6 @@ class TicketForm(GenericTicketForm):
         // Sometimes IE11 is not firing jQuery's ready callbacks like
         // "$(function(){...})" or "$(document).ready(function(){...});"
         $(window).load(function(){
-            $('#show_attach').click(function(evt) {
-                $('#view_attach').show();
-                $('#show_attach').hide();
-                evt.preventDefault();
-            });
             $('form').submit(function() {
                 $('input[type=submit]', this).prop('disabled', true);
             });