allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/2] allura git commit: [#8193] Include rate limiting on forum topics, fix minor tickets UI bug
Date Thu, 08 Mar 2018 20:43:28 GMT
[#8193] Include rate limiting on forum topics, fix minor tickets UI bug


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

Branch: refs/heads/master
Commit: 334868b5f2f86c0087dd08410486ed033442679c
Parents: 5359a3b
Author: Kenton Taylor <ktaylor@slashdotmedia.com>
Authored: Thu Mar 8 13:37:38 2018 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Thu Mar 8 15:37:49 2018 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py                    | 4 ++--
 Allura/allura/model/artifact.py                         | 1 +
 Allura/allura/tests/functional/test_discuss.py          | 9 +++++----
 Allura/development.ini                                  | 1 +
 ForgeDiscussion/forgediscussion/controllers/root.py     | 1 +
 ForgeTracker/forgetracker/templates/tracker/ticket.html | 7 ++++---
 6 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/334868b5/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index ba31409..100ce44 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -209,7 +209,7 @@ class ThreadController(BaseController, FeedController):
     @utils.AntiSpam.validate('Spambot protection engaged')
     def post(self, **kw):
         require_access(self.thread, 'post')
-        self.rate_limit(M.Post, "Comment", redir='..')
+        self.rate_limit(M.Post, "Comment", redir=request.referrer)
         if self.thread.ref:
             require_access(self.thread.ref.artifact, 'post')
         kw = self.W.edit_post.to_python(kw, None)
@@ -345,7 +345,7 @@ class PostController(BaseController):
     @require_post(redir='.')
     def reply(self, file_info=None, **kw):
         require_access(self.thread, 'post')
-        self.rate_limit(M.Post, "Comment", redir='..')
+        self.rate_limit(M.Post, "Comment", redir=request.referrer)
         kw = self.W.edit_post.to_python(kw, None)
         p = self.thread.add_post(parent_id=self.post._id, **kw)
         p.add_multiple_attachments(file_info)

http://git-wip-us.apache.org/repos/asf/allura/blob/334868b5/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 30836f1..7933e7f 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -646,6 +646,7 @@ class VersionedArtifact(Artifact):
         if 'user' in kwargs:
             def distinct_artifacts_by_user():
                 # count distinct items, not total (e.g. many edits to a single wiki page
doesn't count against you)
+                # query history here, as regular base artifacts have no author information
                 HC = cls.__mongometa__.history_class
                 artifacts = HC.query.find({'author.id': kwargs['user']._id}).distinct('artifact_id')
                 """

http://git-wip-us.apache.org/repos/asf/allura/blob/334868b5/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 8f3c968..50eecd6 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -134,10 +134,11 @@ class TestDiscuss(TestDiscussBase):
     def test_rate_limit(self):
         with h.push_config(config, **{'allura.rate_limits_per_user': '{"3600": 2}'}):
             for i in range(0, 2):
-                self._make_post('This is a post {}'.format(i))
-            with assert_raises(AppError):
-                self._make_post('This is a post that should fail.')
-            return 'foo'
+                r = self._make_post('This is a post {}'.format(i))
+                assert 'rate limit exceeded' not in r.body
+
+            r = self._make_post('This is a post that should fail.')
+            assert 'rate limit exceeded' in r.body
 
     def test_permissions(self):
         thread_url = self._thread_link()

http://git-wip-us.apache.org/repos/asf/allura/blob/334868b5/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index e43be7d..0aa0bcd 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -529,6 +529,7 @@ forgemail.domain = .in.localhost
 ; Number of different wiki pages, tickets, etc that a user can create or edit, per time period,
across all projects
 ; Keys are number of seconds, values are max number allowed until that time period is reached
 ; NOTE: wiki pages include the default "Home" page created for the user-project and any other
projects created by the user
+; NOTE: allura.rate_limits* cover posts to threads across all tools.
 ;forgewiki.rate_limits_per_user =    {"60": 3, "120": 3, "900": 5, "1800": 7, "3600": 10,
"7200": 15, "86400": 20, "604800": 50, "2592000": 200}
 ;forgetracker.rate_limits_per_user = {"60": 1, "120": 3, "900": 5, "1800": 7, "3600": 10,
"7200": 15, "86400": 20, "604800": 50, "2592000": 200}
 ;forgeblog.rate_limits_per_user =    {"60": 1, "120": 3, "900": 5, "1800": 7, "3600": 10,
"7200": 15, "86400": 20, "604800": 50, "2592000": 200}

http://git-wip-us.apache.org/repos/asf/allura/blob/334868b5/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 4b35254..176156f 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -123,6 +123,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
     @validate(W.new_topic, error_handler=create_topic)
     @AntiSpam.validate('Spambot protection engaged')
     def save_new_topic(self, subject=None, text=None, forum=None, **kw):
+        self.rate_limit(model.ForumPost, 'Topic creation', request.referer)
         discussion = model.Forum.query.get(
             app_config_id=c.app.config._id,
             shortname=forum)

http://git-wip-us.apache.org/repos/asf/allura/blob/334868b5/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index 8665611..2895829 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -189,7 +189,7 @@
           var discussion_holder = $('#discussion_holder');
           var ticket_content = $('#ticket_content');
           var title_holder = $('h2.dark');
-          var original_title = title_holder.text();
+          var original_title = title_holder.html();
           var title_actions = title_holder.find('small');
           var vote = $('#vote');
 
@@ -218,7 +218,8 @@
             $(this).trigger('editTicket');
             return false;
           });
-          if ($('div > div.error').hasClass('error')){
+          var flashErrors = $('div > div.error');
+          if (flashErrors.hasClass('error') && flashErrors.html().indexOf('rate limit')
< 0){
             $('a.edit_ticket').click();
           }
           $('a.cancel_form').click(function () {
@@ -226,7 +227,7 @@
             view_holder.show();
             discussion_holder.show();
             ticket_content.show();
-            title_holder.text(original_title);
+            title_holder.html(original_title);
             title_actions.appendTo(title_holder);
             title_actions.show();
             vote.show();


Mime
View raw message