allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [4/50] git commit: [#4339] ticket:237 add page for ticket moving
Date Tue, 22 Jan 2013 23:23:18 GMT
[#4339] ticket:237 add page for ticket moving


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

Branch: refs/heads/cj/4691
Commit: a594ddac959761755c3515a7995132e91e8272e8
Parents: e0c6e1d
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Dec 11 15:02:51 2012 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Fri Jan 18 21:53:18 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/forms.py                 |   20 ++++++++++++++
 .../templates/tracker/move_ticket.html             |    9 ++++++
 .../forgetracker/templates/tracker/ticket.html     |    3 ++
 ForgeTracker/forgetracker/tracker_main.py          |   21 +++++++++++++++
 4 files changed, 53 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a594ddac/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 22ff9c8..0579de6 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -879,3 +879,23 @@ class NeighborhoodAddProjectForm(ForgeForm):
                 });
             });
         ''' % dict(project_name=project_name, project_unixname=project_unixname))
+
+
+class MoveTicketForm(ForgeForm):
+    defaults = dict(
+        ForgeForm.defaults,
+        action='',
+        method='post',
+        submit_text='Move')
+
+    class fields(ew_core.NameList):
+        tracker = ew.SingleSelectField(
+            label='Tracker mount point',
+            options = [])
+
+    def __init__(self, *args, **kwargs):
+        trackers = kwargs.pop('trackers', [])
+        super(MoveTicketForm, self).__init__(*args, **kwargs)
+        self.fields.tracker.options = (
+            [ew.Option(py_value=v, label=l, selected=s)
+             for v, l, s in sorted(trackers, key=lambda x: x[1])])

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a594ddac/ForgeTracker/forgetracker/templates/tracker/move_ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/move_ticket.html b/ForgeTracker/forgetracker/templates/tracker/move_ticket.html
new file mode 100644
index 0000000..c556f80
--- /dev/null
+++ b/ForgeTracker/forgetracker/templates/tracker/move_ticket.html
@@ -0,0 +1,9 @@
+{% extends g.theme.master %}
+
+{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Move ticket
#{{ticket.ticket_num}} {{ticket.summary}}{% endblock %}
+
+{% block header %}Move ticket #{{ticket.ticket_num}} {{ticket.summary}}{% endblock %}
+
+{% block content %}
+  {{ form.display() }}
+{% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a594ddac/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index 72de788..aaf28bc 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -18,6 +18,9 @@
 {% if c.user and c.user != c.user.anonymous() %}
   {{c.subscribe_form.display(value=subscribed, tool_subscribed=tool_subscribed, action='subscribe',
style='icon')}}
 {% endif %}
+{% if h.has_access(ticket.app, 'admin') %}
+  <a href="move" title="Move"><b data-icons="{{g.icons['pencil'].char}}" class="ico
{{g.icons['pencil'].css}}"></b> Move</a>
+{% endif %}
 {% if h.has_access(ticket, 'update') %}
   <a href="#" title="Edit" class="edit_ticket"><b data-icon="{{g.icons['pencil'].char}}"
class="ico {{g.icons['pencil'].css}}"></b> Edit</a>
 {% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a594ddac/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 612cd9e..626c035 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -6,6 +6,7 @@ from urllib import urlencode, unquote
 from urllib2 import urlopen
 from webob import exc
 import json
+from itertools import ifilter
 
 # Non-stdlib imports
 import pkg_resources
@@ -135,6 +136,7 @@ class W:
     options_admin = OptionsAdmin()
     search_help_modal = SearchHelp()
     vote_form = w.VoteForm()
+    move_ticket_form = w.forms.MoveTicketForm
 
 class ForgeTrackerApp(Application):
     __version__ = version.__version__
@@ -1265,6 +1267,25 @@ class TicketController(BaseController):
             votes_down=self.ticket.votes_down,
             votes_percent=self.ticket.votes_up_percent)
 
+    @expose('jinja:forgetracker:templates/tracker/move_ticket.html')
+    def move(self, **post_data):
+        require_access(self.ticket.app, 'admin')
+        # collect all 'Tickets' instances in all user project for which his has admin perms
+        trackers = []
+        projects = c.user.my_projects()
+        projects = ifilter(lambda p: has_access(p, 'admin'), projects)
+        for p in projects:
+            for ac in p.app_configs:
+                if ac.tool_name == 'Tickets':
+                    trac = (str(ac._id),
+                            '%s/%s' % (p.shortname, ac.options['mount_point']),
+                            bool(self.ticket.app.config == ac))
+                    trackers.append(trac)
+        return {
+            'ticket': self.ticket,
+            'form': W.move_ticket_form(trackers=trackers),
+        }
+
 
 class AttachmentController(ac.AttachmentController):
     AttachmentClass = TM.TicketAttachment


Mime
View raw message