Skip to content

Commit

Permalink
Update extras API to return canPublish using document_acl table
Browse files Browse the repository at this point in the history
Close #253
  • Loading branch information
karenc committed Sep 17, 2014
1 parent ee74c12 commit fc6e38a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
17 changes: 5 additions & 12 deletions cnxarchive/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,8 @@ def get_collection_tree(collection_ident, cursor):


def get_module_can_publish(cursor, id):
cursor.execute('''
SELECT submitter, authors, maintainers, licensors
FROM latest_modules m
WHERE m.uuid = %s''', [id])
users = set([])
for role_users in cursor.fetchone():
if role_users:
if not isinstance(role_users, list):
role_users = [role_users]
for user in role_users:
users.add(user)
return list(users)
cursor.execute("""
SELECT DISTINCT user_id
FROM document_acl
WHERE uuid = %s AND permission = 'publish'""", (id,))
return [i[0] for i in cursor.fetchall()]
2 changes: 0 additions & 2 deletions cnxarchive/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,6 @@ def test_get_extra_no_allowable_types(self):
u'downloads': [],
u'isLatest': False,
u'canPublish': [u'1df3bab1-1dc7-4017-9b3a-960a87e706b1',
u'9366c786-e3c8-4960-83d4-aec1269ac5e5',
u'e5a07af6-09b9-4b74-aa7a-b7510bee90b8']
})

Expand Down Expand Up @@ -1056,7 +1055,6 @@ def test_extra_w_utf8_characters(self):
output['canPublish'].sort()
self.assertEqual(output, {
u'canPublish': [u'1df3bab1-1dc7-4017-9b3a-960a87e706b1',
u'9366c786-e3c8-4960-83d4-aec1269ac5e5',
u'e5a07af6-09b9-4b74-aa7a-b7510bee90b8'],
u'isLatest': True,
u'downloads': [{
Expand Down

0 comments on commit fc6e38a

Please sign in to comment.