incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/2] git commit: [#4968] ticket:172 redirect imported ticket to its new url
Date Fri, 05 Oct 2012 16:27:22 GMT
[#4968] ticket:172 redirect imported ticket to its new url


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

Branch: refs/heads/master
Commit: 6ef3a88eefa8aaa10072f5855ccd0fe6ee11f03d
Parents: 1a481f4
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Sep 24 12:18:28 2012 +0300
Committer: Cory Johns <johnsca@geek.net>
Committed: Fri Oct 5 16:13:29 2012 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py          |    3 ++-
 .../forgetracker/tests/functional/test_root.py     |   13 +++++++++++++
 ForgeTracker/forgetracker/tracker_main.py          |    7 +++++++
 3 files changed, 22 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6ef3a88e/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 67ce054..b0a4580 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -277,7 +277,8 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             snippet_s=self.summary,
             votes_up_i=self.votes_up,
             votes_down_i=self.votes_down,
-            votes_total_i=(self.votes_up-self.votes_down)
+            votes_total_i=(self.votes_up-self.votes_down),
+            import_id_s=self.import_id
             )
         for k,v in self.custom_fields.iteritems():
             result[k + '_s'] = unicode(v)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6ef3a88e/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index f5c0b4b..39fffc2 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -868,6 +868,19 @@ class TestFunctionalController(TrackerTestController):
         a = r.html.find('a', {'class': 'edit_ticket'})
         assert a.text == 'Edit'
 
+    def test_imported_tickets_redirect(self):
+        self.new_ticket(summary='Imported ticket')
+        ticket = tm.Ticket.query.get(ticket_num=1)
+        ticket.import_id = '42000'
+        ThreadLocalORMSession.flush_all()
+
+        # expect permanent redirect to /p/test/bugs/1/
+        r = self.app.get('/p/test/bugs/42000/', status=301).follow()
+        assert r.request.path == '/p/test/bugs/1/', r.request.path
+
+        # not found and has not import_id
+        self.app.get('/p/test/bugs/42042/', status=404)
+
 
 class TestMilestoneAdmin(TrackerTestController):
     def _post(self, params, **kw):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6ef3a88e/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 8a1b404..8a6bc42 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -23,6 +23,7 @@ from ming.utils import LazyProperty
 # Pyforge-specific imports
 from allura import model as M
 from allura.lib import helpers as h
+from allura.lib import utils
 from allura.app import Application, SitemapEntry, DefaultAdminController, ConfigOption
 from allura.lib.search import search_artifact
 from allura.lib.decorators import require_post
@@ -954,6 +955,12 @@ class TicketController(BaseController):
             self.ticket_num = int(ticket_num)
             self.ticket = TM.Ticket.query.get(app_config_id=c.app.config._id,
                                                     ticket_num=self.ticket_num)
+            if self.ticket is None:
+                self.ticket = TM.Ticket.query.get(
+                        app_config_id=c.app.config._id,
+                        import_id=str(ticket_num))
+                if self.ticket is not None:
+                    utils.permanent_redirect(self.ticket.url())
             self.attachment = AttachmentsController(self.ticket)
             # self.comments = CommentController(self.ticket)
         setattr(self, 'feed.atom', self.feed)


Mime
View raw message