You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2018/02/27 22:27:52 UTC
allura git commit: fixup! [#8189] Adds testing util script to
populate lots of forum topics
Repository: allura
Updated Branches:
refs/heads/kt/8189 5853afcbb -> 935f42d7c
fixup! [#8189] Adds testing util script to populate lots of forum topics
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/935f42d7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/935f42d7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/935f42d7
Branch: refs/heads/kt/8189
Commit: 935f42d7cd0a0557cae1ac800cb0772bf2018168
Parents: 5853afc
Author: Kenton Taylor <kt...@slashdotmedia.com>
Authored: Tue Feb 27 17:27:19 2018 -0500
Committer: Kenton Taylor <kt...@slashdotmedia.com>
Committed: Tue Feb 27 17:27:19 2018 -0500
----------------------------------------------------------------------
Allura/allura/lib/widgets/discuss.py | 3 +
.../033-change-comment-anon-permissions.py | 66 --------------------
.../perf/033-change-comment-anon-permissions.py | 66 ++++++++++++++++++++
3 files changed, 69 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/935f42d7/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 0a7e8b9..7afdac4 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -221,6 +221,9 @@ class SubscriptionForm(ew.SimpleForm):
class fields(ew_core.NameList):
page_list = ffw.PageList()
page_size = ffw.PageSize()
+
+ # Careful! using the same name as the prop on the model will invoke the RelationalProperty,
+ # causing all related entities to be (re)fetched.
_threads = _ThreadsTable()
def resources(self):
http://git-wip-us.apache.org/repos/asf/allura/blob/935f42d7/scripts/migrations/033-change-comment-anon-permissions.py
----------------------------------------------------------------------
diff --git a/scripts/migrations/033-change-comment-anon-permissions.py b/scripts/migrations/033-change-comment-anon-permissions.py
deleted file mode 100644
index b5a710c..0000000
--- a/scripts/migrations/033-change-comment-anon-permissions.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import sys
-import logging
-from ming.orm import ThreadLocalORMSession, session
-from pylons import tmpl_context as c
-from allura import model as M
-from forgediscussion.model import ForumPost
-from allura.lib import utils, security
-from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, ArgumentTypeError
-
-
-log = logging.getLogger(__name__)
-
-
-def arguments():
- parser = ArgumentParser(description="Args for changing anon comment permissions",
- formatter_class=ArgumentDefaultsHelpFormatter, )
- parser.add_argument('shortname', help="shortname of project to change perms on")
- parser.add_argument('toolname', help="toolname to change perms on")
-
- args = parser.parse_args()
- return args
-
-
-def main():
- args = arguments()
-
- c.project = None # to avoid error in Artifact.__mongometa__.before_save
- project = M.Project.query.get(shortname=args.shortname)
- tool = project.app_config_by_tool_type(args.toolname)
-
- for chunk in utils.chunked_find(ForumPost, {'app_config_id':tool._id}):
- for p in chunk:
- has_access = bool(security.has_access(p, 'moderate', M.User.anonymous()))
-
- if has_access:
- anon_role_id = None
- for acl in p.acl:
- # find the anon moderate acl
- if acl.permission == 'moderate' and acl.access=='ALLOW':
- anon_role_id = acl.role_id
-
- if anon_role_id:
- print "revoking anon moderate privelege for '{}'".format(p._id)
- security.simple_revoke(p.acl, anon_role_id, 'moderate')
- session(p).flush(p)
-
-
-if __name__ == '__main__':
- main()
http://git-wip-us.apache.org/repos/asf/allura/blob/935f42d7/scripts/perf/033-change-comment-anon-permissions.py
----------------------------------------------------------------------
diff --git a/scripts/perf/033-change-comment-anon-permissions.py b/scripts/perf/033-change-comment-anon-permissions.py
new file mode 100644
index 0000000..b5a710c
--- /dev/null
+++ b/scripts/perf/033-change-comment-anon-permissions.py
@@ -0,0 +1,66 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+import logging
+from ming.orm import ThreadLocalORMSession, session
+from pylons import tmpl_context as c
+from allura import model as M
+from forgediscussion.model import ForumPost
+from allura.lib import utils, security
+from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, ArgumentTypeError
+
+
+log = logging.getLogger(__name__)
+
+
+def arguments():
+ parser = ArgumentParser(description="Args for changing anon comment permissions",
+ formatter_class=ArgumentDefaultsHelpFormatter, )
+ parser.add_argument('shortname', help="shortname of project to change perms on")
+ parser.add_argument('toolname', help="toolname to change perms on")
+
+ args = parser.parse_args()
+ return args
+
+
+def main():
+ args = arguments()
+
+ c.project = None # to avoid error in Artifact.__mongometa__.before_save
+ project = M.Project.query.get(shortname=args.shortname)
+ tool = project.app_config_by_tool_type(args.toolname)
+
+ for chunk in utils.chunked_find(ForumPost, {'app_config_id':tool._id}):
+ for p in chunk:
+ has_access = bool(security.has_access(p, 'moderate', M.User.anonymous()))
+
+ if has_access:
+ anon_role_id = None
+ for acl in p.acl:
+ # find the anon moderate acl
+ if acl.permission == 'moderate' and acl.access=='ALLOW':
+ anon_role_id = acl.role_id
+
+ if anon_role_id:
+ print "revoking anon moderate privelege for '{}'".format(p._id)
+ security.simple_revoke(p.acl, anon_role_id, 'moderate')
+ session(p).flush(p)
+
+
+if __name__ == '__main__':
+ main()