From 34e3cb1e7de17aa643b5cc0e030ac5dfe9b635d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 13 Jul 2016 15:59:38 +0200 Subject: [PATCH] Management command for refreshing home project permissions. --- pillar/manage.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pillar/manage.py b/pillar/manage.py index 64faa710..25ab1e0f 100755 --- a/pillar/manage.py +++ b/pillar/manage.py @@ -300,6 +300,30 @@ def refresh_project_permissions(): print('Updated %i documents' % result.modified_count) +@manager.command +def refresh_home_project_permissions(): + """Replaces the home project comment node type permissions with proper ones.""" + + proj_coll = app.data.driver.db['projects'] + + from application.modules.blender_cloud import home_project + from application.modules import service + + service.fetch_role_to_group_id_map() + + fake_node_type = home_project.assign_permissions(node_type_comment, + subscriber_methods=[u'GET', u'POST'], + world_methods=[u'GET']) + perms = fake_node_type['permissions'] + + result = proj_coll.update_many( + {'category': 'home', 'node_types.name': 'comment'}, + {'$set': {'node_types.$.permissions': perms}}) + + print('Matched %i documents' % result.matched_count) + print('Updated %i documents' % result.modified_count) + + @manager.command def clear_db(): """Wipes the database