You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/04/09 18:28:46 UTC

[1/6] git commit: [#2716] Fix users_with_role() for subprojects.

Updated Branches:
  refs/heads/cj/5494 adc806e07 -> 5207de0e2 (forced update)


[#2716] Fix users_with_role() for subprojects.

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5494
Commit: 0ce64c7b392a1af9601e38b78bcee0afc20ffa59
Parents: 46780f8
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Thu Apr 4 17:58:33 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Apr 4 19:32:59 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py            |   12 ++++++------
 Allura/allura/tests/model/test_project.py |    8 +++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0ce64c7b/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index b0b45df..279a122 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -666,15 +666,15 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         e.g., project.users_with_role('Admin', 'Developer') -> returns all
           users in `project` having the Admin role or the Developer role, or both
         """
-        roles = ProjectRole.query.find(dict(name={'$in': role_names}, project_id=self._id))
-        return [project_role.user for r in roles for project_role in r.users_with_role(self)]
+        users = set()
+        for role_name in role_names:
+            for user in g.credentials.users_with_named_role(self.root_project._id, role_name):
+                users.add(user)
+        return list(users)
 
     def admins(self):
         """Find all the users who have 'Admin' role for this project"""
-        admin_role = ProjectRole.query.get(name='Admin', project_id=self._id)
-        if not admin_role:
-            return []
-        return [r.user.username for r in admin_role.users_with_role(self)]
+        return self.users_with_role('Admin')
 
     def user_in_project(self, username):
         from .auth import User

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0ce64c7b/Allura/allura/tests/model/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_project.py b/Allura/allura/tests/model/test_project.py
index 5277d34..b084a3d 100644
--- a/Allura/allura/tests/model/test_project.py
+++ b/Allura/allura/tests/model/test_project.py
@@ -84,4 +84,10 @@ def test_set_ordinal_to_admin_tool():
     assert c.project.sitemap()
     assert c.project.app_config('admin').options.ordinal == 100
 
-
+def test_users_and_roles():
+    p = c.project
+    sub = c.project.direct_subprojects.next()
+    u = M.User.by_username('test-admin')
+    assert p.users_with_role('Admin') == [u]
+    assert p.users_with_role('Admin') == sub.users_with_role('Admin')
+    assert p.users_with_role('Admin') == p.admins()


[2/6] git commit: [#5453] `from PIL import Image` doesn't work all the time

Posted by jo...@apache.org.
[#5453] `from PIL import Image` doesn't work all the time


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

Branch: refs/heads/cj/5494
Commit: b08571f17b65540cf75998e808042eaf3a2fec44
Parents: 0ce64c7
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Apr 4 20:46:01 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Apr 4 20:46:01 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/graphics/graphic_methods.py |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b08571f1/Allura/allura/lib/graphics/graphic_methods.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/graphics/graphic_methods.py b/Allura/allura/lib/graphics/graphic_methods.py
index cd3151b..88892c1 100644
--- a/Allura/allura/lib/graphics/graphic_methods.py
+++ b/Allura/allura/lib/graphics/graphic_methods.py
@@ -1,8 +1,9 @@
+import StringIO
+
 from matplotlib.backends.backend_agg import FigureCanvasAgg
 from matplotlib.figure import Figure
-from matplotlib.text import Annotation
-from PIL import Image
-import StringIO
+import Image
+
 
 def create_histogram(data, tick_labels, y_label, title):
     fig = Figure(figsize=(10,5), dpi=80, facecolor='white')
@@ -23,7 +24,7 @@ def create_histogram(data, tick_labels, y_label, title):
     fig.subplots_adjust(bottom=0.3)
 
     canvas.draw()
-        
+
     s = canvas.tostring_rgb()
     l,b,w,h = fig.bbox.bounds
     w, h = int(w), int(h)
@@ -66,4 +67,3 @@ def create_progress_bar(value):
     im.save(output, 'PNG')
 
     return output.getvalue()
-


[3/6] git commit: [#6068] fix paged_diffs return value when no DiffInfoDoc found

Posted by jo...@apache.org.
[#6068] fix paged_diffs return value when no DiffInfoDoc found


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

Branch: refs/heads/cj/5494
Commit: 2dfbcfb25a24f844c332f7e3643fe0df5dc60eb0
Parents: b08571f
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Apr 8 13:17:26 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Apr 8 17:22:11 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py                      |    2 +-
 ForgeSVN/forgesvn/tests/model/test_repository.py |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dfbcfb2/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 4d396b8..d8b06be 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -270,7 +270,7 @@ class Commit(RepoObject):
     def paged_diffs(self, start=0, end=None):
         di = DiffInfoDoc.m.get(_id=self._id)
         if di is None:
-            return Object(added=[], removed=[], changed=[], copied=[])
+            return Object(added=[], removed=[], changed=[], copied=[], total=0)
         added = []
         removed = []
         changed = []

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dfbcfb2/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 676a887..09745e7 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -209,7 +209,11 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         expected =  dict(
                 copied=[], changed=[], removed=[],
                 added=['/a/b', '/a/b/c'], total=4)
-        self.assertEqual(expected, entry.paged_diffs(start=1, end=3))
+        actual = entry.paged_diffs(start=1, end=3)
+        self.assertEqual(expected, actual)
+
+        empty = M.repo.Commit().paged_diffs()
+        self.assertEqual(sorted(actual.keys()), sorted(empty.keys()))
 
     def test_diff_create_file(self):
         entry = self.repo.log(1, limit=1)[0]


[5/6] git commit: [#2643] update test for longer time window

Posted by jo...@apache.org.
[#2643] update test for longer time window


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

Branch: refs/heads/cj/5494
Commit: fa5d7e03e3baa587129ec4f49738d598c9861a76
Parents: 7041d1a
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Apr 9 11:15:45 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Apr 9 11:15:45 2013 -0400

----------------------------------------------------------------------
 Allura/allura/tests/test_utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fa5d7e03/Allura/allura/tests/test_utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_utils.py b/Allura/allura/tests/test_utils.py
index 2095179..c047028 100644
--- a/Allura/allura/tests/test_utils.py
+++ b/Allura/allura/tests/test_utils.py
@@ -77,7 +77,7 @@ class TestAntispam(unittest.TestCase):
         self.assertRaises(
             ValueError,
             utils.AntiSpam.validate_request,
-            r, now=time.time()+60*60+1)
+            r, now=time.time()+24*60*60+1)
 
     def test_invalid_future(self):
         form = dict(a='1', b='2')


[4/6] git commit: [#2643] greatly increase antispam time window, to allow longer time for people to compose messages

Posted by jo...@apache.org.
[#2643] greatly increase antispam time window, to allow longer time for people to compose messages


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

Branch: refs/heads/cj/5494
Commit: 7041d1a1e2c9727aee0e3cb51c78d47c430c0160
Parents: 2dfbcfb
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Apr 9 14:04:15 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Apr 9 14:04:15 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/utils.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7041d1a1/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 6e2d3b8..9bf6cd8 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -294,8 +294,8 @@ class AntiSpam(object):
             if now is None: now = time.time()
             if obj.timestamp > now + 5:
                 raise ValueError, 'Post from the future'
-            if now - obj.timestamp > 60*60:
-                raise ValueError, 'Post from the 1hr+ past'
+            if now - obj.timestamp > 24*60*60:
+                raise ValueError, 'Post from the distant past'
             if obj.spinner != obj.make_spinner(obj.timestamp):
                 raise ValueError, 'Bad spinner value'
             for k in new_params.keys():


[6/6] git commit: [#5494] Refactor mass edit ticket select checkboxes to use multi-value instead of name/join

Posted by jo...@apache.org.
[#5494] Refactor mass edit ticket select checkboxes to use multi-value instead of name/join

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5494
Commit: 5207de0e2d9606fc11d3dd2bd2616941b573cf79
Parents: fa5d7e0
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Apr 4 19:11:12 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Apr 9 16:28:22 2013 +0000

----------------------------------------------------------------------
 .../templates/tracker_widgets/mass_edit.html       |    2 +-
 .../templates/tracker_widgets/mass_edit_form.html  |    1 -
 .../forgetracker/tests/functional/test_root.py     |    6 +++---
 ForgeTracker/forgetracker/tracker_main.py          |   11 ++---------
 .../forgetracker/widgets/resources/js/mass-edit.js |    4 +++-
 5 files changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5207de0e/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit.html b/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit.html
index 07b3d22..381cf7a 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit.html
@@ -17,7 +17,7 @@
       <tbody class="ticket-list">
         {% for t in tickets %}
         <tr>
-          <td><input type="checkbox" name="{{t._id}}" value=""/></td>
+          <td><input type="checkbox" name="ticket_ids" value="{{t._id}}"/></td>
           <td><a href="{{t.url()}}">{{t.ticket_num}}</a></td>
           <td><a href="{{t.url()}}">{{t.summary}}</a></td>
           <td>{{t._milestone}}</td>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5207de0e/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit_form.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit_form.html b/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit_form.html
index 7e6e738..1cb215b 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit_form.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/mass_edit_form.html
@@ -72,6 +72,5 @@
       <!-- tg.url(c.app.url+'search/', dict(q=query, limit=limit, sort=sort))}}" class="btn link">Cancel</a>-->
     </div>
     <div class="grid-12" id="result"></div>
-    <input name="__selected" type="hidden" value="" id="id_selected" />
     <input name="__search" type="hidden" value="" id="id_search" />
 </form>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5207de0e/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 8276692..b2fd554 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -243,7 +243,7 @@ class TestFunctionalController(TrackerTestController):
         r = self.app.get('/p/test/bugs/edit/?q=ticket')
         self.app.post('/p/test/bugs/update_tickets', {
                       '__search': '',
-                      '__selected': first_ticket._id,
+                      '__ticket_ids': [first_ticket._id],
                       '_milestone': '2.0',
                       })
         r = self.app.get('/p/test/bugs/1/')
@@ -252,7 +252,7 @@ class TestFunctionalController(TrackerTestController):
         assert '<li><strong>Milestone</strong>: 1.0 --&gt; 2.0</li>' not in r
         self.app.post('/p/test/bugs/update_tickets', {
                       '__search': '',
-                      '__selected': '%s,%s' % (
+                      '__ticket_ids': (
                           first_ticket._id,
                           second_ticket._id),
                       '_milestone': '1.0',
@@ -264,7 +264,7 @@ class TestFunctionalController(TrackerTestController):
 
         self.app.post('/p/test/bugs/update_tickets', {
                       '__search': '',
-                      '__selected': '%s,%s' % (
+                      '__ticket_ids': (
                           first_ticket._id,
                           second_ticket._id),
                       'status': 'accepted',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5207de0e/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 7cde33e..dc14459 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -12,6 +12,7 @@ from itertools import ifilter
 import pkg_resources
 from tg import expose, validate, redirect, flash, url, config
 from tg.decorators import with_trailing_slash, without_trailing_slash
+from paste.deploy.converters import aslist
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request, response
 from formencode import validators
@@ -737,7 +738,7 @@ class RootController(BaseController):
     @require_post()
     def update_tickets(self, **post_data):
         tickets = TM.Ticket.query.find(dict(
-                _id={'$in':[ObjectId(id) for id in post_data['__selected'].split(',')]},
+                _id={'$in':[ObjectId(id) for id in aslist(post_data['__ticket_ids'])]},
                 app_config_id=c.app.config._id)).all()
         for ticket in tickets:
             require_access(ticket, 'update')
@@ -802,14 +803,6 @@ class RootController(BaseController):
         flash('Updated {} ticket{}'.format(count, 's' if count != 1 else ''), 'ok')
         redirect('edit/' + post_data['__search'])
 
-# tickets
-# open tickets
-# closed tickets
-# new tickets in the last 7/14/30 days
-# of comments on tickets
-# of new comments on tickets in 7/14/30
-# of ticket changes in the last 7/14/30
-
     def tickets_since(self, when=None):
         count = 0
         if when:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5207de0e/ForgeTracker/forgetracker/widgets/resources/js/mass-edit.js
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/resources/js/mass-edit.js b/ForgeTracker/forgetracker/widgets/resources/js/mass-edit.js
index f9ae973..9be18bb 100644
--- a/ForgeTracker/forgetracker/widgets/resources/js/mass-edit.js
+++ b/ForgeTracker/forgetracker/widgets/resources/js/mass-edit.js
@@ -17,6 +17,8 @@ $(function(){
             return false;
         }
 
-        $('#id_selected').val($checked.map(function(){ return this.name; }).get().join(','));
+        $checked.each(function() {
+            $('#update-values').append('<input type="hidden" name="__ticket_ids" value="'+$(this).val()+'"/>');
+        });
     });
 });