You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/10/14 21:00:09 UTC
[allura] 04/09: [#8336] Remove dead "viewable_by" code (partially
removed way back in [#1279])
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8336
in repository https://gitbox.apache.org/repos/asf/allura.git
commit e9d5046cea9ce1b86b8b2d0ac7ed6760c459a344
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Oct 11 17:13:03 2019 -0400
[#8336] Remove dead "viewable_by" code (partially removed way back in [#1279])
---
Allura/allura/tests/functional/test_feeds.py | 2 +-
Allura/allura/tests/functional/test_rest.py | 2 +-
ForgeImporters/forgeimporters/github/wiki.py | 1 -
.../forgetracker/tests/functional/test_root.py | 2 +-
ForgeWiki/forgewiki/model/wiki.py | 2 +-
ForgeWiki/forgewiki/tests/functional/test_root.py | 64 +++++++++++-----------
ForgeWiki/forgewiki/wiki_main.py | 22 --------
scripts/teamforge-import.py | 1 -
8 files changed, 36 insertions(+), 60 deletions(-)
diff --git a/Allura/allura/tests/functional/test_feeds.py b/Allura/allura/tests/functional/test_feeds.py
index 54416a5..e1e54d5 100644
--- a/Allura/allura/tests/functional/test_feeds.py
+++ b/Allura/allura/tests/functional/test_feeds.py
@@ -70,7 +70,7 @@ class TestFeeds(TestController):
'title': 'Root',
'text': '',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
self.app.get('/wiki/Root/feed.rss')
self.app.get('/wiki/Root/feed.atom')
diff --git a/Allura/allura/tests/functional/test_rest.py b/Allura/allura/tests/functional/test_rest.py
index 8d12950..1ba033b 100644
--- a/Allura/allura/tests/functional/test_rest.py
+++ b/Allura/allura/tests/functional/test_rest.py
@@ -314,7 +314,7 @@ class TestRestHome(TestRestApiBase):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
r = self.api_get('/rest/p/test/wiki/tést/')
assert r.status_int == 200
assert r.json['title'].encode('utf-8') == 'tést', r.json
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 4875501..53093f4 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -231,7 +231,6 @@ class GitHubWikiImporter(ToolImporter):
mod_date = datetime.utcfromtimestamp(commit.committed_date)
wiki_page = WM.Page.upsert(self._convert_page_name(orig_name))
wiki_page.timestamp = wiki_page.mod_date = mod_date
- wiki_page.viewable_by = ['all']
if renamed_orig_name and renamed_to in commit.tree:
wiki_page.title = self._convert_page_name(renamed_orig_name)
wiki_page.text = self.convert_markup(
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 9975c3b..5eb9315 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -977,7 +977,7 @@ class TestFunctionalController(TrackerTestController):
'title': 'aaa',
'text': '',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
self.new_ticket(summary='bbb')
ThreadLocalORMSession.flush_all()
M.MonQTask.run_ready()
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index ed0d4de..a9240c3 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -111,7 +111,7 @@ class Page(VersionedArtifact, ActivityObject):
title = FieldProperty(str)
text = FieldProperty(schema.String, if_missing='')
text_cache = FieldProperty(MarkdownCache)
- viewable_by = FieldProperty([str])
+ viewable_by = FieldProperty(schema.Deprecated)
type_s = 'Wiki'
@property
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 4814688..d79937a 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -187,7 +187,7 @@ class TestRootController(TestController):
'title': 'foo',
'text': 'sometext',
'labels': 'test label',
- 'viewable_by-0.id': 'all'}).follow()
+ }).follow()
assert_in('<a href="/p/test/wiki/search/?q=labels_t:%22test label%22&parser=standard">test label (1)</a>',
response)
@@ -199,7 +199,7 @@ class TestRootController(TestController):
'title': 'foo/bar',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'}).follow()
+ }).follow()
assert 'foo-bar' in response
assert 'foo-bar' in response.request.url
@@ -210,7 +210,7 @@ class TestRootController(TestController):
'title': 'page.dot',
'text': 'text1',
'labels': '',
- 'viewable_by-0.id': 'all'}).follow()
+ }).follow()
assert 'page.dot' in r
def test_subpage_attempt(self):
@@ -221,7 +221,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'text1',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
assert '/p/test/wiki/Home/' in self.app.get('/wiki/tést/Home/')
self.app.get('/wiki/tést/notthere/', status=404)
@@ -233,14 +233,14 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'text1',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
self.app.post(
'/wiki/tést/update',
params={
'title': 'tést',
'text': 'text2',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
response = self.app.get('/wiki/tést/history')
assert 'tést' in response
# two revisions are shown
@@ -265,7 +265,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
self.app.post('/wiki/tést/revert', params=dict(version='1'))
response = self.app.get('/wiki/tést/diff?v1=0&v2=0')
assert 'tést' in response
@@ -359,7 +359,7 @@ class TestRootController(TestController):
'title': 'TEST',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
response = self.app.get('/wiki/TEST/raw')
assert 'TEST' in response
@@ -370,7 +370,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': '',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
response = self.app.post('/wiki/tést/revert', params=dict(version='1'))
assert '.' in response.json['location']
response = self.app.get('/wiki/tést/')
@@ -384,7 +384,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
response = self.app.post('/wiki/tést/revert', params=dict(version='1'))
assert '.' in response.json['location']
response = self.app.get('/wiki/tést/')
@@ -399,7 +399,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
assert_equal(spam_checker.check.call_args[0][0], u'tést\nsometext')
assert 'tést' in response
@@ -410,7 +410,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': '- [ ] checkbox',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
response = self.app.get('/wiki/tést/get_markdown')
assert '- [ ] checkbox' in response
@@ -422,7 +422,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': '- [ ] checkbox',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
response = self.app.post(
'/wiki/tést/update_markdown',
params={
@@ -444,7 +444,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': 'yellow,green',
- 'viewable_by-0.id': 'all'})
+ })
assert 'tést' in response
response = self.app.post(
'/wiki/tést/update',
@@ -452,7 +452,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': 'yellow',
- 'viewable_by-0.id': 'all'})
+ })
assert 'tést' in response
def test_page_label_count(self):
@@ -465,7 +465,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': labels,
- 'viewable_by-0.id': 'all'})
+ })
r = self.app.get('/wiki/browse_tags/')
assert 'results of 100 ' in r
assert '<div class="page_list">' in r
@@ -483,7 +483,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
content = file(__file__).read()
self.app.post('/wiki/tést/attach',
upload_files=[('file_info', 'test_root.py', content)])
@@ -497,7 +497,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
content = file(__file__).read()
self.app.post('/wiki/tést/attach',
upload_files=[('file_info', 'test1.py', content), ('file_info', 'test2.py', content)])
@@ -512,7 +512,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
file_name = 'test_root.py'
file_data = file(__file__).read()
upload = ('file_info', file_name, file_data)
@@ -526,7 +526,7 @@ class TestRootController(TestController):
'title': 'TEST',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
file_name = 'neo-icon-set-454545-256x350.png'
file_path = os.path.join(
allura.__path__[0], 'nf', 'allura', 'images', file_name)
@@ -565,17 +565,17 @@ class TestRootController(TestController):
'title': 'TEST',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
self.app.post('/wiki/aaa/update', params={
'title': 'aaa',
'text': '',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
self.app.post('/wiki/bbb/update', params={
'title': 'bbb',
'text': '',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
h.set_context('test', 'wiki', neighborhood='Projects')
a = model.Page.query.find(dict(title='aaa')).first()
@@ -597,7 +597,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
wiki_page = self.app.get('/wiki/tést/')
assert wiki_page.html.find('div', {'id': 'new_post_holder'})
options_admin = self.app.get(
@@ -616,7 +616,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
wiki_page = self.app.get('/wiki/tést/')
assert wiki_page.html.find('ul', {'class': 'sidebarmenu'})
options_admin = self.app.get(
@@ -638,7 +638,7 @@ class TestRootController(TestController):
'title': 'tést',
'text': 'sometext',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
wiki_page = self.app.get('/wiki/tést/')
assert wiki_page.html.find('div', {'class': 'editbox'})
options_admin = self.app.get(
@@ -670,7 +670,7 @@ class TestRootController(TestController):
'title': 'space page',
'text': '''There is a space in the title!''',
'labels': '',
- 'viewable_by-0.id': 'all'}
+ }
self.app.post('/wiki/space%20page/update', params=params)
self.app.get('/wiki/TEST/')
params = {
@@ -688,7 +688,7 @@ class TestRootController(TestController):
* Here is a link to [attach](TEST/attachment/test_root.py)
''',
'labels': '',
- 'viewable_by-0.id': 'all'}
+ }
self.app.post('/wiki/TEST/update', params=params)
content = file(__file__).read()
self.app.post('/wiki/TEST/attach',
@@ -746,7 +746,7 @@ class TestRootController(TestController):
'title': 'cache',
'text': html,
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
# first request caches html, second serves from cache
r = self.app.get('/wiki/cache/')
r = self.app.get('/wiki/cache/')
@@ -757,12 +757,12 @@ class TestRootController(TestController):
'title': 'aaa',
'text': '111',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
self.app.post('/wiki/bbb/update', params={
'title': 'bbb',
'text': '222',
'labels': '',
- 'viewable_by-0.id': 'all'})
+ })
response = self.app.get('/wiki/browse_pages/')
assert 'aaa' in response
assert 'bbb' in response
@@ -783,7 +783,7 @@ class TestRootController(TestController):
* Handmaid mailto <a href="mailto:yoda@jedi.org">Email Yoda</a>
''',
'labels': '',
- 'viewable_by-0.id': 'all'}
+ }
self.app.post('/wiki/test_mailto/update', params=params)
r = self.app.get('/wiki/test_mailto/')
mailto_links = 0
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index ed1043a..50c80e2 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -325,7 +325,6 @@ The wiki uses [Markdown](%s) syntax.
if p is None:
with h.push_config(c, app=self), h.notifications_disabled(c.project, disabled=not notify):
p = WM.Page.upsert(new_root)
- p.viewable_by = ['all']
p.text = self.default_root_page_text()
p.commit()
@@ -577,8 +576,6 @@ class PageController(BaseController, FeedController):
redirect('.?version=%d' % (version - 1))
else:
redirect('.')
- elif 'all' not in page.viewable_by and c.user.username not in page.viewable_by:
- raise exc.HTTPForbidden(detail="You may not view this page.")
cur = page.version
if cur > 1:
prev = cur - 1
@@ -706,8 +703,6 @@ class PageController(BaseController, FeedController):
@require_post()
def update(self, title=None, text=None,
labels=None,
- viewable_by=None,
- new_viewable_by=None,
subscribe=False,
**kw):
activity_verb = 'created'
@@ -719,7 +714,6 @@ class PageController(BaseController, FeedController):
if not self.page:
# the page doesn't exist yet, so create it
self.page = WM.Page.upsert(self.title)
- self.page.viewable_by = ['all']
else:
require_access(self.page, 'edit')
activity_verb = 'modified'
@@ -750,22 +744,6 @@ class PageController(BaseController, FeedController):
notification_tasks.send_usermentions_notification.post(self.page.index_id(), text, old_text)
g.director.create_activity(c.user, activity_verb, self.page,
related_nodes=[c.project], tags=['wiki'])
- if new_viewable_by:
- if new_viewable_by == 'all':
- self.page.viewable_by.append('all')
- else:
- user = c.project.user_in_project(str(new_viewable_by))
- if user:
- self.page.viewable_by.append(user.username)
- if viewable_by:
- for u in viewable_by:
- if u.get('delete'):
- if u['id'] == 'all':
- self.page.viewable_by.remove('all')
- else:
- user = M.User.by_username(str(u['id']))
- if user:
- self.page.viewable_by.remove(user.username)
redirect('../' + h.really_unicode(self.page.title)
.encode('utf-8') + ('/' if not name_conflict else '/edit'))
diff --git a/scripts/teamforge-import.py b/scripts/teamforge-import.py
index aed92cd..9e7ba6b 100644
--- a/scripts/teamforge-import.py
+++ b/scripts/teamforge-import.py
@@ -459,7 +459,6 @@ def import_wiki(project, pid, nbhd):
globals = WM.Globals(
app_config_id=wiki_app.config._id, root=page_data.title)
p = WM.Page.upsert(page_data.title)
- p.viewable_by = ['all']
p.text = wiki2markdown(content)
# upload attachments
upload_attachments(p, pid, beginning)