incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [4/6] git commit: [#2584] ticket:256 * removed ?deleted=True from deleted tickets url * improved tests
Date Tue, 29 Jan 2013 20:00:28 GMT
[#2584] ticket:256
* removed ?deleted=True from deleted tickets url
* improved tests


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

Branch: refs/heads/master
Commit: 6c4ae599d66f5a5c6a29cf21159548ded588bf7d
Parents: 1651878
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Mon Jan 21 16:48:53 2013 +0400
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Jan 29 19:59:49 2013 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py          |    9 ++-
 .../forgetracker/templates/tracker/index.html      |    6 +-
 .../forgetracker/tests/functional/test_root.py     |   46 +++++++++------
 ForgeTracker/forgetracker/tracker_main.py          |   16 +++--
 4 files changed, 44 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6c4ae599/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 54c90ae..a61cd9a 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -160,6 +160,10 @@ class Globals(MappedClass):
                 for field in self.custom_fields
                 if field.get('show_in_search')]
 
+    def has_deleted_tickets(self):
+        return  Ticket.query.find(dict(
+            app_config_id=c.app.config._id, deleted=True)).count() > 0
+
 
 class TicketHistory(Snapshot):
 
@@ -461,10 +465,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             pubdate=self.created_date)
 
     def url(self):
-        s = self.app_config.url() + str(self.ticket_num) + '/'
-        if self.deleted:
-            s += '?deleted=True'
-        return s
+        return self.app_config.url() + str(self.ticket_num) + '/'
 
     def shorthand_id(self):
         return '#' + str(self.ticket_num)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6c4ae599/ForgeTracker/forgetracker/templates/tracker/index.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/index.html b/ForgeTracker/forgetracker/templates/tracker/index.html
index f22a561..509542e 100644
--- a/ForgeTracker/forgetracker/templates/tracker/index.html
+++ b/ForgeTracker/forgetracker/templates/tracker/index.html
@@ -21,14 +21,14 @@
 {% endblock %}
 
 {% block content %}
-    {%if h.has_access(c.app, 'delete')%}
-        <div class="grid-18">
+    {%if h.has_access(c.app, 'delete') and c.app.globals.has_deleted_tickets()%}
+        <p>
             {%if deleted%}
                 <a href="?deleted=False">Hide deleted tickets</a>
             {%else%}
                 <a  href="?deleted=True">Show deleted tickets</a>
             {%endif%}
-        </div>
+        </p>
     {%endif%}
   {% if help_msg %}
     <div id="search-ticket-help-msg" class="grid-19 info">{{g.markdown.convert(help_msg)}}</div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6c4ae599/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 aecbd72..b05e62e 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1062,35 +1062,43 @@ class TestFunctionalController(TrackerTestController):
         # not found and has not import_id
         self.app.get('/p/test/bugs/42042/', status=404)
 
-    def test_deleted_tickets(self):
+    def test_ticket_delete(self):
         self.new_ticket(summary='Test ticket')
+        self.app.post('/bugs/1/delete')
         r = self.app.get('/bugs/')
-        assert '<a href="/p/test/bugs/1/">Test ticket</a>' in r
-        assert '<a  href="?deleted=True">Show deleted tickets</a>' in r
-        r = self.app.get('/bugs/', extra_environ=dict(username='*anonymous'))
-        assert '<a  href="?deleted=True">Show deleted tickets</a>' not in r
-        self.app.post('/bugs/1/delete', extra_environ=dict(username='*anonymous'))
+        assert 'No open tickets found.' in r
+        self.app.post('/bugs/1/undelete')
         r = self.app.get('/bugs/')
         assert 'No open tickets found.' not in r
 
+    def test_ticket_delete_without_permission(self):
+        self.new_ticket(summary='Test ticket')
+        self.app.post('/bugs/1/delete', extra_environ=dict(username='*anonymous'))
+        r = self.app.get('/bugs/')
+        assert '<a href="/p/test/bugs/1/">Test ticket</a>' in r
         self.app.post('/bugs/1/delete')
+        self.app.post('/bugs/1/undelete', extra_environ=dict(username='*anonymous'))
         r = self.app.get('/bugs/')
         assert 'No open tickets found.' in r
-        r = self.app.get('/bugs/?deleted=True')
-        assert '<a href="/p/test/bugs/1/?deleted=True">Test ticket' in r
-        assert '<a href="?deleted=False">Hide deleted tickets</a>' in r
-        ticket = tm.Ticket.query.find().first()
-        assert 'deleted=True' in ticket.url()
-        r = self.app.get('/p/test/bugs/1/?deleted=True')
+
+    def test_deleted_ticket_visible(self):
+        self.new_ticket(summary='Test ticket')
+        self.app.post('/bugs/1/delete')
+        r = self.app.get('/p/test/bugs/1/')
         assert '#1 Test ticket' in r
-        r = self.app.get('/p/test/bugs/1/', status=404)
+        self.app.get('/p/test/bugs/1/', extra_environ=dict(username='*anonymous'), status=404)
 
-        self.app.post('/bugs/1/undelete', extra_environ=dict(username='*anonymous'))
-        r = self.app.get('/bugs/')
-        assert 'No open tickets found.' in r
-        self.app.post('/bugs/1/undelete')
-        r = self.app.get('/bugs/')
-        assert 'No open tickets found.' not in r
+    def test_show_hide_deleted_tickets(self):
+        self.new_ticket(summary='Test ticket')
+        r = self.app.get('/p/test/bugs/')
+        assert 'Show deleted tickets' not in r
+        self.app.post('/bugs/1/delete')
+        r = self.app.get('/p/test/bugs/')
+        assert 'Show deleted tickets' in r
+        assert 'No open tickets found' in r
+        r = self.app.get('/bugs/?deleted=True')
+        assert '<a href="/p/test/bugs/1/">Test ticket' in r
+        assert '<a href="?deleted=False">Hide deleted tickets</a>' in r
 
     @td.with_tool('test', 'Tickets', 'bugs2')
     @td.with_tool('test2', 'Tickets', 'bugs')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6c4ae599/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index a302812..7324598 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1098,13 +1098,15 @@ class TicketController(BaseController):
     @expose('jinja:forgetracker:templates/tracker/ticket.html')
     @validate(dict(
             page=validators.Int(if_empty=0),
-            limit=validators.Int(if_empty=10),
-            deleted=validators.StringBool(if_empty=False)))
+            limit=validators.Int(if_empty=10)))
     def index(self, page=0, limit=10, deleted=False, **kw):
-        if ((self.ticket is not None) and
-           (not self.ticket.deleted or (self.ticket.deleted and
-                                        has_access(self.ticket,'delete') and
-                                        deleted))):
+        ticket_visible = False
+        if self.ticket is not None:
+            ticket_visible = (not self.ticket.deleted or
+                              (self.ticket.deleted and
+                               has_access(self.ticket,'delete')))
+
+        if ticket_visible:
             c.ticket_form = W.ticket_form
             c.thread = W.thread
             c.attachment_list = W.attachment_list
@@ -1188,7 +1190,7 @@ class TicketController(BaseController):
         suffix = " {dt.hour}:{dt.minute}:{dt.second} {dt.day}-{dt.month}-{dt.year}".format(dt=datetime.utcnow())
         self.ticket.summary += suffix
         flash('Ticket successfully deleted')
-        return dict(location='../'+str(self.ticket.ticket_num)+'/?deleted=True')
+        return dict(location='../'+str(self.ticket.ticket_num))
 
     @without_trailing_slash
     @expose('json:')


Mime
View raw message