From a4047725fd98d67466aa8e1c046c6cb08da8d386 Mon Sep 17 00:00:00 2001 From: iPablo Date: Mon, 16 Nov 2015 13:10:32 +0100 Subject: [PATCH 01/38] Added movements tests, incompletes --- gecoscc/tests.py | 394 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 384 insertions(+), 10 deletions(-) diff --git a/gecoscc/tests.py b/gecoscc/tests.py index 8b89636e..072f4381 100644 --- a/gecoscc/tests.py +++ b/gecoscc/tests.py @@ -278,7 +278,7 @@ def drop_mock_nodes(self): global NODES NODES = {} - def get_dummy_request(self): + def get_dummy_request(self, is_superuser=True): ''' Useful method, returns a typical request, with the same request properties than pyramid add (see gecoscc/__init__) @@ -286,10 +286,17 @@ def get_dummy_request(self): request = testing.DummyRequest() request.db = get_db(request) request.userdb = get_userdb(request) - user = request.db.adminusers.find_one({'is_superuser': True}) - if not user: - user = request.userdb.create_user('test', 'test', 'test@example.com', {'is_superuser': True}) - request.user = request.db.adminusers.find_one({'is_superuser': True}) + if is_superuser is True: + user = request.db.adminusers.find_one({'is_superuser': True}) + if not user: + user = request.userdb.create_user('test', 'test', 'test@example.com', {'is_superuser': True}) + request.user = request.db.adminusers.find_one({'is_superuser': True}) + else: + user = request.db.adminusers.find_one({'is_superuser': False}) + if not user: + user = request.userdb.create_user('test_no_super', 'test_no_super', 'test_no_super@example.com', {'is_superuser': False}) + request.user = request.db.adminusers.find_one({'is_superuser': False}) + return request def dummy_get_request(self, data, schema=None): @@ -317,11 +324,11 @@ def get_dummy_json_post_request(self, data, schema=None): del request.validated['_id'] return request - def get_dummy_json_put_request(self, data, schema=None): + def get_dummy_json_put_request(self, data, schema=None, is_superuser=True): ''' Useful method, returns a typical put request ''' - request = self.get_dummy_request() + request = self.get_dummy_request(is_superuser) request.method = 'PUT' request.errors = Errors() if schema: @@ -558,7 +565,7 @@ def create_domain(self, ou_name, flag): ''' Useful method, create a Domain ''' - data = {'name': 'Domain 1', + data = {'name': ou_name, 'type': 'ou', 'path': '%s,%s' % (flag['path'], flag['_id']), 'master': 'gecos', @@ -579,7 +586,7 @@ def create_node(self, data, api_class, ou_name='OU 1'): return (data, object_api.collection_post()) - def update_node(self, obj, field_name, field_value, api_class): + def update_node(self, obj, field_name, field_value, api_class, is_superuser=True): ''' Useful method, update a node ''' @@ -587,7 +594,7 @@ def update_node(self, obj, field_name, field_value, api_class): obj[field_name].append(field_value) else: obj[field_name] = field_value - request_put = self.get_dummy_json_put_request(obj, api_class.schema_detail) + request_put = self.get_dummy_json_put_request(obj, api_class.schema_detail, is_superuser) api = api_class(request_put) return api.put() @@ -3100,3 +3107,370 @@ def test_30_recalc_command_cert_policy(self, get_cookbook_method, get_cookbook_m self.assertEquals(node_policy, [{u'name': u'cert_ou', u'uri': u'uri_ou'}, {u'name': u'cert_ws', u'uri': u'uri_ws'}]) self.assertNoErrorJobs() + + +# class MovementsTests(BaseGecosTestCase): + +# @mock.patch('gecoscc.api.chef_status.Node') +# @mock.patch('gecoscc.forms.create_chef_admin_user') +# @mock.patch('gecoscc.forms._') +# @mock.patch('gecoscc.utils.isinstance') +# @mock.patch('chef.Node') +# @mock.patch('gecoscc.utils.ChefNode') +# @mock.patch('gecoscc.tasks.get_cookbook') +# @mock.patch('gecoscc.utils.get_cookbook') +# def test_01_printers_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, +# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): +# ''' +# Test 01: +# 1. Check the printers movements work +# ''' +# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + +# # 1 - Create printer +# data, new_printer = self.create_printer('Testprinter') + +# # 2 - Register workstation +# db = self.get_db() +# ou_1 = db.nodes.find_one({'name': 'OU 1'}) +# chef_node_id = CHEF_NODE_ID +# self.register_computer() + +# # 3 - Add printer to workstation and check if it is applied in chef node +# computer = db.nodes.find_one({'name': 'testing'}) +# request = self.dummy_get_request(computer, ComputerResource.schema_detail) +# computer_api = ComputerResource(request) +# computer = computer_api.get() + +# printer_policy = db.policies.find_one({'slug': 'printer_can_view'}) +# computer['policies'] = {unicode(printer_policy['_id']): {'object_related_list': [new_printer['_id']]}} +# policy_path = printer_policy['path'] +# node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) + +# self.assertEqualsObjects(node_policy[0], new_printer, fields=('oppolicy', +# 'model', +# 'uri', +# 'name', +# 'manufacturer')) + +# # 4 - Move printer to the OU path like admin +# printer_update = self.update_node(obj=new_printer, field_name='path', +# field_value=ou_1['path'], api_class=PrinterResource, +# is_superuser=False) + +# # 5 - Checks if the printer has been moved +# self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', +# 'model', +# 'uri', +# 'name', +# 'manufacturer')) +# # 6 - Move printer to the OU path like super admin +# printer_update = self.update_node(obj=new_printer, field_name='path', +# field_value=ou_1['path'], api_class=PrinterResource) + +# # 7 - Checks if the printer has been moved +# self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', +# 'model', +# 'uri', +# 'name', +# 'manufacturer')) + +# self.assertNoErrorJobs() + +# @mock.patch('gecoscc.api.chef_status.Node') +# @mock.patch('gecoscc.forms.create_chef_admin_user') +# @mock.patch('gecoscc.forms._') +# @mock.patch('gecoscc.utils.isinstance') +# @mock.patch('chef.Node') +# @mock.patch('gecoscc.utils.ChefNode') +# @mock.patch('gecoscc.tasks.get_cookbook') +# @mock.patch('gecoscc.utils.get_cookbook') +# def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, +# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): +# ''' +# Test 02: +# 1. Check the shared folder movements work +# ''' +# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + +# # Register admin +# admin_username = 'superuser' +# self.add_admin_user(admin_username) + +# # 1 - Create storage +# db = self.get_db() +# data, new_storage = self.create_storage('shared folder') + +# # 2 - Create OU 2 +# data, ou_2 = self.create_ou('OU 2') + +# # 3 - Create ws and user +# username = 'testuser' +# data, new_user = self.create_user(username) +# self.assertEqualsObjects(data, new_user) + +# db = self.get_db() +# ou_1 = db.nodes.find_one({'name': 'OU 1'}) +# chef_node_id = CHEF_NODE_ID +# self.register_computer() + +# # 4 - Register user in ws +# self.assign_user_to_node(gcc_superusername=admin_username, chef_node_id=chef_node_id, username=username) + +# # 5 - Add storage to user and check if it is applied in chef node +# user = db.nodes.find_one({'name': username}) +# request = self.dummy_get_request(user, UserResource.schema_detail) +# user_api = UserResource(request) +# user = user_api.get() + +# id_computer = user['computers'] +# user['computers'] = [ObjectId(id_computer[0])] + +# storage_policy = db.policies.find_one({'slug': 'storage_can_view'}) + +# user['policies'] = {unicode(storage_policy['_id']): {'object_related_list': [new_storage['_id']]}} +# policy_path = storage_policy['path'] + '.' + username + '.gtkbookmarks' +# node_policy = self.add_and_get_policy(node=user, chef_node_id=chef_node_id, api_class=UserResource, policy_path=policy_path) + +# # 6 - Update storage's URI +# storage_update = self.update_node(obj=new_storage, field_name='path', +# field_value='%s,%s' % (ou_2['path'], ou_2['_id']), api_class=StorageResource, +# is_superuser=False) + +# # 7- Check if the storage has been moved +# # 8 - Move printer to the OU path like admin +# storage_policy = self.update_node(obj=new_storage, field_name='path', +# field_value=ou_1['path'], api_class=StorageResource, +# is_superuser=True) + +# # 9- Check if the storage has been moved + +# self.assertNoErrorJobs() + +# @mock.patch('gecoscc.api.chef_status.Node') +# @mock.patch('gecoscc.forms.create_chef_admin_user') +# @mock.patch('gecoscc.forms._') +# @mock.patch('gecoscc.utils.isinstance') +# @mock.patch('chef.Node') +# @mock.patch('gecoscc.utils.ChefNode') +# @mock.patch('gecoscc.tasks.get_cookbook') +# @mock.patch('gecoscc.utils.get_cookbook') +# def test_03_repository_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, +# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): +# ''' +# Test 03: +# 1. Check the repository movements work +# ''' +# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + +# # 1 - Create printer +# data, new_repository = self.create_repository('Testrepo') + +# # 2 - Register workstation +# db = self.get_db() +# ou_1 = db.nodes.find_one({'name': 'OU 1'}) +# chef_node_id = CHEF_NODE_ID +# self.register_computer() + +# # 3 - Add repository to workstation +# repository_policy = db.policies.find_one({'slug': 'repository_can_view'}) +# policy_path = repository_policy['path'] +# computer = db.nodes.find_one({'name': 'testing'}) +# computer['policies'] = {unicode(repository_policy['_id']): {'object_related_list': [new_repository['_id']]}} +# node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) + +# # 4 - Move repository to the OU path +# printer_update = self.update_node(obj=new_repository, field_name='path', +# field_value=ou_1['path'], api_class=RepositoryResource, +# is_superuser=False) + +# # 5 - Checks if the repository has been moved + +# # 6 - Move repository to the OU path like super admin +# printer_update = self.update_node(obj=new_repository, field_name='path', +# field_value=ou_1['path'], api_class=RepositoryResource) + +# # 7 - Checks if the repository has been moved + +# self.assertNoErrorJobs() + +# @mock.patch('gecoscc.api.chef_status.Node') +# @mock.patch('gecoscc.forms.create_chef_admin_user') +# @mock.patch('gecoscc.forms._') +# @mock.patch('gecoscc.utils.isinstance') +# @mock.patch('chef.Node') +# @mock.patch('gecoscc.utils.ChefNode') +# @mock.patch('gecoscc.tasks.get_cookbook') +# @mock.patch('gecoscc.utils.get_cookbook') +# def test_04_groups_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, +# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): +# ''' +# Test 04: +# 1. Check the groups movements work +# ''' +# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + +# # 1- Create a group +# data, new_group = self.create_group('testgroup') + +# # 2 - Register a workstation +# db = self.get_db() +# ou_1 = db.nodes.find_one({'name': 'OU 1'}) +# self.register_computer() +# computer = db.nodes.find_one({'name': 'testing'}) + +# # 3 - Assign group to computer +# self.assign_group_to_node(node_name=computer['name'], api_class=ComputerResource, group=new_group) + +# # Check if group's node is update in node chef +# group = db.nodes.find_one({'name': 'testgroup'}) +# self.assertEqual(group['members'][0], computer['_id']) + +# # 4 - move group to the OU path +# group_update = self.update_node(obj=new_group, field_name='path', +# field_value=ou_1['path'], api_class=GroupResource, +# is_superuser=False) +# # 5 - Check if the groups has been moved + +# # 6 - move group to the OU path like admin +# group_update = self.update_node(obj=new_group, field_name='path', +# field_value=ou_1['path'], api_class=GroupResource, +# is_superuser=True) + +# # 7 - Check if the groups has been moved + +# self.assertNoErrorJobs() + +# @mock.patch('gecoscc.api.chef_status.Node') +# @mock.patch('gecoscc.forms.create_chef_admin_user') +# @mock.patch('gecoscc.forms._') +# @mock.patch('gecoscc.utils.isinstance') +# @mock.patch('chef.Node') +# @mock.patch('gecoscc.utils.ChefNode') +# @mock.patch('gecoscc.tasks.get_cookbook') +# @mock.patch('gecoscc.utils.get_cookbook') +# def test_05_groups_movements_domain(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, +# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): +# ''' +# Test 05: +# 1. Check the groups movements work +# ''' +# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + +# # 1- Create a group +# data, new_group = self.create_group('testgroup') + +# # 2 - Register a workstation +# db = self.get_db() +# self.register_computer() +# computer = db.nodes.find_one({'name': 'testing'}) + +# # 3 - Assign group to computer +# self.assign_group_to_node(node_name=computer['name'], api_class=ComputerResource, group=new_group) + +# # Check if group's node is update in node chef +# group = db.nodes.find_one({'name': 'testgroup'}) +# self.assertEqual(group['members'][0], computer['_id']) + +# # 4 - Create domain +# data = {'name': 'Flag', +# 'type': 'ou', +# 'path': 'root', +# 'source': 'gecos'} + +# request_post = self.get_dummy_json_post_request(data, OrganisationalUnitResource.schema_detail) +# ou_api = OrganisationalUnitResource(request_post) +# flag_new = ou_api.collection_post() + +# data, domain = self.create_domain('Domain 2', flag_new) + +# # 5 - move group to the OU path +# group_update = self.update_node(obj=new_group, field_name='path', +# field_value=domain['path'], api_class=GroupResource, +# is_superuser=True) + +# # 6 - Check if the groups has been moved + +# self.assertNoErrorJobs() + +# @mock.patch('gecoscc.api.chef_status.Node') +# @mock.patch('gecoscc.forms.create_chef_admin_user') +# @mock.patch('gecoscc.forms._') +# @mock.patch('gecoscc.utils.isinstance') +# @mock.patch('chef.Node') +# @mock.patch('gecoscc.utils.ChefNode') +# @mock.patch('gecoscc.tasks.get_cookbook') +# @mock.patch('gecoscc.utils.get_cookbook') +# def test_06_OUs_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, +# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): +# ''' +# Test 06: +# 1. Check the ous movements work +# ''' +# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + +# # 1- Create OU 2 +# data, ou_2 = self.create_ou('OU 2', 'OU 1') + +# # 2 - Register a workstation +# db = self.get_db() +# self.register_computer(ou_name=ou_2['name']) + +# ou_1 = db.nodes.find_one({'name': 'OU 1'}) +# # 3 - Move OU 2 to OU 1 path +# ou_moved = self.update_node(obj=ou_2, field_name='path', +# field_value=ou_1['path'], api_class=OrganisationalUnitResource, +# is_superuser=False) + +# # 7- Check if the storage has been moved + +# # 8 - Move printer to the OU path like admin +# ou_moved = self.update_node(obj=ou_2, field_name='path', +# field_value=ou_1['path'], api_class=OrganisationalUnitResource, +# is_superuser=True) + +# # 9- Check if the storage has been moved + +# self.assertNoErrorJobs() + +# @mock.patch('gecoscc.api.chef_status.Node') +# @mock.patch('gecoscc.forms.create_chef_admin_user') +# @mock.patch('gecoscc.forms._') +# @mock.patch('gecoscc.utils.isinstance') +# @mock.patch('chef.Node') +# @mock.patch('gecoscc.utils.ChefNode') +# @mock.patch('gecoscc.tasks.get_cookbook') +# @mock.patch('gecoscc.utils.get_cookbook') +# def test_07_OUs_movements_domain(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, +# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): +# ''' +# Test 07: +# 1. Check the ous movements work +# ''' +# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + +# # 1 - Create domain +# data = {'name': 'Flag', +# 'type': 'ou', +# 'path': 'root', +# 'source': 'gecos'} + +# request_post = self.get_dummy_json_post_request(data, OrganisationalUnitResource.schema_detail) +# ou_api = OrganisationalUnitResource(request_post) +# flag_new = ou_api.collection_post() + +# data, domain = self.create_domain('Domain 2', flag_new) + +# # 2 - Register a workstation +# db = self.get_db() +# ou_1 = db.nodes.find_one({'name': 'OU 1'}) +# self.register_computer(ou_name=ou_1['name']) + +# # 3 - Move OU 1 to Domain path +# ou_moved = self.update_node(obj=ou_1, field_name='path', +# field_value=domain['path'], api_class=OrganisationalUnitResource, +# is_superuser=True) + +# # 9- Check if the storage has been moved + +# self.assertNoErrorJobs() From e778504c90f6af677a5142df0d49bb8843a58b0e Mon Sep 17 00:00:00 2001 From: iPablo Date: Mon, 16 Nov 2015 13:18:49 +0100 Subject: [PATCH 02/38] Uncomment text --- gecoscc/tests.py | 729 +++++++++++++++++++++++------------------------ 1 file changed, 364 insertions(+), 365 deletions(-) diff --git a/gecoscc/tests.py b/gecoscc/tests.py index 072f4381..b278c21d 100644 --- a/gecoscc/tests.py +++ b/gecoscc/tests.py @@ -3108,369 +3108,368 @@ def test_30_recalc_command_cert_policy(self, get_cookbook_method, get_cookbook_m self.assertNoErrorJobs() +class MovementsTests(BaseGecosTestCase): -# class MovementsTests(BaseGecosTestCase): - -# @mock.patch('gecoscc.api.chef_status.Node') -# @mock.patch('gecoscc.forms.create_chef_admin_user') -# @mock.patch('gecoscc.forms._') -# @mock.patch('gecoscc.utils.isinstance') -# @mock.patch('chef.Node') -# @mock.patch('gecoscc.utils.ChefNode') -# @mock.patch('gecoscc.tasks.get_cookbook') -# @mock.patch('gecoscc.utils.get_cookbook') -# def test_01_printers_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, -# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): -# ''' -# Test 01: -# 1. Check the printers movements work -# ''' -# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) - -# # 1 - Create printer -# data, new_printer = self.create_printer('Testprinter') - -# # 2 - Register workstation -# db = self.get_db() -# ou_1 = db.nodes.find_one({'name': 'OU 1'}) -# chef_node_id = CHEF_NODE_ID -# self.register_computer() - -# # 3 - Add printer to workstation and check if it is applied in chef node -# computer = db.nodes.find_one({'name': 'testing'}) -# request = self.dummy_get_request(computer, ComputerResource.schema_detail) -# computer_api = ComputerResource(request) -# computer = computer_api.get() - -# printer_policy = db.policies.find_one({'slug': 'printer_can_view'}) -# computer['policies'] = {unicode(printer_policy['_id']): {'object_related_list': [new_printer['_id']]}} -# policy_path = printer_policy['path'] -# node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) - -# self.assertEqualsObjects(node_policy[0], new_printer, fields=('oppolicy', -# 'model', -# 'uri', -# 'name', -# 'manufacturer')) - -# # 4 - Move printer to the OU path like admin -# printer_update = self.update_node(obj=new_printer, field_name='path', -# field_value=ou_1['path'], api_class=PrinterResource, -# is_superuser=False) - -# # 5 - Checks if the printer has been moved -# self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', -# 'model', -# 'uri', -# 'name', -# 'manufacturer')) -# # 6 - Move printer to the OU path like super admin -# printer_update = self.update_node(obj=new_printer, field_name='path', -# field_value=ou_1['path'], api_class=PrinterResource) - -# # 7 - Checks if the printer has been moved -# self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', -# 'model', -# 'uri', -# 'name', -# 'manufacturer')) - -# self.assertNoErrorJobs() - -# @mock.patch('gecoscc.api.chef_status.Node') -# @mock.patch('gecoscc.forms.create_chef_admin_user') -# @mock.patch('gecoscc.forms._') -# @mock.patch('gecoscc.utils.isinstance') -# @mock.patch('chef.Node') -# @mock.patch('gecoscc.utils.ChefNode') -# @mock.patch('gecoscc.tasks.get_cookbook') -# @mock.patch('gecoscc.utils.get_cookbook') -# def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, -# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): -# ''' -# Test 02: -# 1. Check the shared folder movements work -# ''' -# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) - -# # Register admin -# admin_username = 'superuser' -# self.add_admin_user(admin_username) - -# # 1 - Create storage -# db = self.get_db() -# data, new_storage = self.create_storage('shared folder') - -# # 2 - Create OU 2 -# data, ou_2 = self.create_ou('OU 2') - -# # 3 - Create ws and user -# username = 'testuser' -# data, new_user = self.create_user(username) -# self.assertEqualsObjects(data, new_user) - -# db = self.get_db() -# ou_1 = db.nodes.find_one({'name': 'OU 1'}) -# chef_node_id = CHEF_NODE_ID -# self.register_computer() - -# # 4 - Register user in ws -# self.assign_user_to_node(gcc_superusername=admin_username, chef_node_id=chef_node_id, username=username) - -# # 5 - Add storage to user and check if it is applied in chef node -# user = db.nodes.find_one({'name': username}) -# request = self.dummy_get_request(user, UserResource.schema_detail) -# user_api = UserResource(request) -# user = user_api.get() - -# id_computer = user['computers'] -# user['computers'] = [ObjectId(id_computer[0])] - -# storage_policy = db.policies.find_one({'slug': 'storage_can_view'}) - -# user['policies'] = {unicode(storage_policy['_id']): {'object_related_list': [new_storage['_id']]}} -# policy_path = storage_policy['path'] + '.' + username + '.gtkbookmarks' -# node_policy = self.add_and_get_policy(node=user, chef_node_id=chef_node_id, api_class=UserResource, policy_path=policy_path) - -# # 6 - Update storage's URI -# storage_update = self.update_node(obj=new_storage, field_name='path', -# field_value='%s,%s' % (ou_2['path'], ou_2['_id']), api_class=StorageResource, -# is_superuser=False) - -# # 7- Check if the storage has been moved -# # 8 - Move printer to the OU path like admin -# storage_policy = self.update_node(obj=new_storage, field_name='path', -# field_value=ou_1['path'], api_class=StorageResource, -# is_superuser=True) - -# # 9- Check if the storage has been moved - -# self.assertNoErrorJobs() - -# @mock.patch('gecoscc.api.chef_status.Node') -# @mock.patch('gecoscc.forms.create_chef_admin_user') -# @mock.patch('gecoscc.forms._') -# @mock.patch('gecoscc.utils.isinstance') -# @mock.patch('chef.Node') -# @mock.patch('gecoscc.utils.ChefNode') -# @mock.patch('gecoscc.tasks.get_cookbook') -# @mock.patch('gecoscc.utils.get_cookbook') -# def test_03_repository_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, -# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): -# ''' -# Test 03: -# 1. Check the repository movements work -# ''' -# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) - -# # 1 - Create printer -# data, new_repository = self.create_repository('Testrepo') - -# # 2 - Register workstation -# db = self.get_db() -# ou_1 = db.nodes.find_one({'name': 'OU 1'}) -# chef_node_id = CHEF_NODE_ID -# self.register_computer() - -# # 3 - Add repository to workstation -# repository_policy = db.policies.find_one({'slug': 'repository_can_view'}) -# policy_path = repository_policy['path'] -# computer = db.nodes.find_one({'name': 'testing'}) -# computer['policies'] = {unicode(repository_policy['_id']): {'object_related_list': [new_repository['_id']]}} -# node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) - -# # 4 - Move repository to the OU path -# printer_update = self.update_node(obj=new_repository, field_name='path', -# field_value=ou_1['path'], api_class=RepositoryResource, -# is_superuser=False) - -# # 5 - Checks if the repository has been moved - -# # 6 - Move repository to the OU path like super admin -# printer_update = self.update_node(obj=new_repository, field_name='path', -# field_value=ou_1['path'], api_class=RepositoryResource) - -# # 7 - Checks if the repository has been moved - -# self.assertNoErrorJobs() - -# @mock.patch('gecoscc.api.chef_status.Node') -# @mock.patch('gecoscc.forms.create_chef_admin_user') -# @mock.patch('gecoscc.forms._') -# @mock.patch('gecoscc.utils.isinstance') -# @mock.patch('chef.Node') -# @mock.patch('gecoscc.utils.ChefNode') -# @mock.patch('gecoscc.tasks.get_cookbook') -# @mock.patch('gecoscc.utils.get_cookbook') -# def test_04_groups_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, -# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): -# ''' -# Test 04: -# 1. Check the groups movements work -# ''' -# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) - -# # 1- Create a group -# data, new_group = self.create_group('testgroup') - -# # 2 - Register a workstation -# db = self.get_db() -# ou_1 = db.nodes.find_one({'name': 'OU 1'}) -# self.register_computer() -# computer = db.nodes.find_one({'name': 'testing'}) - -# # 3 - Assign group to computer -# self.assign_group_to_node(node_name=computer['name'], api_class=ComputerResource, group=new_group) - -# # Check if group's node is update in node chef -# group = db.nodes.find_one({'name': 'testgroup'}) -# self.assertEqual(group['members'][0], computer['_id']) - -# # 4 - move group to the OU path -# group_update = self.update_node(obj=new_group, field_name='path', -# field_value=ou_1['path'], api_class=GroupResource, -# is_superuser=False) -# # 5 - Check if the groups has been moved - -# # 6 - move group to the OU path like admin -# group_update = self.update_node(obj=new_group, field_name='path', -# field_value=ou_1['path'], api_class=GroupResource, -# is_superuser=True) - -# # 7 - Check if the groups has been moved - -# self.assertNoErrorJobs() - -# @mock.patch('gecoscc.api.chef_status.Node') -# @mock.patch('gecoscc.forms.create_chef_admin_user') -# @mock.patch('gecoscc.forms._') -# @mock.patch('gecoscc.utils.isinstance') -# @mock.patch('chef.Node') -# @mock.patch('gecoscc.utils.ChefNode') -# @mock.patch('gecoscc.tasks.get_cookbook') -# @mock.patch('gecoscc.utils.get_cookbook') -# def test_05_groups_movements_domain(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, -# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): -# ''' -# Test 05: -# 1. Check the groups movements work -# ''' -# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) - -# # 1- Create a group -# data, new_group = self.create_group('testgroup') - -# # 2 - Register a workstation -# db = self.get_db() -# self.register_computer() -# computer = db.nodes.find_one({'name': 'testing'}) - -# # 3 - Assign group to computer -# self.assign_group_to_node(node_name=computer['name'], api_class=ComputerResource, group=new_group) - -# # Check if group's node is update in node chef -# group = db.nodes.find_one({'name': 'testgroup'}) -# self.assertEqual(group['members'][0], computer['_id']) - -# # 4 - Create domain -# data = {'name': 'Flag', -# 'type': 'ou', -# 'path': 'root', -# 'source': 'gecos'} - -# request_post = self.get_dummy_json_post_request(data, OrganisationalUnitResource.schema_detail) -# ou_api = OrganisationalUnitResource(request_post) -# flag_new = ou_api.collection_post() - -# data, domain = self.create_domain('Domain 2', flag_new) - -# # 5 - move group to the OU path -# group_update = self.update_node(obj=new_group, field_name='path', -# field_value=domain['path'], api_class=GroupResource, -# is_superuser=True) - -# # 6 - Check if the groups has been moved - -# self.assertNoErrorJobs() - -# @mock.patch('gecoscc.api.chef_status.Node') -# @mock.patch('gecoscc.forms.create_chef_admin_user') -# @mock.patch('gecoscc.forms._') -# @mock.patch('gecoscc.utils.isinstance') -# @mock.patch('chef.Node') -# @mock.patch('gecoscc.utils.ChefNode') -# @mock.patch('gecoscc.tasks.get_cookbook') -# @mock.patch('gecoscc.utils.get_cookbook') -# def test_06_OUs_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, -# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): -# ''' -# Test 06: -# 1. Check the ous movements work -# ''' -# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) - -# # 1- Create OU 2 -# data, ou_2 = self.create_ou('OU 2', 'OU 1') - -# # 2 - Register a workstation -# db = self.get_db() -# self.register_computer(ou_name=ou_2['name']) - -# ou_1 = db.nodes.find_one({'name': 'OU 1'}) -# # 3 - Move OU 2 to OU 1 path -# ou_moved = self.update_node(obj=ou_2, field_name='path', -# field_value=ou_1['path'], api_class=OrganisationalUnitResource, -# is_superuser=False) - -# # 7- Check if the storage has been moved - -# # 8 - Move printer to the OU path like admin -# ou_moved = self.update_node(obj=ou_2, field_name='path', -# field_value=ou_1['path'], api_class=OrganisationalUnitResource, -# is_superuser=True) - -# # 9- Check if the storage has been moved - -# self.assertNoErrorJobs() - -# @mock.patch('gecoscc.api.chef_status.Node') -# @mock.patch('gecoscc.forms.create_chef_admin_user') -# @mock.patch('gecoscc.forms._') -# @mock.patch('gecoscc.utils.isinstance') -# @mock.patch('chef.Node') -# @mock.patch('gecoscc.utils.ChefNode') -# @mock.patch('gecoscc.tasks.get_cookbook') -# @mock.patch('gecoscc.utils.get_cookbook') -# def test_07_OUs_movements_domain(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, -# isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): -# ''' -# Test 07: -# 1. Check the ous movements work -# ''' -# self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) - -# # 1 - Create domain -# data = {'name': 'Flag', -# 'type': 'ou', -# 'path': 'root', -# 'source': 'gecos'} - -# request_post = self.get_dummy_json_post_request(data, OrganisationalUnitResource.schema_detail) -# ou_api = OrganisationalUnitResource(request_post) -# flag_new = ou_api.collection_post() - -# data, domain = self.create_domain('Domain 2', flag_new) - -# # 2 - Register a workstation -# db = self.get_db() -# ou_1 = db.nodes.find_one({'name': 'OU 1'}) -# self.register_computer(ou_name=ou_1['name']) - -# # 3 - Move OU 1 to Domain path -# ou_moved = self.update_node(obj=ou_1, field_name='path', -# field_value=domain['path'], api_class=OrganisationalUnitResource, -# is_superuser=True) - -# # 9- Check if the storage has been moved - -# self.assertNoErrorJobs() + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_01_printers_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 01: + 1. Check the printers movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + + # 1 - Create printer + data, new_printer = self.create_printer('Testprinter') + + # 2 - Register workstation + db = self.get_db() + ou_1 = db.nodes.find_one({'name': 'OU 1'}) + chef_node_id = CHEF_NODE_ID + self.register_computer() + + # 3 - Add printer to workstation and check if it is applied in chef node + computer = db.nodes.find_one({'name': 'testing'}) + request = self.dummy_get_request(computer, ComputerResource.schema_detail) + computer_api = ComputerResource(request) + computer = computer_api.get() + + printer_policy = db.policies.find_one({'slug': 'printer_can_view'}) + computer['policies'] = {unicode(printer_policy['_id']): {'object_related_list': [new_printer['_id']]}} + policy_path = printer_policy['path'] + node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) + + self.assertEqualsObjects(node_policy[0], new_printer, fields=('oppolicy', + 'model', + 'uri', + 'name', + 'manufacturer')) + + # 4 - Move printer to the OU path like admin + printer_update = self.update_node(obj=new_printer, field_name='path', + field_value=ou_1['path'], api_class=PrinterResource, + is_superuser=False) + + # 5 - Checks if the printer has been moved + self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', + 'model', + 'uri', + 'name', + 'manufacturer')) + # 6 - Move printer to the OU path like super admin + printer_update = self.update_node(obj=new_printer, field_name='path', + field_value=ou_1['path'], api_class=PrinterResource) + + # 7 - Checks if the printer has been moved + self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', + 'model', + 'uri', + 'name', + 'manufacturer')) + + self.assertNoErrorJobs() + + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 02: + 1. Check the shared folder movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + + # Register admin + admin_username = 'superuser' + self.add_admin_user(admin_username) + + # 1 - Create storage + db = self.get_db() + data, new_storage = self.create_storage('shared folder') + + # 2 - Create OU 2 + data, ou_2 = self.create_ou('OU 2') + + # 3 - Create ws and user + username = 'testuser' + data, new_user = self.create_user(username) + self.assertEqualsObjects(data, new_user) + + db = self.get_db() + ou_1 = db.nodes.find_one({'name': 'OU 1'}) + chef_node_id = CHEF_NODE_ID + self.register_computer() + + # 4 - Register user in ws + self.assign_user_to_node(gcc_superusername=admin_username, chef_node_id=chef_node_id, username=username) + + # 5 - Add storage to user and check if it is applied in chef node + user = db.nodes.find_one({'name': username}) + request = self.dummy_get_request(user, UserResource.schema_detail) + user_api = UserResource(request) + user = user_api.get() + + id_computer = user['computers'] + user['computers'] = [ObjectId(id_computer[0])] + + storage_policy = db.policies.find_one({'slug': 'storage_can_view'}) + + user['policies'] = {unicode(storage_policy['_id']): {'object_related_list': [new_storage['_id']]}} + policy_path = storage_policy['path'] + '.' + username + '.gtkbookmarks' + node_policy = self.add_and_get_policy(node=user, chef_node_id=chef_node_id, api_class=UserResource, policy_path=policy_path) + + # 6 - Update storage's URI + storage_update = self.update_node(obj=new_storage, field_name='path', + field_value='%s,%s' % (ou_2['path'], ou_2['_id']), api_class=StorageResource, + is_superuser=False) + + # 7- Check if the storage has been moved + # 8 - Move printer to the OU path like admin + storage_policy = self.update_node(obj=new_storage, field_name='path', + field_value=ou_1['path'], api_class=StorageResource, + is_superuser=True) + + # 9- Check if the storage has been moved + + self.assertNoErrorJobs() + + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_03_repository_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 03: + 1. Check the repository movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + + # 1 - Create printer + data, new_repository = self.create_repository('Testrepo') + + # 2 - Register workstation + db = self.get_db() + ou_1 = db.nodes.find_one({'name': 'OU 1'}) + chef_node_id = CHEF_NODE_ID + self.register_computer() + + # 3 - Add repository to workstation + repository_policy = db.policies.find_one({'slug': 'repository_can_view'}) + policy_path = repository_policy['path'] + computer = db.nodes.find_one({'name': 'testing'}) + computer['policies'] = {unicode(repository_policy['_id']): {'object_related_list': [new_repository['_id']]}} + node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) + + # 4 - Move repository to the OU path + printer_update = self.update_node(obj=new_repository, field_name='path', + field_value=ou_1['path'], api_class=RepositoryResource, + is_superuser=False) + + # 5 - Checks if the repository has been moved + + # 6 - Move repository to the OU path like super admin + printer_update = self.update_node(obj=new_repository, field_name='path', + field_value=ou_1['path'], api_class=RepositoryResource) + + # 7 - Checks if the repository has been moved + + self.assertNoErrorJobs() + + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_04_groups_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 04: + 1. Check the groups movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + + # 1- Create a group + data, new_group = self.create_group('testgroup') + + # 2 - Register a workstation + db = self.get_db() + ou_1 = db.nodes.find_one({'name': 'OU 1'}) + self.register_computer() + computer = db.nodes.find_one({'name': 'testing'}) + + # 3 - Assign group to computer + self.assign_group_to_node(node_name=computer['name'], api_class=ComputerResource, group=new_group) + + # Check if group's node is update in node chef + group = db.nodes.find_one({'name': 'testgroup'}) + self.assertEqual(group['members'][0], computer['_id']) + + # 4 - move group to the OU path + group_update = self.update_node(obj=new_group, field_name='path', + field_value=ou_1['path'], api_class=GroupResource, + is_superuser=False) + # 5 - Check if the groups has been moved + + # 6 - move group to the OU path like admin + group_update = self.update_node(obj=new_group, field_name='path', + field_value=ou_1['path'], api_class=GroupResource, + is_superuser=True) + + # 7 - Check if the groups has been moved + + self.assertNoErrorJobs() + + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_05_groups_movements_domain(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 05: + 1. Check the groups movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + + # 1- Create a group + data, new_group = self.create_group('testgroup') + + # 2 - Register a workstation + db = self.get_db() + self.register_computer() + computer = db.nodes.find_one({'name': 'testing'}) + + # 3 - Assign group to computer + self.assign_group_to_node(node_name=computer['name'], api_class=ComputerResource, group=new_group) + + # Check if group's node is update in node chef + group = db.nodes.find_one({'name': 'testgroup'}) + self.assertEqual(group['members'][0], computer['_id']) + + # 4 - Create domain + data = {'name': 'Flag', + 'type': 'ou', + 'path': 'root', + 'source': 'gecos'} + + request_post = self.get_dummy_json_post_request(data, OrganisationalUnitResource.schema_detail) + ou_api = OrganisationalUnitResource(request_post) + flag_new = ou_api.collection_post() + + data, domain = self.create_domain('Domain 2', flag_new) + + # 5 - move group to the OU path + group_update = self.update_node(obj=new_group, field_name='path', + field_value=domain['path'], api_class=GroupResource, + is_superuser=True) + + # 6 - Check if the groups has been moved + + self.assertNoErrorJobs() + + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_06_OUs_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 06: + 1. Check the ous movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + + # 1- Create OU 2 + data, ou_2 = self.create_ou('OU 2', 'OU 1') + + # 2 - Register a workstation + db = self.get_db() + self.register_computer(ou_name=ou_2['name']) + + ou_1 = db.nodes.find_one({'name': 'OU 1'}) + # 3 - Move OU 2 to OU 1 path + ou_moved = self.update_node(obj=ou_2, field_name='path', + field_value=ou_1['path'], api_class=OrganisationalUnitResource, + is_superuser=False) + + # 7- Check if the storage has been moved + + # 8 - Move printer to the OU path like admin + ou_moved = self.update_node(obj=ou_2, field_name='path', + field_value=ou_1['path'], api_class=OrganisationalUnitResource, + is_superuser=True) + + # 9- Check if the storage has been moved + + self.assertNoErrorJobs() + + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_07_OUs_movements_domain(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 07: + 1. Check the ous movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + + # 1 - Create domain + data = {'name': 'Flag', + 'type': 'ou', + 'path': 'root', + 'source': 'gecos'} + + request_post = self.get_dummy_json_post_request(data, OrganisationalUnitResource.schema_detail) + ou_api = OrganisationalUnitResource(request_post) + flag_new = ou_api.collection_post() + + data, domain = self.create_domain('Domain 2', flag_new) + + # 2 - Register a workstation + db = self.get_db() + ou_1 = db.nodes.find_one({'name': 'OU 1'}) + self.register_computer(ou_name=ou_1['name']) + + # 3 - Move OU 1 to Domain path + ou_moved = self.update_node(obj=ou_1, field_name='path', + field_value=domain['path'], api_class=OrganisationalUnitResource, + is_superuser=True) + + # 9- Check if the storage has been moved + + self.assertNoErrorJobs() From b9d5e541d026b7dfc112f272f569418eeb69af5a Mon Sep 17 00:00:00 2001 From: iPablo Date: Tue, 17 Nov 2015 17:17:22 +0100 Subject: [PATCH 03/38] Printers movements backend --- gecoscc/tasks.py | 7 ++++--- gecoscc/utils.py | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/gecoscc/tasks.py b/gecoscc/tasks.py index 66d5d6a4..b1a321c5 100644 --- a/gecoscc/tasks.py +++ b/gecoscc/tasks.py @@ -29,13 +29,14 @@ from gecoscc.eventsmanager import JobStorage from gecoscc.rules import get_rules, is_user_policy, get_username_chef_format, object_related_list from gecoscc.socks import invalidate_jobs -# It is necessary import here: apply_policies_to_computer and apply_policies_to_user +# It is necessary import here: apply_policies_to_computer, apply_policies_to_printer and apply_policies_to_user from gecoscc.utils import (get_chef_api, get_cookbook, get_filter_nodes_belonging_ou, emiter_police_slug, get_computer_of_user, delete_dotted, to_deep_dict, reserve_node_or_raise, save_node_and_free, NodeBusyException, NodeNotLinked, apply_policies_to_computer, apply_policies_to_user, + apply_policies_to_printer, RESOURCES_RECEPTOR_TYPES, RESOURCES_EMITTERS_TYPES, POLICY_EMITTER_SUBFIX) @@ -868,7 +869,7 @@ def object_moved(self, user, objnew, objold): func = globals()['apply_policies_to_%s' % objnew['type']] except KeyError: raise NotImplementedError - func(self.db.nodes, objnew, user, api, initialize=True, use_celery=False) + func(self.db.nodes, objnew, user, api, initialize=True, use_celery=False, policies_collection=self.db.policies) def object_emiter_deleted(self, user, obj, computers=None): obj_id = unicode(obj['_id']) @@ -993,8 +994,8 @@ def printer_changed(self, user, objnew, objold, computers=None): self.log_action('changed', 'Printer', objnew) def printer_moved(self, user, objnew, objold): + self.object_moved(user, objnew, objold) self.log_action('moved', 'Printer', objnew) - raise NotImplementedError def printer_deleted(self, user, obj, computers=None, direct_deleted=True): self.object_emiter_deleted(user, obj, computers=computers) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index 3133fbbb..3ce09a84 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -460,7 +460,7 @@ def recalc_node_policies(nodes_collection, jobs_collection, computer, auth_user, return (True, 'success') -def apply_policies_to_computer(nodes_collection, computer, auth_user, api=None, initialize=False, use_celery=True): +def apply_policies_to_computer(nodes_collection, computer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): from gecoscc.tasks import object_changed, object_created if use_celery: object_created = object_created.delay @@ -484,7 +484,7 @@ def apply_policies_to_computer(nodes_collection, computer, auth_user, api=None, object_created(auth_user, 'computer', computer, computers=[computer]) -def apply_policies_to_user(nodes_collection, user, auth_user, api=None, initialize=False, use_celery=True): +def apply_policies_to_user(nodes_collection, user, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): from gecoscc.tasks import object_changed, object_created if use_celery: object_created = object_created.delay @@ -513,6 +513,41 @@ def apply_policies_to_user(nodes_collection, user, auth_user, api=None, initiali object_created(auth_user, 'user', user, computers=computers) +def apply_policies_to_printer(nodes_collection, printer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): + from gecoscc.tasks import object_changed, object_created + + if use_celery: + object_created = object_created.delay + object_changed = object_changed.delay + + policy_id = policies_collection.find_one({'slug': 'printer_can_view'}).get('_id') + policy_id = unicode(policy_id) + nodes_with_printer = nodes_collection.find({"policies.%s.object_related_list" % policy_id: {'$in': [unicode(printer['_id'])]}}) + + if nodes_with_printer.count() == 0: + return + + elif auth_user.get('is_superuser', False): + for node in nodes_with_printer: + object_related_list = node['policies'][policy_id].get('object_related_list', []) + is_visible = nodes_collection.find_one({ + '_id': ObjectId(printer['_id']), + 'path': get_filter_nodes_parents_ou(nodes_collection.database, + node['_id'], + printer['_id'])}) + if is_visible is None: + object_related_list.remove(unicode(printer['_id'])) + if not object_related_list: + del node['policies'][policy_id] + else: + node['policies'][policy_id]['object_related_list'] = object_related_list + nodes_collection.update({'_id': node['_id']}, {'$set': {'policies': node['policies']}}) + + object_created(auth_user, 'printer', printer) + + return + + def remove_policies_of_computer(user, computer, auth_user): from gecoscc.tasks import object_deleted computer['user'] = user From 93657e283bc055c4f2a0e7b60bb8abc16e0298a3 Mon Sep 17 00:00:00 2001 From: iPablo Date: Wed, 18 Nov 2015 11:31:04 +0100 Subject: [PATCH 04/38] Fixed movement test: 1, 2, 3 --- gecoscc/tests.py | 84 ++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/gecoscc/tests.py b/gecoscc/tests.py index b278c21d..40c3c0d6 100644 --- a/gecoscc/tests.py +++ b/gecoscc/tests.py @@ -25,6 +25,7 @@ from paste.deploy import loadapp from pymongo import Connection from pyramid import testing +from pyramid.httpexceptions import HTTPForbidden from api.chef_status import USERS_OHAI from gecoscc.api.organisationalunits import OrganisationalUnitResource @@ -3108,6 +3109,7 @@ def test_30_recalc_command_cert_policy(self, get_cookbook_method, get_cookbook_m self.assertNoErrorJobs() + class MovementsTests(BaseGecosTestCase): @mock.patch('gecoscc.api.chef_status.Node') @@ -3144,35 +3146,27 @@ def test_01_printers_movements(self, get_cookbook_method, get_cookbook_method_ta printer_policy = db.policies.find_one({'slug': 'printer_can_view'}) computer['policies'] = {unicode(printer_policy['_id']): {'object_related_list': [new_printer['_id']]}} policy_path = printer_policy['path'] - node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) + self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) - self.assertEqualsObjects(node_policy[0], new_printer, fields=('oppolicy', - 'model', - 'uri', - 'name', - 'manufacturer')) - - # 4 - Move printer to the OU path like admin - printer_update = self.update_node(obj=new_printer, field_name='path', - field_value=ou_1['path'], api_class=PrinterResource, - is_superuser=False) + printer = db.nodes.find_one({'name': 'Testprinter'}) + # 4 - Move printer to the OU path + try: + printer_update = self.update_node(obj=new_printer, field_name='path', + field_value=ou_1['path'], api_class=PrinterResource, + is_superuser=False) + except HTTPForbidden: + printer_update = printer # 5 - Checks if the printer has been moved - self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', - 'model', - 'uri', - 'name', - 'manufacturer')) + self.assertEqual(printer_update['path'], printer['path']) + # 6 - Move printer to the OU path like super admin printer_update = self.update_node(obj=new_printer, field_name='path', - field_value=ou_1['path'], api_class=PrinterResource) + field_value=ou_1['path'], api_class=PrinterResource, + is_superuser=True) # 7 - Checks if the printer has been moved - self.assertEqualsObjects(node_policy[0], printer_update, fields=('oppolicy', - 'model', - 'uri', - 'name', - 'manufacturer')) + self.assertNotEqual(printer_update['path'], printer['path']) self.assertNoErrorJobs() @@ -3202,7 +3196,6 @@ def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_meth # 2 - Create OU 2 data, ou_2 = self.create_ou('OU 2') - # 3 - Create ws and user username = 'testuser' data, new_user = self.create_user(username) @@ -3229,20 +3222,27 @@ def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_meth user['policies'] = {unicode(storage_policy['_id']): {'object_related_list': [new_storage['_id']]}} policy_path = storage_policy['path'] + '.' + username + '.gtkbookmarks' - node_policy = self.add_and_get_policy(node=user, chef_node_id=chef_node_id, api_class=UserResource, policy_path=policy_path) + self.add_and_get_policy(node=user, chef_node_id=chef_node_id, api_class=UserResource, policy_path=policy_path) - # 6 - Update storage's URI - storage_update = self.update_node(obj=new_storage, field_name='path', - field_value='%s,%s' % (ou_2['path'], ou_2['_id']), api_class=StorageResource, - is_superuser=False) + storage = db.nodes.find_one({'name': 'shared folder'}) + # 6 - Move storage + try: + storage_update = self.update_node(obj=new_storage, field_name='path', + field_value=ou_2['path'], api_class=StorageResource, + is_superuser=False) + except HTTPForbidden: + storage_update = storage # 7- Check if the storage has been moved - # 8 - Move printer to the OU path like admin - storage_policy = self.update_node(obj=new_storage, field_name='path', - field_value=ou_1['path'], api_class=StorageResource, + self.assertEqual(storage_update['path'], storage['path']) + + # 8 - Move storage to the OU path like admin + storage_update = self.update_node(obj=new_storage, field_name='path', + field_value=ou_2['path'], api_class=StorageResource, is_superuser=True) # 9- Check if the storage has been moved + self.assertNotEqual(storage_update['path'], storage['path']) self.assertNoErrorJobs() @@ -3255,7 +3255,7 @@ def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_meth @mock.patch('gecoscc.tasks.get_cookbook') @mock.patch('gecoscc.utils.get_cookbook') def test_03_repository_movements(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, - isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): ''' Test 03: 1. Check the repository movements work @@ -3276,20 +3276,26 @@ def test_03_repository_movements(self, get_cookbook_method, get_cookbook_method_ policy_path = repository_policy['path'] computer = db.nodes.find_one({'name': 'testing'}) computer['policies'] = {unicode(repository_policy['_id']): {'object_related_list': [new_repository['_id']]}} - node_policy = self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) + self.add_and_get_policy(node=computer, chef_node_id=chef_node_id, api_class=ComputerResource, policy_path=policy_path) + repository = db.nodes.find_one({'name': 'Testrepo'}) # 4 - Move repository to the OU path - printer_update = self.update_node(obj=new_repository, field_name='path', - field_value=ou_1['path'], api_class=RepositoryResource, - is_superuser=False) - + try: + repository_update = self.update_node(obj=new_repository, field_name='path', + field_value=ou_1['path'], api_class=RepositoryResource, + is_superuser=False) + except HTTPForbidden: + repository_update = repository # 5 - Checks if the repository has been moved + self.assertEqual(repository_update['path'], repository['path']) # 6 - Move repository to the OU path like super admin - printer_update = self.update_node(obj=new_repository, field_name='path', - field_value=ou_1['path'], api_class=RepositoryResource) + repository_update = self.update_node(obj=new_repository, field_name='path', + field_value=ou_1['path'], api_class=RepositoryResource, + is_superuser=True) # 7 - Checks if the repository has been moved + self.assertNotEqual(repository_update['path'], repository['path']) self.assertNoErrorJobs() From 0faadabad8f0633b6191455234b3016cd28aa16c Mon Sep 17 00:00:00 2001 From: iPablo Date: Wed, 18 Nov 2015 11:44:26 +0100 Subject: [PATCH 05/38] Now, emitters objects can be moved (Backend) --- gecoscc/tasks.py | 26 +++++++++++++-------- gecoscc/utils.py | 59 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/gecoscc/tasks.py b/gecoscc/tasks.py index b1a321c5..6d65d5ea 100644 --- a/gecoscc/tasks.py +++ b/gecoscc/tasks.py @@ -29,14 +29,15 @@ from gecoscc.eventsmanager import JobStorage from gecoscc.rules import get_rules, is_user_policy, get_username_chef_format, object_related_list from gecoscc.socks import invalidate_jobs -# It is necessary import here: apply_policies_to_computer, apply_policies_to_printer and apply_policies_to_user +# It is necessary import here: apply_policies_to_computer, apply_policies_to_printer and apply_policies_to_user... from gecoscc.utils import (get_chef_api, get_cookbook, get_filter_nodes_belonging_ou, emiter_police_slug, get_computer_of_user, delete_dotted, to_deep_dict, reserve_node_or_raise, save_node_and_free, NodeBusyException, NodeNotLinked, apply_policies_to_computer, apply_policies_to_user, - apply_policies_to_printer, + apply_policies_to_printer, apply_policies_to_storage, + apply_policies_to_repository, RESOURCES_RECEPTOR_TYPES, RESOURCES_EMITTERS_TYPES, POLICY_EMITTER_SUBFIX) @@ -349,9 +350,16 @@ def has_changed_ws_emitter_policy(self, node, obj_ui, field_chef): return False related_objs = obj_ui for field_value in field_chef_value: - if related_objs['name'] == field_value['name']: + if obj_ui['type'] == 'repository': + field_chef = field_value['repo_name'] + else: + field_chef = field_value['name'] + if related_objs['name'] == field_chef: for attribute in field_value.keys(): - if related_objs[attribute] != field_value[attribute]: + if attribute == 'repo_name': + if related_objs['name'] != field_value[attribute]: + return True + elif related_objs[attribute] != field_value[attribute]: return True return False @@ -1010,8 +1018,8 @@ def storage_changed(self, user, objnew, objold, computers=None): self.log_action('changed', 'Storage', objnew) def storage_moved(self, user, objnew, objold): + self.object_moved(user, objnew, objold) self.log_action('moved', 'Storage', objnew) - raise NotImplementedError def storage_deleted(self, user, obj, computers=None, direct_deleted=True): self.object_emiter_deleted(user, obj, computers=computers) @@ -1019,19 +1027,19 @@ def storage_deleted(self, user, obj, computers=None, direct_deleted=True): def repository_created(self, user, objnew, computers=None): self.object_created(user, objnew, computers=computers) - self.log_action('created', 'Storage', objnew) + self.log_action('created', 'Repository', objnew) def repository_changed(self, user, objnew, objold, computers=None): self.object_changed(user, objnew, objold, computers=computers) - self.log_action('changed', 'Storage', objnew) + self.log_action('changed', 'Repository', objnew) def repository_moved(self, user, objnew, objold): + self.object_moved(user, objnew, objold) self.log_action('moved', 'Repository', objnew) - raise NotImplementedError def repository_deleted(self, user, obj, computers=None, direct_deleted=True): self.object_emiter_deleted(user, obj, computers=computers) - self.log_action('deleted', 'Storage', obj) + self.log_action('deleted', 'Repository', obj) @task_prerun.connect diff --git a/gecoscc/utils.py b/gecoscc/utils.py index 3ce09a84..d6be1b64 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -513,39 +513,74 @@ def apply_policies_to_user(nodes_collection, user, auth_user, api=None, initiali object_created(auth_user, 'user', user, computers=computers) -def apply_policies_to_printer(nodes_collection, printer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): +def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, policy_id, api=None, initialize=False, use_celery=True): + ''' + Checks if a emitter object is within the scope of the objects that is related and then update policies + ''' from gecoscc.tasks import object_changed, object_created if use_celery: object_created = object_created.delay object_changed = object_changed.delay - policy_id = policies_collection.find_one({'slug': 'printer_can_view'}).get('_id') - policy_id = unicode(policy_id) - nodes_with_printer = nodes_collection.find({"policies.%s.object_related_list" % policy_id: {'$in': [unicode(printer['_id'])]}}) + nodes_related_with_obj = nodes_collection.find({"policies.%s.object_related_list" % policy_id: {'$in': [unicode(obj['_id'])]}}) - if nodes_with_printer.count() == 0: + if nodes_related_with_obj.count() == 0: return elif auth_user.get('is_superuser', False): - for node in nodes_with_printer: - object_related_list = node['policies'][policy_id].get('object_related_list', []) + for node in nodes_related_with_obj: is_visible = nodes_collection.find_one({ - '_id': ObjectId(printer['_id']), + '_id': ObjectId(obj['_id']), 'path': get_filter_nodes_parents_ou(nodes_collection.database, node['_id'], - printer['_id'])}) + obj['_id'])}) if is_visible is None: - object_related_list.remove(unicode(printer['_id'])) + object_related_list = node['policies'][policy_id].get('object_related_list', []) + object_related_list.remove(unicode(obj['_id'])) if not object_related_list: del node['policies'][policy_id] else: node['policies'][policy_id]['object_related_list'] = object_related_list nodes_collection.update({'_id': node['_id']}, {'$set': {'policies': node['policies']}}) + obj = nodes_collection.find_one({'_id': node['_id']}) + + if obj['type'] == 'computer': + remove_chef_computer_data(obj, api) + elif obj['type'] == 'user': + computers = get_computer_of_user(nodes_collection, obj) + remove_chef_user_data(obj, computers, api) + + object_created(auth_user, obj['type'], obj) + else: + return + + +def apply_policies_to_printer(nodes_collection, printer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): + ''' + Checks if a printer is within the scope of the objects that is related and then update policies + ''' + policy_id = policies_collection.find_one({'slug': 'printer_can_view'}).get('_id') + policy_id = unicode(policy_id) + apply_policies_to_emitter_object(nodes_collection, printer, auth_user, policy_id, api, initialize, use_celery) + + +def apply_policies_to_repository(nodes_collection, repository, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): + ''' + Checks if a repository is within the scope of the objects that is related and then update policies + ''' + policy_id = policies_collection.find_one({'slug': 'repository_can_view'}).get('_id') + policy_id = unicode(policy_id) + apply_policies_to_emitter_object(nodes_collection, repository, auth_user, policy_id, api, initialize, use_celery) - object_created(auth_user, 'printer', printer) - return +def apply_policies_to_storage(nodes_collection, storage, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): + ''' + Checks if a storage is within the scope of the objects that is related and then update policies + ''' + policy_id = policies_collection.find_one({'slug': 'storage_can_view'}).get('_id') + policy_id = unicode(policy_id) + apply_policies_to_emitter_object(nodes_collection, storage, auth_user, policy_id, api, initialize, use_celery) def remove_policies_of_computer(user, computer, auth_user): From b987aa565fa3cc0329c21fb6bd26572d4c22036d Mon Sep 17 00:00:00 2001 From: iPablo Date: Wed, 18 Nov 2015 17:18:25 +0100 Subject: [PATCH 06/38] Improved code and fixed some details --- gecoscc/api/__init__.py | 55 ++++++++++----- gecoscc/utils.py | 144 ++++++++++++++++++++++++---------------- 2 files changed, 125 insertions(+), 74 deletions(-) diff --git a/gecoscc/api/__init__.py b/gecoscc/api/__init__.py index c737af1f..c566b5bd 100644 --- a/gecoscc/api/__init__.py +++ b/gecoscc/api/__init__.py @@ -31,10 +31,10 @@ visibility_object_related, visibility_group) from gecoscc.i18n import gettext as _ - + import logging logger = logging.getLogger(__name__) - + SAFE_METHODS = ('GET', 'OPTIONS', 'HEAD',) UNSAFE_METHODS = ('POST', 'PUT', 'PATCH', 'DELETE', ) SCHEMA_METHODS = ('POST', 'PUT', ) @@ -202,7 +202,7 @@ def integrity_validation(self, obj, real_obj=None): def pre_save(self, obj, old_obj=None): if old_obj and 'name' in old_obj: obj['name'] = old_obj['name'] - + # Check he policies "object_related_list" attribute if 'policies' in obj: policies = obj['policies'] @@ -210,9 +210,9 @@ def pre_save(self, obj, old_obj=None): # Get the policy policyobj = self.request.db.policies.find_one({"_id": ObjectId(str(policy))}) if policyobj is None: - logger.warning("Unknown policy: %s"%(str(policy))) + logger.warning("Unknown policy: %s" % (str(policy))) else: - # Get the related object collection + # Get the related object collection ro_collection = None if policyobj['slug'] == 'printer_can_view': ro_collection = self.request.db.nodes @@ -225,22 +225,21 @@ def pre_save(self, obj, old_obj=None): elif policyobj['slug'] == 'package_profile_res': ro_collection = self.request.db.software_profiles else: - logger.warning("Unrecognized slug: %s"%(str(policyobj['slug']))) - + logger.warning("Unrecognized slug: %s" % (str(policyobj['slug']))) + # Check the related objects if ro_collection is not None: ro_list = policies[str(policy)]['object_related_list'] for ro_id in ro_list: ro_obj = ro_collection.find_one({"_id": ObjectId(str(ro_id))}) if ro_obj is None: - logger.error("Can't find related object: %s:%s"%(str(policyobj['slug']), str(ro_id))) - self.request.errors.add('body', 'object', "Can't find related object: %s:%s"%(str(policyobj['slug']), str(ro_id))) + logger.error("Can't find related object: %s:%s" % (str(policyobj['slug']), str(ro_id))) + self.request.errors.add('body', 'object', "Can't find related object: %s:%s" % (str(policyobj['slug']), str(ro_id))) return None - - + else: logger.debug("No policies in this object") - + return obj def post_save(self, obj, old_obj=None): @@ -386,9 +385,8 @@ class TreeResourcePaginated(ResourcePaginated): def check_unique_node_name_by_type_at_domain(self, obj): unique = check_unique_node_name_by_type_at_domain(self.request.db.nodes, obj) if not unique: - self.request.errors.add( - 'body', 'name', - "Name must be unique in domain.") + self.request.errors.add('body', 'name', + "Name must be unique in domain.") return unique def integrity_validation(self, obj, real_obj=None): @@ -527,3 +525,30 @@ def get_objects_filter(self): filters.append({'path': get_filter_nodes_parents_ou(self.request.db, ou_id, item_id)}) return filters + + def check_obj_is_related(self, obj): + ''' + Check if the emitter object is related with any object + ''' + if obj['type'] == 'printer': + slug = 'printer_can_view' + elif obj['type'] == 'repository': + slug = 'repository_can_view' + elif obj['type'] == 'storage': + slug == 'storage_can_view' + + policy_id = self.request.db.policies.find_one({'slug': slug}).get('_id') + nodes_related_with_obj = self.request.db.nodes.find({"policies.%s.object_related_list" + % unicode(policy_id): {'$in': [unicode(obj['_id'])]}}) + + if nodes_related_with_obj.count() == 0: + return True + + return False + + def integrity_validation(self, obj, real_obj=None): + result = super(PassiveResourcePaginated, self).integrity_validation( + obj, real_obj) + result = self.request.user.get('is_superuser', False) or self.check_obj_is_related(obj) + + return result diff --git a/gecoscc/utils.py b/gecoscc/utils.py index d6be1b64..5691d0c0 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -194,7 +194,10 @@ def delete_chef_admin_user(api, settings, usrname): return False -def remove_chef_computer_data(computer, api): +def remove_chef_computer_data(computer, api, policy=None): + ''' + Remove computer policies in chef node + ''' node_chef_id = computer.get('node_chef_id', None) if node_chef_id: node = reserve_node_or_raise(node_chef_id, api, 'gcc-remove-computer-data-%s' % random.random()) @@ -202,14 +205,22 @@ def remove_chef_computer_data(computer, api): settings = get_current_registry().settings cookbook_name = settings.get('chef.cookbook_name') cookbook = node.normal.get(cookbook_name) - for mgmt in cookbook.keys(): - if mgmt == USER_MGMT: - continue - cookbook.pop(mgmt) + if policy: + policy_path = policy[1] + policy_field = policy[2] + cookbook[policy_path].pop(policy_field) + else: + for mgmt in cookbook.keys(): + if mgmt == USER_MGMT: + continue + cookbook.pop(mgmt) save_node_and_free(node) -def remove_chef_user_data(user, computers, api): +def remove_chef_user_data(user, computers, api, policy_field_name=None): + ''' + Remove computer policies in chef node + ''' settings = get_current_registry().settings cookbook_name = settings.get('chef.cookbook_name') for computer in computers: @@ -217,19 +228,30 @@ def remove_chef_user_data(user, computers, api): if node_chef_id: node = reserve_node_or_raise(node_chef_id, api, 'gcc-remove-user-data-%s' % random.random()) if node: - try: - user_mgmt = node.normal.get_dotted('%s.%s' % (cookbook_name, USER_MGMT)) - for policy in user_mgmt: - try: - users = user_mgmt.get(policy).get('users') - if not users: - continue - users.pop(user['name']) - except KeyError: + if policy_field_name: + try: + user_mgmt = node.normal.get_dotted('%s.%s' % (cookbook_name + '.' + USER_MGMT, policy_field_name)) + users = user_mgmt.get('users') + if not users: continue - save_node_and_free(node) - except KeyError: - save_node_and_free(node) + users.pop(user['name']) + save_node_and_free(node) + except KeyError: + save_node_and_free(node) + else: + try: + user_mgmt = node.normal.get_dotted('%s.%s' % (cookbook_name, USER_MGMT)) + for policy in user_mgmt: + try: + users = user_mgmt.get(policy).get('users') + if not users: + continue + users.pop(user['name']) + except KeyError: + continue + save_node_and_free(node) + except KeyError: + save_node_and_free(node) def reserve_node_or_raise(node_id, api, controller_requestor='gcc', attempts=1): @@ -407,11 +429,7 @@ def visibility_object_related(db, obj): '_id': ObjectId(object_related_id) }) else: - is_visible = db.nodes.find_one( - {'_id': ObjectId(object_related_id), - 'path': get_filter_nodes_parents_ou(db, - ou_id, - obj_id)}) + is_visible = is_visible_query(db.nodes, object_related_id, ou_id, obj_id) if is_visible: object_related_visible.append(object_related_id) if object_related_list != object_related_visible: @@ -421,8 +439,7 @@ def visibility_object_related(db, obj): del policies[unicode(emitter_policy_id)] have_updated = True if have_updated: - db.nodes.update({'_id': obj_id}, {'$set': {'policies': policies}}) - obj = db.nodes.find_one({'_id': obj_id}) + obj = update_collection_and_get_obj(db.nodes, obj_id, policies) return obj @@ -460,6 +477,21 @@ def recalc_node_policies(nodes_collection, jobs_collection, computer, auth_user, return (True, 'success') +def is_visible_query(nodes_collection, object_related_id, ou_id, obj_id): + return nodes_collection.find_one({'_id': ObjectId(object_related_id), + 'path': get_filter_nodes_parents_ou(nodes_collection.database, + ou_id, + obj_id)}) + + +def update_collection_and_get_obj(nodes_collection, obj_id, policies_value): + ''' + Updates the node policy and return the obj + ''' + nodes_collection.update({'_id': obj_id}, {'$set': {'policies': policies_value}}) + return nodes_collection.find_one({'_id': obj_id}) + + def apply_policies_to_computer(nodes_collection, computer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): from gecoscc.tasks import object_changed, object_created if use_celery: @@ -513,12 +545,15 @@ def apply_policies_to_user(nodes_collection, user, auth_user, api=None, initiali object_created(auth_user, 'user', user, computers=computers) -def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, policy_id, api=None, initialize=False, use_celery=True): +def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api=None, initialize=False, use_celery=True, policies_collection=None): ''' Checks if a emitter object is within the scope of the objects that is related and then update policies ''' from gecoscc.tasks import object_changed, object_created + policy = policies_collection.find_one({'slug': slug}) + policy_id = unicode(policy.get('_id')) + if use_celery: object_created = object_created.delay object_changed = object_changed.delay @@ -528,59 +563,50 @@ def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, policy_id if nodes_related_with_obj.count() == 0: return - elif auth_user.get('is_superuser', False): - for node in nodes_related_with_obj: - is_visible = nodes_collection.find_one({ - '_id': ObjectId(obj['_id']), - 'path': get_filter_nodes_parents_ou(nodes_collection.database, - node['_id'], - obj['_id'])}) - if is_visible is None: - object_related_list = node['policies'][policy_id].get('object_related_list', []) - object_related_list.remove(unicode(obj['_id'])) - if not object_related_list: - del node['policies'][policy_id] - else: - node['policies'][policy_id]['object_related_list'] = object_related_list - nodes_collection.update({'_id': node['_id']}, {'$set': {'policies': node['policies']}}) - obj = nodes_collection.find_one({'_id': node['_id']}) + for node in nodes_related_with_obj: + is_visible = is_visible_query(nodes_collection, object_related_id=obj['_id'], + ou_id=node['path'].split(',')[-1], obj_id=obj['_id']) - if obj['type'] == 'computer': - remove_chef_computer_data(obj, api) - elif obj['type'] == 'user': - computers = get_computer_of_user(nodes_collection, obj) - remove_chef_user_data(obj, computers, api) + if is_visible is None: + object_related_list = node['policies'][policy_id].get('object_related_list', []) + object_related_list.remove(unicode(obj['_id'])) - object_created(auth_user, obj['type'], obj) - else: - return + if not object_related_list: + del node['policies'][policy_id] + else: + node['policies'][policy_id]['object_related_list'] = object_related_list + obj = update_collection_and_get_obj(nodes_collection, node['_id'], node['policies']) + + if obj['type'] == 'computer': + policy = policy['path'].split('.')[:3] + remove_chef_computer_data(obj, api, policy) + elif obj['type'] == 'user': + computers = get_computer_of_user(nodes_collection, obj) + policy_field_name = policy['path'].split('.')[2] + remove_chef_user_data(obj, computers, api, policy_field_name) + + object_created(auth_user, obj['type'], obj) def apply_policies_to_printer(nodes_collection, printer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): ''' Checks if a printer is within the scope of the objects that is related and then update policies ''' - policy_id = policies_collection.find_one({'slug': 'printer_can_view'}).get('_id') - policy_id = unicode(policy_id) - apply_policies_to_emitter_object(nodes_collection, printer, auth_user, policy_id, api, initialize, use_celery) + apply_policies_to_emitter_object(nodes_collection, printer, auth_user, 'printer_can_view', api, initialize, use_celery, policies_collection) def apply_policies_to_repository(nodes_collection, repository, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): ''' Checks if a repository is within the scope of the objects that is related and then update policies ''' - policy_id = policies_collection.find_one({'slug': 'repository_can_view'}).get('_id') - policy_id = unicode(policy_id) - apply_policies_to_emitter_object(nodes_collection, repository, auth_user, policy_id, api, initialize, use_celery) + apply_policies_to_emitter_object(nodes_collection, repository, auth_user, 'repository_can_view', api, initialize, use_celery, policies_collection) def apply_policies_to_storage(nodes_collection, storage, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): ''' Checks if a storage is within the scope of the objects that is related and then update policies ''' - policy_id = policies_collection.find_one({'slug': 'storage_can_view'}).get('_id') - policy_id = unicode(policy_id) - apply_policies_to_emitter_object(nodes_collection, storage, auth_user, policy_id, api, initialize, use_celery) + apply_policies_to_emitter_object(nodes_collection, storage, auth_user, 'storage_can_view', api, initialize, use_celery, policies_collection) def remove_policies_of_computer(user, computer, auth_user): From 2c1494def7da0e3f271f227da383a392e9c90ee3 Mon Sep 17 00:00:00 2001 From: iPablo Date: Thu, 19 Nov 2015 17:42:11 +0100 Subject: [PATCH 07/38] Now, we can move groups (backend) --- gecoscc/tasks.py | 6 +-- gecoscc/utils.py | 135 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 113 insertions(+), 28 deletions(-) diff --git a/gecoscc/tasks.py b/gecoscc/tasks.py index 6d65d5ea..20d47f6b 100644 --- a/gecoscc/tasks.py +++ b/gecoscc/tasks.py @@ -37,7 +37,7 @@ save_node_and_free, NodeBusyException, NodeNotLinked, apply_policies_to_computer, apply_policies_to_user, apply_policies_to_printer, apply_policies_to_storage, - apply_policies_to_repository, + apply_policies_to_repository, apply_policies_to_group, RESOURCES_RECEPTOR_TYPES, RESOURCES_EMITTERS_TYPES, POLICY_EMITTER_SUBFIX) @@ -908,8 +908,8 @@ def group_changed(self, user, objnew, objold, computers=None): self.log_action('changed', 'Group', objnew) def group_moved(self, user, objnew, objold): - self.log_action('moved', 'Storage', objnew) - raise NotImplementedError + self.object_moved(user, objnew, objold) + self.log_action('moved', 'Group', objnew) def group_deleted(self, user, obj, computers=None, direct_deleted=True): self.object_deleted(user, obj, computers=computers) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index 5691d0c0..a01468ed 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -19,7 +19,7 @@ import re from bson import ObjectId, json_util -from copy import deepcopy +from copy import deepcopy, copy from chef import ChefAPI, Client from chef import Node as ChefNode @@ -194,7 +194,7 @@ def delete_chef_admin_user(api, settings, usrname): return False -def remove_chef_computer_data(computer, api, policy=None): +def remove_chef_computer_data(computer, api, policies=None): ''' Remove computer policies in chef node ''' @@ -205,10 +205,11 @@ def remove_chef_computer_data(computer, api, policy=None): settings = get_current_registry().settings cookbook_name = settings.get('chef.cookbook_name') cookbook = node.normal.get(cookbook_name) - if policy: - policy_path = policy[1] - policy_field = policy[2] - cookbook[policy_path].pop(policy_field) + if policies: + for policy in policies: + policy_path = policy[1] + policy_field = policy[2] + cookbook[policy_path].pop(policy_field) else: for mgmt in cookbook.keys(): if mgmt == USER_MGMT: @@ -217,7 +218,7 @@ def remove_chef_computer_data(computer, api, policy=None): save_node_and_free(node) -def remove_chef_user_data(user, computers, api, policy_field_name=None): +def remove_chef_user_data(user, computers, api, policy_fields=None): ''' Remove computer policies in chef node ''' @@ -228,16 +229,17 @@ def remove_chef_user_data(user, computers, api, policy_field_name=None): if node_chef_id: node = reserve_node_or_raise(node_chef_id, api, 'gcc-remove-user-data-%s' % random.random()) if node: - if policy_field_name: - try: - user_mgmt = node.normal.get_dotted('%s.%s' % (cookbook_name + '.' + USER_MGMT, policy_field_name)) - users = user_mgmt.get('users') - if not users: - continue - users.pop(user['name']) - save_node_and_free(node) - except KeyError: - save_node_and_free(node) + if policy_fields: + for policy in policy_fields: + try: + user_mgmt = node.normal.get_dotted('%s.%s' % (cookbook_name + '.' + USER_MGMT, policy)) + users = user_mgmt.get('users') + if not users: + continue + users.pop(user['name']) + save_node_and_free(node) + except KeyError: + save_node_and_free(node) else: try: user_mgmt = node.normal.get_dotted('%s.%s' % (cookbook_name, USER_MGMT)) @@ -565,7 +567,7 @@ def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api for node in nodes_related_with_obj: is_visible = is_visible_query(nodes_collection, object_related_id=obj['_id'], - ou_id=node['path'].split(',')[-1], obj_id=obj['_id']) + ou_id=node['path'].split(',')[-1], obj_id=node['_id']) if is_visible is None: object_related_list = node['policies'][policy_id].get('object_related_list', []) @@ -577,17 +579,100 @@ def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api node['policies'][policy_id]['object_related_list'] = object_related_list obj = update_collection_and_get_obj(nodes_collection, node['_id'], node['policies']) - if obj['type'] == 'computer': - policy = policy['path'].split('.')[:3] - remove_chef_computer_data(obj, api, policy) - elif obj['type'] == 'user': - computers = get_computer_of_user(nodes_collection, obj) - policy_field_name = policy['path'].split('.')[2] - remove_chef_user_data(obj, computers, api, policy_field_name) + if obj['type'] in RESOURCES_RECEPTOR_TYPES: + try: + func = globals()['update_data_%s' % obj['type']] + except KeyError: + raise NotImplementedError + func(nodes_collection, obj, policy, api) object_created(auth_user, obj['type'], obj) +def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): + ''' + Checks if a group is within the scope of the objects that is related and then update policies + ''' + from gecoscc.tasks import object_changed, object_created + if use_celery: + object_created = object_created.delay + object_changed = object_changed.delay + policies = group['policies'].keys() + members_group = copy(group['members']) + + if not members_group: + return + + for member_id in members_group: + member = nodes_collection.find_one({'_id': member_id}) + is_visible = is_visible_group(nodes_collection.database, unicode(group['_id']), member) + + if is_visible is None: + + member['memberof'].remove(group['_id']) + user_member_of_groups = member['memberof'] + group['members'].remove(member['_id']) + groups_members = group['members'] + nodes_collection.update({'_id': member_id, }, {'$set': {'memberof': user_member_of_groups}}) + nodes_collection.update({'_id': group['_id']}, {'$set': {'members': groups_members}}) + + if member['type'] == 'user': + update_data_user(nodes_collection, member, policies, api, auth_user) + elif member['type'] == 'computer': + update_data_computer(nodes_collection, member, policies, api, auth_user) + + object_created(auth_user, group['type'], group) + + +def update_data_ou(nodes_collection, obj, policy, api, auth_user=None): + members_path = obj['path'] + ',' + obj[unicode('_id')] + members = nodes_collection.find({'path': members_path}) + for member_id in members: + member = nodes_collection.find_one({'_id': member_id}) + if member['type'] in RESOURCES_RECEPTOR_TYPES: + try: + func = 'update_data_%s' % obj['type'] + except KeyError: + raise NotImplementedError + func(nodes_collection, obj, policy, api) + + +def update_data_group(nodes_collection, obj, policy, api, auth_user=None): + for member_id in obj['members']: + member = nodes_collection.find_one({'_id': member_id}) + if member['type'] == 'user': + update_data_user(nodes_collection, obj, member, policy, api) + elif member['type'] == 'computer': + update_data_computer(nodes_collection, member, policy, api) + + +def update_data_user(nodes_collection, obj, policy, api, auth_user=None): + from gecoscc.tasks import object_created + computers = get_computer_of_user(nodes_collection, obj) + if isinstance(policy, list): + policy_field_name = [] + for policy_id in policy: + policy = nodes_collection.database.policies.find_one({'_id': policy_id}) + policy_field_name.append(policy['path'].split('.')[2]) + else: + policy_field_name = [policy['path'].split('.')[2]] + remove_chef_user_data(obj, computers, api, policy_field_name) + object_created(auth_user, 'user', obj, computers=computers) + + +def update_data_computer(nodes_collection, obj, policy, api, auth_user=None): + from gecoscc.tasks import object_created + if isinstance(policy, list): + policy_field_name = [] + for policy_id in policy: + policy = nodes_collection.database.policies.find_one({'_id': policy_id}) + policy_field_name.append(policy['path'].split('.')[:3]) + else: + policy_field_name = [policy['path'].split('.')[:3]] + remove_chef_computer_data(obj, api, policy_field_name) + object_created(auth_user, 'computer', obj, computers=[obj]) + + def apply_policies_to_printer(nodes_collection, printer, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): ''' Checks if a printer is within the scope of the objects that is related and then update policies From 1b97b1199f1cd38ddafdf6027f84225c71894b7a Mon Sep 17 00:00:00 2001 From: iPablo Date: Thu, 19 Nov 2015 18:00:33 +0100 Subject: [PATCH 08/38] Now, movements test 4 and 5 works correctly --- gecoscc/tests.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gecoscc/tests.py b/gecoscc/tests.py index 40c3c0d6..f4f67243 100644 --- a/gecoscc/tests.py +++ b/gecoscc/tests.py @@ -3202,7 +3202,6 @@ def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_meth self.assertEqualsObjects(data, new_user) db = self.get_db() - ou_1 = db.nodes.find_one({'name': 'OU 1'}) chef_node_id = CHEF_NODE_ID self.register_computer() @@ -3332,10 +3331,15 @@ def test_04_groups_movements(self, get_cookbook_method, get_cookbook_method_task self.assertEqual(group['members'][0], computer['_id']) # 4 - move group to the OU path - group_update = self.update_node(obj=new_group, field_name='path', - field_value=ou_1['path'], api_class=GroupResource, - is_superuser=False) + try: + group_update = self.update_node(obj=new_group, field_name='path', + field_value=ou_1['path'], api_class=GroupResource, + is_superuser=False) + except HTTPForbidden: + group_update = group + # 5 - Check if the groups has been moved + self.assertEqual(group_update['path'], group['path']) # 6 - move group to the OU path like admin group_update = self.update_node(obj=new_group, field_name='path', @@ -3343,6 +3347,7 @@ def test_04_groups_movements(self, get_cookbook_method, get_cookbook_method_task is_superuser=True) # 7 - Check if the groups has been moved + self.assertNotEqual(group_update['path'], group['path']) self.assertNoErrorJobs() @@ -3390,11 +3395,15 @@ def test_05_groups_movements_domain(self, get_cookbook_method, get_cookbook_meth data, domain = self.create_domain('Domain 2', flag_new) # 5 - move group to the OU path - group_update = self.update_node(obj=new_group, field_name='path', - field_value=domain['path'], api_class=GroupResource, - is_superuser=True) + try: + group_update = self.update_node(obj=new_group, field_name='path', + field_value=domain['path'], api_class=GroupResource, + is_superuser=True) + except KeyError: + group_update = group # 6 - Check if the groups has been moved + self.assertEqual(group_update['path'], group['path']) self.assertNoErrorJobs() From 95dc115755e598ec6c18a80a9c7c6f21e66a7d69 Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 20 Nov 2015 13:48:43 +0100 Subject: [PATCH 09/38] Now we can move OUs (backend) --- gecoscc/api/__init__.py | 7 +++++- gecoscc/api/organisationalunits.py | 22 +++++++++++-------- gecoscc/tasks.py | 6 +++--- gecoscc/utils.py | 34 ++++++++++++++++++++++++------ 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/gecoscc/api/__init__.py b/gecoscc/api/__init__.py index c566b5bd..881ee44e 100644 --- a/gecoscc/api/__init__.py +++ b/gecoscc/api/__init__.py @@ -536,6 +536,11 @@ def check_obj_is_related(self, obj): slug = 'repository_can_view' elif obj['type'] == 'storage': slug == 'storage_can_view' + elif obj['type'] == 'group': + members_group = obj['members'] + if not members_group: + return True + return False policy_id = self.request.db.policies.find_one({'slug': slug}).get('_id') nodes_related_with_obj = self.request.db.nodes.find({"policies.%s.object_related_list" @@ -549,6 +554,6 @@ def check_obj_is_related(self, obj): def integrity_validation(self, obj, real_obj=None): result = super(PassiveResourcePaginated, self).integrity_validation( obj, real_obj) - result = self.request.user.get('is_superuser', False) or self.check_obj_is_related(obj) + result = result and (self.request.user.get('is_superuser', False) or self.check_obj_is_related(obj)) return result diff --git a/gecoscc/api/organisationalunits.py b/gecoscc/api/organisationalunits.py index 96499213..d60c2f91 100644 --- a/gecoscc/api/organisationalunits.py +++ b/gecoscc/api/organisationalunits.py @@ -36,17 +36,21 @@ class OrganisationalUnitResource(TreeResourcePaginated): def integrity_validation(self, obj, real_obj=None): status = super(OrganisationalUnitResource, self).integrity_validation(obj, real_obj) - if (real_obj is not None and obj['path'] != real_obj['path']): - # Check if the ou is moving to self depth, that is not correct. - if obj['path'] in real_obj['path']: - self.request.errors.add( - obj[self.key], 'path', - "the ou is moving to self depth position, " - "that is not allowed") - return False - status = status and self.check_unique_node_name_by_type_at_domain(obj) + status_user = self.request.user.get('is_superuser', False) or self.is_ou_empty(obj) + status = status and status_user return status + def is_ou_empty(self, obj): + ''' + Check if the Ou contains any object + ''' + ou_children = self.get_db().nodes.find({'path': {'$regex': '.*' + unicode(obj['_id']) + '.*'}}),count() + + if ou_children == 0: + return True + else: + return False + def post_save(self, obj, old_obj=None): """ Check if path has changed to refresh children nodes """ if (self.request.method == 'PUT' and old_obj and diff --git a/gecoscc/tasks.py b/gecoscc/tasks.py index 20d47f6b..c2bf1263 100644 --- a/gecoscc/tasks.py +++ b/gecoscc/tasks.py @@ -38,8 +38,8 @@ apply_policies_to_computer, apply_policies_to_user, apply_policies_to_printer, apply_policies_to_storage, apply_policies_to_repository, apply_policies_to_group, - RESOURCES_RECEPTOR_TYPES, RESOURCES_EMITTERS_TYPES, - POLICY_EMITTER_SUBFIX) + apply_policies_to_ou, RESOURCES_RECEPTOR_TYPES, + RESOURCES_EMITTERS_TYPES, POLICY_EMITTER_SUBFIX) DELETED_POLICY_ACTION = 'deleted' @@ -978,8 +978,8 @@ def ou_changed(self, user, objnew, objold, computers=None): self.log_action('changed', 'OU', objnew) def ou_moved(self, user, objnew, objold): + self.object_moved(user, objnew, objold) self.log_action('moved', 'OU', objnew) - raise NotImplementedError def ou_deleted(self, user, obj, computers=None, direct_deleted=True): ou_path = '%s,%s' % (obj['path'], unicode(obj['_id'])) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index a01468ed..eb299989 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -584,7 +584,7 @@ def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api func = globals()['update_data_%s' % obj['type']] except KeyError: raise NotImplementedError - func(nodes_collection, obj, policy, api) + func(nodes_collection, obj, policy, api, auth_user) object_created(auth_user, obj['type'], obj) @@ -624,7 +624,29 @@ def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initia object_created(auth_user, group['type'], group) -def update_data_ou(nodes_collection, obj, policy, api, auth_user=None): +def apply_policies_to_ou(nodes_collection, ou, auth_user, api=None, initialize=False, use_celery=True, policies_collection=None): + ''' + Checks if a group is within the scope of the objects that is related and then update policies + ''' + from gecoscc.tasks import object_changed, object_created, object_moved + if use_celery: + object_created = object_created.delay + object_changed = object_changed.delay + children_path = ou['path'] + ',' + unicode(ou['_id']) + ou_children = nodes_collection.find({'path': {'$regex': '.*' + unicode(ou['_id']) + '.*'}}) + + if ou_children.count() == 0: + return + + for child in ou_children: + child_old = nodes_collection.find_one({'_id': child['_id']}) + child['path'] = children_path + object_moved(auth_user, child['type'], child, child_old) + + object_created(auth_user, 'ou', ou) + + +def update_data_ou(nodes_collection, obj, policy, api, auth_user): members_path = obj['path'] + ',' + obj[unicode('_id')] members = nodes_collection.find({'path': members_path}) for member_id in members: @@ -634,10 +656,10 @@ def update_data_ou(nodes_collection, obj, policy, api, auth_user=None): func = 'update_data_%s' % obj['type'] except KeyError: raise NotImplementedError - func(nodes_collection, obj, policy, api) + func(nodes_collection, obj, policy, api, auth_user) -def update_data_group(nodes_collection, obj, policy, api, auth_user=None): +def update_data_group(nodes_collection, obj, policy, api, auth_user): for member_id in obj['members']: member = nodes_collection.find_one({'_id': member_id}) if member['type'] == 'user': @@ -646,7 +668,7 @@ def update_data_group(nodes_collection, obj, policy, api, auth_user=None): update_data_computer(nodes_collection, member, policy, api) -def update_data_user(nodes_collection, obj, policy, api, auth_user=None): +def update_data_user(nodes_collection, obj, policy, api, auth_user): from gecoscc.tasks import object_created computers = get_computer_of_user(nodes_collection, obj) if isinstance(policy, list): @@ -660,7 +682,7 @@ def update_data_user(nodes_collection, obj, policy, api, auth_user=None): object_created(auth_user, 'user', obj, computers=computers) -def update_data_computer(nodes_collection, obj, policy, api, auth_user=None): +def update_data_computer(nodes_collection, obj, policy, api, auth_user): from gecoscc.tasks import object_created if isinstance(policy, list): policy_field_name = [] From 62c15cbe1f79dc250516efa38791106c2084b796 Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 20 Nov 2015 13:53:54 +0100 Subject: [PATCH 10/38] Added new movements test --- gecoscc/tests.py | 131 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 121 insertions(+), 10 deletions(-) diff --git a/gecoscc/tests.py b/gecoscc/tests.py index f4f67243..bee8f1e5 100644 --- a/gecoscc/tests.py +++ b/gecoscc/tests.py @@ -560,7 +560,7 @@ def create_ou(self, ou_name, domain_name='Domain 1'): 'type': 'ou', 'path': '%s,%s' % (domain['path'], domain['_id']), 'source': 'gecos'} - return self.create_node(data, OrganisationalUnitResource, ou_name='Domain 1') + return self.create_node(data, OrganisationalUnitResource, ou_name=domain_name) def create_domain(self, ou_name, flag): ''' @@ -3424,26 +3424,33 @@ def test_06_OUs_movements(self, get_cookbook_method, get_cookbook_method_tasks, self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) # 1- Create OU 2 - data, ou_2 = self.create_ou('OU 2', 'OU 1') + data, new_ou = self.create_ou('OU 2', 'OU 1') # 2 - Register a workstation db = self.get_db() - self.register_computer(ou_name=ou_2['name']) + self.register_computer(ou_name=new_ou['name']) ou_1 = db.nodes.find_one({'name': 'OU 1'}) + ou_2 = db.nodes.find_one({'name': 'OU 2'}) # 3 - Move OU 2 to OU 1 path - ou_moved = self.update_node(obj=ou_2, field_name='path', - field_value=ou_1['path'], api_class=OrganisationalUnitResource, - is_superuser=False) + try: + ou_moved = self.update_node(obj=new_ou, field_name='path', + field_value=ou_1['path'], api_class=OrganisationalUnitResource, + is_superuser=False) + + except HTTPForbidden: + ou_moved = ou_2 # 7- Check if the storage has been moved + self.assertEqual(ou_moved['path'], ou_2['path']) # 8 - Move printer to the OU path like admin - ou_moved = self.update_node(obj=ou_2, field_name='path', + ou_moved = self.update_node(obj=new_ou, field_name='path', field_value=ou_1['path'], api_class=OrganisationalUnitResource, is_superuser=True) # 9- Check if the storage has been moved + self.assertNotEqual(ou_moved['path'], ou_2['path']) self.assertNoErrorJobs() @@ -3481,10 +3488,114 @@ def test_07_OUs_movements_domain(self, get_cookbook_method, get_cookbook_method_ self.register_computer(ou_name=ou_1['name']) # 3 - Move OU 1 to Domain path - ou_moved = self.update_node(obj=ou_1, field_name='path', - field_value=domain['path'], api_class=OrganisationalUnitResource, - is_superuser=True) + try: + ou_moved = self.update_node(obj=ou_1, field_name='path', + field_value=domain['path'], api_class=OrganisationalUnitResource, + is_superuser=True) + except HTTPForbidden: + ou_moved = ou_1 # 9- Check if the storage has been moved + self.assertEqual(ou_moved['path'], ou_1['path']) + + self.assertNoErrorJobs() + + @mock.patch('gecoscc.api.chef_status.Node') + @mock.patch('gecoscc.forms.create_chef_admin_user') + @mock.patch('gecoscc.forms._') + @mock.patch('gecoscc.utils.isinstance') + @mock.patch('chef.Node') + @mock.patch('gecoscc.utils.ChefNode') + @mock.patch('gecoscc.tasks.get_cookbook') + @mock.patch('gecoscc.utils.get_cookbook') + def test_08_complete_policy(self, get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, + isinstance_method, gettext, create_chef_admin_user_method, ChefNodeStatusClass): + ''' + Test 08: + 1. Check the ous movements work + ''' + self.apply_mocks(get_cookbook_method, get_cookbook_method_tasks, NodeClass, ChefNodeClass, isinstance_method, gettext_mock, create_chef_admin_user_method, ChefNodeStatusClass) + chef_node_id = CHEF_NODE_ID + + # 1 - Create OU 1 + data, ou_1 = self.create_ou('OU 1') + + # 2 - Create OU 2 + data, ou_2 = self.create_ou('OU 2') + + # 3 - Create OU 3 + data, ou_3 = self.create_ou('OU 3', 'OU 1') + + # 4 - Create user, workstation, storage and 5 - Assign user to computer + admin_username = 'superuser' + self.add_admin_user(admin_username) + + username = 'testuser' + data, user = self.create_user(username, 'OU 3') + self.assertEqualsObjects(data, user) + + db = self.get_db() + chef_node_id = CHEF_NODE_ID + self.register_computer(ou_name=ou_3['name']) + + self.assign_user_to_node(gcc_superusername=admin_username, chef_node_id=chef_node_id, username=username) + + data, storage = self.create_storage('shared folder', ou_3['name']) + data, storage_ou_1 = self.create_storage('shared folder_ou_1', ou_1['name']) + + user = db.nodes.find_one({'name': username}) + request = self.dummy_get_request(user, UserResource.schema_detail) + user_api = UserResource(request) + user = user_api.get() + + id_computer = user['computers'] + user['computers'] = [ObjectId(id_computer[0])] + + storage_policy = db.policies.find_one({'slug': 'storage_can_view'}) + + user['policies'] = {unicode(storage_policy['_id']): {'object_related_list': [storage['_id']]}} + storage_policy_path = storage_policy['path'] + '.' + username + '.gtkbookmarks' + node_policy = self.add_and_get_policy(node=user, chef_node_id=chef_node_id, api_class=UserResource, policy_path=storage_policy_path) + + ou_1 = db.nodes.find_one({'name': 'OU 1'}) + ou_1['policies'] = {unicode(storage_policy['_id']): {'object_related_list': [storage_ou_1['_id']]}} + node_policy = self.add_and_get_policy(node=ou_1, chef_node_id=chef_node_id, api_class=OrganisationalUnitResource, policy_path=storage_policy_path) + + # 7 - add package policy to OU_1, OU_3 and ws + package_res_policy = self.get_default_ws_policy() + policy_path = package_res_policy['path'] + '.package_list' + ou_1['policies'] = {unicode(package_res_policy['_id']): {'package_list': ['gimp'], 'pkgs_to_remove': []}} + package_res_node_policy = self.add_and_get_policy(node=ou_1, chef_node_id=chef_node_id, api_class=OrganisationalUnitResource, policy_path=policy_path) + + apply_package = [{'node': 'testing', 'api_type': ComputerResource, 'package': 'sublime'}, + {'node': 'OU 1', 'api_type': OrganisationalUnitResource, 'package': 'gimp'}, + {'node': 'OU 3', 'api_type': OrganisationalUnitResource, 'package': 'kate'}] + + package_res_policy = self.get_default_ws_policy() + policy_path = package_res_policy['path'] + '.package_list' + + for node in apply_package: + node_to_apply = db.nodes.find_one({'name': node['node']}) + node_to_apply['policies'] = {unicode(package_res_policy['_id']): {'package_list': [node['package']], 'pkgs_to_remove': []}} + package_res_node_policy = self.add_and_get_policy(node=node_to_apply, chef_node_id=chef_node_id, api_class=node['api_type'], policy_path=policy_path) + + self.assertItemsEqual(package_res_node_policy, [u'kate', u'sublime', u'gimp']) + self.assertEmitterObjects(node_policy, [storage_ou_1, storage], fields=('name', + 'uri')) + + # 8 - Move OU 3 to OU 1 path + ou_3 = db.nodes.find_one({'name': 'OU 3'}) + self.update_node(obj=ou_3, field_name='path', + field_value=ou_1['path'], api_class=OrganisationalUnitResource, + is_superuser=True) + + # 9 - Check if the policies has been updated in chef node + node = NodeMock(chef_node_id, None) + node_storage_policy = node.attributes.get_dotted(storage_policy_path) + node_package_policy = node.attributes.get_dotted(policy_path) + + self.assertEmitterObjects(node_storage_policy, [storage], fields=('name', + 'uri')) + self.assertItemsEqual(node_package_policy, [u'kate', u'sublime']) self.assertNoErrorJobs() From bbf1e9800d3b07dbea1f618b7c49e90912031d6e Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 20 Nov 2015 14:01:07 +0100 Subject: [PATCH 11/38] Fixed little code error --- gecoscc/api/organisationalunits.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gecoscc/api/organisationalunits.py b/gecoscc/api/organisationalunits.py index d60c2f91..b28aa318 100644 --- a/gecoscc/api/organisationalunits.py +++ b/gecoscc/api/organisationalunits.py @@ -43,8 +43,8 @@ def integrity_validation(self, obj, real_obj=None): def is_ou_empty(self, obj): ''' Check if the Ou contains any object - ''' - ou_children = self.get_db().nodes.find({'path': {'$regex': '.*' + unicode(obj['_id']) + '.*'}}),count() + ''' + ou_children = self.get_db().nodes.find({'path': {'$regex': '.*' + unicode(obj['_id']) + '.*'}}).count() if ou_children == 0: return True From 929b384901b6edca3afd5a391a247556923982c0 Mon Sep 17 00:00:00 2001 From: iPablo Date: Mon, 23 Nov 2015 08:44:28 +0100 Subject: [PATCH 12/38] Improved code --- gecoscc/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index eb299989..d3707f1d 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -431,7 +431,7 @@ def visibility_object_related(db, obj): '_id': ObjectId(object_related_id) }) else: - is_visible = is_visible_query(db.nodes, object_related_id, ou_id, obj_id) + is_visible = is_object_visible(db.nodes, object_related_id, ou_id, obj_id) if is_visible: object_related_visible.append(object_related_id) if object_related_list != object_related_visible: @@ -479,7 +479,7 @@ def recalc_node_policies(nodes_collection, jobs_collection, computer, auth_user, return (True, 'success') -def is_visible_query(nodes_collection, object_related_id, ou_id, obj_id): +def is_object_visible(nodes_collection, object_related_id, ou_id, obj_id): return nodes_collection.find_one({'_id': ObjectId(object_related_id), 'path': get_filter_nodes_parents_ou(nodes_collection.database, ou_id, @@ -566,10 +566,10 @@ def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api return for node in nodes_related_with_obj: - is_visible = is_visible_query(nodes_collection, object_related_id=obj['_id'], - ou_id=node['path'].split(',')[-1], obj_id=node['_id']) + is_visible = is_object_visible(nodes_collection, object_related_id=obj['_id'], + ou_id=node['path'].split(',')[-1], obj_id=node['_id']) - if is_visible is None: + if not is_visible: object_related_list = node['policies'][policy_id].get('object_related_list', []) object_related_list.remove(unicode(obj['_id'])) @@ -607,7 +607,7 @@ def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initia member = nodes_collection.find_one({'_id': member_id}) is_visible = is_visible_group(nodes_collection.database, unicode(group['_id']), member) - if is_visible is None: + if not is_visible: member['memberof'].remove(group['_id']) user_member_of_groups = member['memberof'] From 77e8bd07fbe73261cdbd2b30914d3555173b9743 Mon Sep 17 00:00:00 2001 From: iPablo Date: Mon, 23 Nov 2015 11:41:18 +0100 Subject: [PATCH 13/38] Fixed error --- gecoscc/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index d3707f1d..dea9624f 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -605,7 +605,7 @@ def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initia for member_id in members_group: member = nodes_collection.find_one({'_id': member_id}) - is_visible = is_visible_group(nodes_collection.database, unicode(group['_id']), member) + is_visible = is_visible_group(nodes_collection.database, group['_id'], member) if not is_visible: From e64c35da5609221641e9b9c1b6e0b87a5b987f0a Mon Sep 17 00:00:00 2001 From: iPablo Date: Mon, 23 Nov 2015 11:45:57 +0100 Subject: [PATCH 14/38] Improved tests --- gecoscc/tests.py | 99 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 88 insertions(+), 11 deletions(-) diff --git a/gecoscc/tests.py b/gecoscc/tests.py index bee8f1e5..ea865407 100644 --- a/gecoscc/tests.py +++ b/gecoscc/tests.py @@ -3157,10 +3157,16 @@ def test_01_printers_movements(self, get_cookbook_method, get_cookbook_method_ta except HTTPForbidden: printer_update = printer - # 5 - Checks if the printer has been moved + # 5 - Checks if the printer has been moved and check if the policy has been updated self.assertEqual(printer_update['path'], printer['path']) - - # 6 - Move printer to the OU path like super admin + node = NodeMock(CHEF_NODE_ID, None) + printer_policy = node.attributes.get_dotted(policy_path) + self.assertEqualsObjects(printer_policy[0], new_printer, fields=('oppolicy', + 'model', + 'uri', + 'name', + 'manufacturer')) + # 6 - Move printer to the OU path like superadmin printer_update = self.update_node(obj=new_printer, field_name='path', field_value=ou_1['path'], api_class=PrinterResource, is_superuser=True) @@ -3168,6 +3174,21 @@ def test_01_printers_movements(self, get_cookbook_method, get_cookbook_method_ta # 7 - Checks if the printer has been moved self.assertNotEqual(printer_update['path'], printer['path']) + # 8 - Create another OU + data, ou_2 = self.create_ou('OU 2') + + # 9 - Move printer to OU 2 like superadmin + printer_update = self.update_node(obj=new_printer, field_name='path', + field_value=ou_2['path'] + ',' + unicode(ou_2['_id']), + api_class=PrinterResource, + is_superuser=True) + + # 10 - Check if the printer is moved and the policy has been updated + self.assertNotEqual(printer_update['path'], printer['path']) + node = NodeMock(CHEF_NODE_ID, None) + printer_policy = node.attributes.get_dotted(policy_path) + self.assertEquals(printer_policy, []) + self.assertNoErrorJobs() @mock.patch('gecoscc.api.chef_status.Node') @@ -3239,9 +3260,31 @@ def test_02_shared_folder_movements(self, get_cookbook_method, get_cookbook_meth storage_update = self.update_node(obj=new_storage, field_name='path', field_value=ou_2['path'], api_class=StorageResource, is_superuser=True) + # 9 - Check if the storage is moved and the policy has been updated + self.assertNotEqual(storage_update['path'], storage['path']) + node = NodeMock(CHEF_NODE_ID, None) + printer_policy = node.attributes.get_dotted(policy_path) + self.assertEqualsObjects(printer_policy[0], storage, fields=('oppolicy', + 'model', + 'uri', + 'name', + 'manufacturer')) + # 10 - Create another OU + data, ou_3 = self.create_ou('OU 3') + + # 11 - Move storage in the OU 3 like admin + storage_update = self.update_node(obj=new_storage, field_name='path', + field_value=ou_3['path'] + ',' + ou_3['_id'], api_class=StorageResource, + is_superuser=True) - # 9- Check if the storage has been moved + # 12 - Check if the storage is moved and the policy has been updated self.assertNotEqual(storage_update['path'], storage['path']) + node = NodeMock(CHEF_NODE_ID, None) + try: + printer_policy = node.attributes.get_dotted(policy_path) + self.assertEquals(printer_policy, []) + except KeyError: + self.assertEquals([], []) self.assertNoErrorJobs() @@ -3288,7 +3331,7 @@ def test_03_repository_movements(self, get_cookbook_method, get_cookbook_method_ # 5 - Checks if the repository has been moved self.assertEqual(repository_update['path'], repository['path']) - # 6 - Move repository to the OU path like super admin + # 6 - Move repository to the OU path like admin repository_update = self.update_node(obj=new_repository, field_name='path', field_value=ou_1['path'], api_class=RepositoryResource, is_superuser=True) @@ -3296,6 +3339,23 @@ def test_03_repository_movements(self, get_cookbook_method, get_cookbook_method_ # 7 - Checks if the repository has been moved self.assertNotEqual(repository_update['path'], repository['path']) + # 8 - Create another OU + data, ou_2 = self.create_ou('OU 2') + + # 9 - Move printer to OU 2 like superadmin + repository = db.nodes.find_one({'name': 'Testrepo'}) + repository_path = repository['path'] + repository_update = self.update_node(obj=repository, field_name='path', + field_value=ou_2['path'] + ',' + unicode(ou_2['_id']), + api_class=RepositoryResource, + is_superuser=True) + + # 10 - Check if the printer is moved and the policy has been updated + self.assertNotEqual(repository_update['path'], repository_path) + node = NodeMock(CHEF_NODE_ID, None) + printer_policy = node.attributes.get_dotted(policy_path) + self.assertEquals(printer_policy, []) + self.assertNoErrorJobs() @mock.patch('gecoscc.api.chef_status.Node') @@ -3332,7 +3392,7 @@ def test_04_groups_movements(self, get_cookbook_method, get_cookbook_method_task # 4 - move group to the OU path try: - group_update = self.update_node(obj=new_group, field_name='path', + group_update = self.update_node(obj=group, field_name='path', field_value=ou_1['path'], api_class=GroupResource, is_superuser=False) except HTTPForbidden: @@ -3342,12 +3402,29 @@ def test_04_groups_movements(self, get_cookbook_method, get_cookbook_method_task self.assertEqual(group_update['path'], group['path']) # 6 - move group to the OU path like admin - group_update = self.update_node(obj=new_group, field_name='path', + group = db.nodes.find_one({'name': 'testgroup'}) + group_path = group['path'] + group_update = self.update_node(obj=group, field_name='path', field_value=ou_1['path'], api_class=GroupResource, is_superuser=True) - # 7 - Check if the groups has been moved - self.assertNotEqual(group_update['path'], group['path']) + self.assertNotEqual(group_update['path'], group_path) + self.assertNotEqual(group_update['members'], []) + + # 8 - Create another OU + data, ou_2 = self.create_ou('OU 2') + + # 9 - Move group to OU 2 like superadmin + group = db.nodes.find_one({'name': 'testgroup'}) + group_path = group['path'] + group_update = self.update_node(obj=group, field_name='path', + field_value=ou_2['path'] + ',' + unicode(ou_2['_id']), + api_class=GroupResource, + is_superuser=True) + + # 10 - Check if the group is moved and the policy has been updated + self.assertNotEqual(group_update['path'], group_path) + self.assertEqual(group_update['members'], []) self.assertNoErrorJobs() @@ -3394,7 +3471,7 @@ def test_05_groups_movements_domain(self, get_cookbook_method, get_cookbook_meth data, domain = self.create_domain('Domain 2', flag_new) - # 5 - move group to the OU path + # 5 - move group to the OU path like admin try: group_update = self.update_node(obj=new_group, field_name='path', field_value=domain['path'], api_class=GroupResource, @@ -3487,7 +3564,7 @@ def test_07_OUs_movements_domain(self, get_cookbook_method, get_cookbook_method_ ou_1 = db.nodes.find_one({'name': 'OU 1'}) self.register_computer(ou_name=ou_1['name']) - # 3 - Move OU 1 to Domain path + # 3 - Move OU 1 to Domain path like admin try: ou_moved = self.update_node(obj=ou_1, field_name='path', field_value=domain['path'], api_class=OrganisationalUnitResource, From 75d4443e09c583d290f385b59b64cde2b171c10d Mon Sep 17 00:00:00 2001 From: rastydnb Date: Mon, 30 Nov 2015 16:31:49 +0100 Subject: [PATCH 15/38] cut and paste repo,group,print and ou --- gecoscc/static/js/group-form-views.js | 3 ++- gecoscc/static/js/ou.js | 3 ++- gecoscc/static/js/printer.js | 5 +++-- gecoscc/static/js/repository.js | 5 +++-- gecoscc/static/js/storage.js | 5 +++-- gecoscc/templates/bb-groups-form.html | 1 + gecoscc/templates/bb-ou.html | 1 + gecoscc/templates/bb-printer.html | 1 + gecoscc/templates/bb-repository.html | 1 + gecoscc/templates/bb-storage.html | 1 + 10 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gecoscc/static/js/group-form-views.js b/gecoscc/static/js/group-form-views.js index 513ad3b4..284cdf3a 100644 --- a/gecoscc/static/js/group-form-views.js +++ b/gecoscc/static/js/group-form-views.js @@ -49,7 +49,8 @@ App.module("Group.Views", function (Views, App, Backbone, Marionette, $, _) { "click button#delete": "deleteModel", "click button#save": "save", "click button.refresh": "refresh", - "click ul.pagination a": "goToPage" + "click ul.pagination a": "goToPage", + "click #cut": "cutModel" }, policiesList: undefined, diff --git a/gecoscc/static/js/ou.js b/gecoscc/static/js/ou.js index 72e90fdc..64084dde 100644 --- a/gecoscc/static/js/ou.js +++ b/gecoscc/static/js/ou.js @@ -49,7 +49,8 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { "click #submit": "saveForm", "click #delete": "deleteModel", "change input": "validate", - "click button.refresh": "refresh" + "click button.refresh": "refresh", + "click #cut": "cutModel" }, policiesList: undefined, diff --git a/gecoscc/static/js/printer.js b/gecoscc/static/js/printer.js index ed068552..4eac8c50 100644 --- a/gecoscc/static/js/printer.js +++ b/gecoscc/static/js/printer.js @@ -20,7 +20,7 @@ App.module("Printer.Models", function (Models, App, Backbone, Marionette, $, _) { "use strict"; - Models.PrinterModel = App.GecosResourceModel.extend({ + Models.PrinterModel = App.Policies.Models.GecosResourceModel.extend({ resourceType: "printer", defaults: { @@ -57,7 +57,8 @@ App.module("Printer.Views", function (Views, App, Backbone, Marionette, $, _) { "click #submit": "saveForm", "click #delete": "deleteModel", "change input": "validate", - "click button.refresh": "refresh" + "click button.refresh": "refresh", + "click #cut": "cutModel" }, onBeforeRender: function () { diff --git a/gecoscc/static/js/repository.js b/gecoscc/static/js/repository.js index 825e6158..40a56496 100644 --- a/gecoscc/static/js/repository.js +++ b/gecoscc/static/js/repository.js @@ -17,7 +17,7 @@ App.module("Repository.Models", function (Models, App, Backbone, Marionette, $, _) { "use strict"; - Models.RepositoryModel = App.GecosResourceModel.extend({ + Models.RepositoryModel = App.Policies.Models.GecosResourceModel.extend({ resourceType: "repository", defaults: { @@ -56,7 +56,8 @@ App.module("Repository.Views", function (Views, App, Backbone, Marionette, $, _) "click #submit": "saveForm", "click #delete": "deleteModel", "change input": "validate", - "click button.refresh": "refresh" + "click button.refresh": "refresh", + "click #cut": "cutModel" }, onBeforeRender: function () { diff --git a/gecoscc/static/js/storage.js b/gecoscc/static/js/storage.js index 985b256b..6b3b1f59 100644 --- a/gecoscc/static/js/storage.js +++ b/gecoscc/static/js/storage.js @@ -16,7 +16,7 @@ App.module("Storage.Models", function (Models, App, Backbone, Marionette, $, _) { "use strict"; - Models.StorageModel = App.GecosResourceModel.extend({ + Models.StorageModel = App.Policies.Models.GecosResourceModel.extend({ resourceType: "storage", defaults: { @@ -54,7 +54,8 @@ App.module("Storage.Views", function (Views, App, Backbone, Marionette, $, _) { "click #submit": "saveForm", "click #delete": "deleteModel", "change input": "validate", - "click button.refresh": "refresh" + "click button.refresh": "refresh", + "click #cut": "cutModel" }, onBeforeRender: function () { diff --git a/gecoscc/templates/bb-groups-form.html b/gecoscc/templates/bb-groups-form.html index 4c9dede3..e8c4ea48 100644 --- a/gecoscc/templates/bb-groups-form.html +++ b/gecoscc/templates/bb-groups-form.html @@ -34,6 +34,7 @@ <% if (typeof id !== "undefined") { %> + <% } %> <% } %> diff --git a/gecoscc/templates/bb-ou.html b/gecoscc/templates/bb-ou.html index 3acf4a37..effb2b37 100644 --- a/gecoscc/templates/bb-ou.html +++ b/gecoscc/templates/bb-ou.html @@ -59,6 +59,7 @@ <% if (typeof id !== "undefined") { %> + <% } %> <% } %> diff --git a/gecoscc/templates/bb-printer.html b/gecoscc/templates/bb-printer.html index 03e091d6..5f79b832 100644 --- a/gecoscc/templates/bb-printer.html +++ b/gecoscc/templates/bb-printer.html @@ -105,6 +105,7 @@ <% if (typeof id !== "undefined") { %> + <% } %> <% } %> diff --git a/gecoscc/templates/bb-repository.html b/gecoscc/templates/bb-repository.html index f9923b6c..e7def0fa 100644 --- a/gecoscc/templates/bb-repository.html +++ b/gecoscc/templates/bb-repository.html @@ -69,6 +69,7 @@ <% if (typeof id !== "undefined") { %> + <% } %> <% } %> diff --git a/gecoscc/templates/bb-storage.html b/gecoscc/templates/bb-storage.html index 3409a282..7e4a5db9 100644 --- a/gecoscc/templates/bb-storage.html +++ b/gecoscc/templates/bb-storage.html @@ -27,6 +27,7 @@ <% if (typeof id !== "undefined") { %> + <% } %> <% } %> From 3b1fc5163d5d391e7f5b9e31e12373b619c2ba4f Mon Sep 17 00:00:00 2001 From: rastydnb Date: Tue, 1 Dec 2015 17:39:00 +0100 Subject: [PATCH 16/38] add maintenance modal question --- gecoscc/static/js/tree-views.js | 15 ++++++++++++++- gecoscc/templates/base_tree.jinja2 | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gecoscc/static/js/tree-views.js b/gecoscc/static/js/tree-views.js index feb54ad3..d2e4cadc 100644 --- a/gecoscc/static/js/tree-views.js +++ b/gecoscc/static/js/tree-views.js @@ -259,7 +259,20 @@ App.module("Tree.Views", function (Views, App, Backbone, Marionette, $, _) { $html.find("a.text-warning").click(function (evt) { evt.preventDefault(); - _.bind(that._pasteOU, ouId)(); + var $modal = $('#maintenance-modal'); + $modal.modal('show'); + var handleMaintenance = function($options){ + _.bind(that._pasteOU, ouId)(); + $modal.modal('hide'); + }; + $('#set-maintenance').click(function(){ + handleMaintenance(true); + }); + $('#unset-maintenance').click(function(){ + handleMaintenance(false); + }); + + }); }, diff --git a/gecoscc/templates/base_tree.jinja2 b/gecoscc/templates/base_tree.jinja2 index e3f8eaef..d3cabd55 100644 --- a/gecoscc/templates/base_tree.jinja2 +++ b/gecoscc/templates/base_tree.jinja2 @@ -127,6 +127,24 @@
+ + {% endblock %} {% block extrajs %} From a1b8ce7073604211cf827962b388bac137ba88c4 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Wed, 2 Dec 2015 11:15:02 +0100 Subject: [PATCH 17/38] check user admin for crop and paste --- gecoscc/static/js/tree-views.js | 10 ++-------- gecoscc/templates/base_tree.jinja2 | 6 +++--- gecoscc/templates/bb-computer.html | 6 +++++- gecoscc/templates/bb-groups-form.html | 6 +++++- gecoscc/templates/bb-ou.html | 6 +++++- gecoscc/templates/bb-printer.html | 6 +++++- gecoscc/templates/bb-repository.html | 8 +++++++- gecoscc/templates/bb-storage.html | 6 +++++- gecoscc/templates/bb-user.html | 6 +++++- 9 files changed, 42 insertions(+), 18 deletions(-) diff --git a/gecoscc/static/js/tree-views.js b/gecoscc/static/js/tree-views.js index d2e4cadc..db14cae2 100644 --- a/gecoscc/static/js/tree-views.js +++ b/gecoscc/static/js/tree-views.js @@ -261,17 +261,11 @@ App.module("Tree.Views", function (Views, App, Backbone, Marionette, $, _) { evt.preventDefault(); var $modal = $('#maintenance-modal'); $modal.modal('show'); - var handleMaintenance = function($options){ + + $('#set-maintenance').click(function(){ _.bind(that._pasteOU, ouId)(); $modal.modal('hide'); - }; - $('#set-maintenance').click(function(){ - handleMaintenance(true); }); - $('#unset-maintenance').click(function(){ - handleMaintenance(false); - }); - }); }, diff --git a/gecoscc/templates/base_tree.jinja2 b/gecoscc/templates/base_tree.jinja2 index d3cabd55..5ea2f3d8 100644 --- a/gecoscc/templates/base_tree.jinja2 +++ b/gecoscc/templates/base_tree.jinja2 @@ -133,13 +133,13 @@ diff --git a/gecoscc/templates/bb-computer.html b/gecoscc/templates/bb-computer.html index 76f5903a..00775653 100644 --- a/gecoscc/templates/bb-computer.html +++ b/gecoscc/templates/bb-computer.html @@ -108,7 +108,11 @@ <% if (typeof id !== "undefined") { %> - + {% if request.user and request.user.get('is_superuser') %} + + {% else %} + + {% endif %} <% } %> <% } %> diff --git a/gecoscc/templates/bb-groups-form.html b/gecoscc/templates/bb-groups-form.html index e8c4ea48..b9001e61 100644 --- a/gecoscc/templates/bb-groups-form.html +++ b/gecoscc/templates/bb-groups-form.html @@ -34,7 +34,11 @@ <% if (typeof id !== "undefined") { %> - + {% if request.user and request.user.get('is_superuser') %} + + {% else %} + + {% endif %} <% } %> <% } %> diff --git a/gecoscc/templates/bb-ou.html b/gecoscc/templates/bb-ou.html index effb2b37..4b4e88b0 100644 --- a/gecoscc/templates/bb-ou.html +++ b/gecoscc/templates/bb-ou.html @@ -59,7 +59,11 @@ <% if (typeof id !== "undefined") { %> - + {% if request.user and request.user.get('is_superuser') %} + + {% else %} + + {% endif %} <% } %> <% } %> diff --git a/gecoscc/templates/bb-printer.html b/gecoscc/templates/bb-printer.html index 5f79b832..dafaaf9b 100644 --- a/gecoscc/templates/bb-printer.html +++ b/gecoscc/templates/bb-printer.html @@ -105,7 +105,11 @@ <% if (typeof id !== "undefined") { %> - + {% if request.user and request.user.get('is_superuser') %} + + {% else %} + + {% endif %} <% } %> <% } %> diff --git a/gecoscc/templates/bb-repository.html b/gecoscc/templates/bb-repository.html index e7def0fa..9c37789e 100644 --- a/gecoscc/templates/bb-repository.html +++ b/gecoscc/templates/bb-repository.html @@ -69,7 +69,13 @@ <% if (typeof id !== "undefined") { %> - + hola + {{request.user.get('is_superuser')}} + {% if request.user and request.user.get('is_superuser') %} + + {% else %} + + {% endif %} <% } %> <% } %> diff --git a/gecoscc/templates/bb-storage.html b/gecoscc/templates/bb-storage.html index 7e4a5db9..42998332 100644 --- a/gecoscc/templates/bb-storage.html +++ b/gecoscc/templates/bb-storage.html @@ -27,7 +27,11 @@ <% if (typeof id !== "undefined") { %> - + {% if request.user and request.user.get('is_superuser') %} + + {% else %} + + {% endif %} <% } %> <% } %> diff --git a/gecoscc/templates/bb-user.html b/gecoscc/templates/bb-user.html index 0be8ae37..f3828dfb 100644 --- a/gecoscc/templates/bb-user.html +++ b/gecoscc/templates/bb-user.html @@ -88,7 +88,11 @@ <% if (typeof id !== "undefined") { %> - + {% if request.user and request.user.get('is_superuser') %} + + {% else %} + + {% endif %} <% } %> <% } %> From 2e24cea22b5e4fae8d6381418c2979edc95421c5 Mon Sep 17 00:00:00 2001 From: iPablo Date: Wed, 2 Dec 2015 17:07:35 +0100 Subject: [PATCH 18/38] Added function that help us to know if a related object is assigned in a policy --- gecoscc/api/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gecoscc/api/__init__.py b/gecoscc/api/__init__.py index 881ee44e..1c9f9a67 100644 --- a/gecoscc/api/__init__.py +++ b/gecoscc/api/__init__.py @@ -179,9 +179,24 @@ def get(self): node = self.collection.find_one(collection_filter) if not node: raise HTTPNotFound() - + if node['type'] in ('printer', 'storage', 'repository'): + node = self.parse_item(node) + node['is_assigned'] = self.is_assigned(node) + return node return self.parse_item(node) + def is_assigned(self, related_object): + db = self.get_collection('policies') + policy = db.find_one({'slug': '%s_can_view' % related_object['type']}) + node_with_related_object = self.collection.find({'policies.%s.object_related_list' % unicode(policy['_id']): + {'$in': [unicode(related_object['_id'])]}}) + if node_with_related_object.count() == 0: + return False + else: + return True + + return related_object + class ResourcePaginated(ResourcePaginatedReadOnly): From 6f32370794cbf15cccefeb37fcbc549815c028d0 Mon Sep 17 00:00:00 2001 From: iPablo Date: Wed, 2 Dec 2015 18:06:43 +0100 Subject: [PATCH 19/38] Code improved --- gecoscc/api/__init__.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/gecoscc/api/__init__.py b/gecoscc/api/__init__.py index 1c9f9a67..48bfc86f 100644 --- a/gecoscc/api/__init__.py +++ b/gecoscc/api/__init__.py @@ -28,8 +28,8 @@ from gecoscc.tasks import object_created, object_changed, object_deleted, object_moved from gecoscc.utils import (get_computer_of_user, get_filter_nodes_parents_ou, oids_filter, check_unique_node_name_by_type_at_domain, - visibility_object_related, visibility_group) - + visibility_object_related, visibility_group, + RESOURCES_EMITTERS_TYPES, get_object_related_list) from gecoscc.i18n import gettext as _ import logging @@ -179,23 +179,15 @@ def get(self): node = self.collection.find_one(collection_filter) if not node: raise HTTPNotFound() - if node['type'] in ('printer', 'storage', 'repository'): - node = self.parse_item(node) + node = self.parse_item(node) + if node['type'] in RESOURCES_EMITTERS_TYPES: node['is_assigned'] = self.is_assigned(node) return node - return self.parse_item(node) + return node def is_assigned(self, related_object): - db = self.get_collection('policies') - policy = db.find_one({'slug': '%s_can_view' % related_object['type']}) - node_with_related_object = self.collection.find({'policies.%s.object_related_list' % unicode(policy['_id']): - {'$in': [unicode(related_object['_id'])]}}) - if node_with_related_object.count() == 0: - return False - else: - return True - - return related_object + node_with_related_object = get_object_related_list(self.request.db, related_object) + return bool(node_with_related_object.count()) class ResourcePaginated(ResourcePaginatedReadOnly): From e982235b8ed1fe64a4da10afb6b3f01766fe9920 Mon Sep 17 00:00:00 2001 From: iPablo Date: Wed, 2 Dec 2015 18:07:24 +0100 Subject: [PATCH 20/38] Code refactored --- gecoscc/tasks.py | 22 +++++----------------- gecoscc/utils.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/gecoscc/tasks.py b/gecoscc/tasks.py index c2bf1263..1b64e8d3 100644 --- a/gecoscc/tasks.py +++ b/gecoscc/tasks.py @@ -39,7 +39,8 @@ apply_policies_to_printer, apply_policies_to_storage, apply_policies_to_repository, apply_policies_to_group, apply_policies_to_ou, RESOURCES_RECEPTOR_TYPES, - RESOURCES_EMITTERS_TYPES, POLICY_EMITTER_SUBFIX) + RESOURCES_EMITTERS_TYPES, POLICY_EMITTER_SUBFIX, + get_policy_emiter_id, get_object_related_list) DELETED_POLICY_ACTION = 'deleted' @@ -131,26 +132,13 @@ def get_related_computers_of_ou(self, ou, related_computers, related_objects): return related_computers - def get_policy_emiter_id(self, obj): - ''' - Get the id from a emitter policy - ''' - return self.db.policies.find_one({'slug': emiter_police_slug(obj['type'])})['_id'] - - def get_object_related_list(self, obj): - ''' - Get the objects related list to an object - ''' - policy_id = unicode(self.get_policy_emiter_id(obj)) - return self.db.nodes.find({"policies.%s.object_related_list" % policy_id: {'$in': [unicode(obj['_id'])]}}) - def get_related_computers_of_emiters(self, obj, related_computers, related_objects): ''' Get the related computers of emitter objects ''' if self.walking_here(obj, related_objects): return related_computers - object_related_list = self.get_object_related_list(obj) + object_related_list = get_object_related_list(self.db, obj) for object_related in object_related_list: self.get_related_computers(object_related, related_computers, related_objects) return related_computers @@ -881,8 +869,8 @@ def object_moved(self, user, objnew, objold): def object_emiter_deleted(self, user, obj, computers=None): obj_id = unicode(obj['_id']) - policy_id = unicode(self.get_policy_emiter_id(obj)) - object_related_list = self.get_object_related_list(obj) + policy_id = unicode(get_policy_emiter_id(self.db, obj)) + object_related_list = get_object_related_list(self.db, obj) for obj_related in object_related_list: obj_old_related = deepcopy(obj_related) object_related_list = obj_related['policies'][policy_id]['object_related_list'] diff --git a/gecoscc/utils.py b/gecoscc/utils.py index dea9624f..aa6a4aac 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -36,6 +36,21 @@ USE_NODE = 'use_node' +def get_policy_emiter_id(collection, obj): + ''' + Get the id from a emitter policy + ''' + return collection.policies.find_one({'slug': emiter_police_slug(obj['type'])})['_id'] + + +def get_object_related_list(collection, obj): + ''' + Get the objects related list to an object + ''' + policy_id = unicode(get_policy_emiter_id(collection, obj)) + return collection.nodes.find({"policies.%s.object_related_list" % policy_id: {'$in': [unicode(obj['_id'])]}}) + + def merge_lists(collection, obj, old_obj, attribute, remote_attribute, keyname='_id'): """ Merge a list of relations in a two ways relation model. From 0d2678830c3a1290ef0d2ef5ecbbe76a20116d7c Mon Sep 17 00:00:00 2001 From: iPablo Date: Wed, 2 Dec 2015 18:08:03 +0100 Subject: [PATCH 21/38] Details fixed for PEP-8 --- gecoscc/api/printer_models.py | 2 +- gecoscc/models.py | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gecoscc/api/printer_models.py b/gecoscc/api/printer_models.py index 43bdb7c4..e23cc2e1 100644 --- a/gecoscc/api/printer_models.py +++ b/gecoscc/api/printer_models.py @@ -36,7 +36,7 @@ def get_distinct_filter(self, objects): if self.request.GET.get('manufacturers_list'): objects = objects.distinct('manufacturer') objects.sort() - objects = [{'manufacturer':m, 'model':''} for m in objects] + objects = [{'manufacturer': m, 'model': ''} for m in objects] return objects def set_name_filter(self, query, key_name='manufacturer'): diff --git a/gecoscc/models.py b/gecoscc/models.py index 69a6edae..05aea65f 100644 --- a/gecoscc/models.py +++ b/gecoscc/models.py @@ -212,17 +212,18 @@ class Groups(colander.SequenceSchema): class Setting(colander.MappingSchema): _id = colander.SchemaNode(ObjectIdField()) key = colander.SchemaNode(colander.String(), - title=_('Key'), - default='', - missing='') + title=_('Key'), + default='', + missing='') value = colander.SchemaNode(colander.String('UTF-8'), - title=_('Value'), - default='', - missing='') + title=_('Value'), + default='', + missing='') type = colander.SchemaNode(colander.String(), - title=_('Type'), - default='', - missing='') + title=_('Type'), + default='', + missing='') + class BaseUser(colander.MappingSchema): first_name = colander.SchemaNode(colander.String(), @@ -247,8 +248,8 @@ class User(Node, BaseUser): default='', missing='') commentaries = colander.SchemaNode(colander.String(), - default='', - missing='') + default='', + missing='') memberof = ObjectIdList(missing=[], default=[]) policies = colander.SchemaNode(colander.Mapping(unknown='preserve'), default={}, @@ -478,8 +479,8 @@ class Computer(Node): default='', missing='') commentaries = colander.SchemaNode(colander.String(), - default='', - missing='') + default='', + missing='') policies = colander.SchemaNode(colander.Mapping(unknown='preserve'), default={}, missing={}) From 7e9f9f6e101b89fcdc0c206451e1a20c347ecdc9 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Thu, 3 Dec 2015 11:54:41 +0100 Subject: [PATCH 22/38] refactor object movement --- gecoscc/static/js/app-utils.js | 28 +++++++++++++++++++++++++++ gecoscc/static/js/group-form-views.js | 2 ++ gecoscc/static/js/ou.js | 27 ++++++++++++++++++++++++++ gecoscc/static/js/printer.js | 1 + gecoscc/static/js/repository.js | 2 ++ gecoscc/static/js/storage.js | 1 + gecoscc/static/js/tree-views.js | 18 +++++++++++------ gecoscc/templates/bb-computer.html | 6 +----- gecoscc/templates/bb-groups-form.html | 6 +----- gecoscc/templates/bb-ou.html | 6 +----- gecoscc/templates/bb-printer.html | 6 +----- gecoscc/templates/bb-repository.html | 8 +------- gecoscc/templates/bb-storage.html | 6 +----- gecoscc/templates/bb-user.html | 6 +----- 14 files changed, 80 insertions(+), 43 deletions(-) diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index ab730895..3619251e 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -386,6 +386,34 @@ }, 2000); }, + canMove: function(){ + var $button = this.$('#cut'); + console.log(this.$('#cut') ); + var disable = function(){ + $button.removeClass('btn-warning'); + $button.addClass('btn-group'); + $button.removeAttr('id'); + $button.unbind('click') + $button.css('margin-right','5px'); + }; + + if(this.model.get('type')=='group'){ + if($button.hasClass('admin')==false && this.model.get('members').length != 0){ + disable(); + } + if($button.hasClass('admin')==true && this.model.get('members').length == 0){ + $button.addClass('no-maintenance'); + } + } + if(this.model.get('type')=='storage' || this.model.get('type')=='printer' || this.model.get('type')=='repository'){ + if($button.hasClass('admin')==false && this.model.get('is_assigned') == true){ + disable(); + } + if($button.hasClass('admin')==true && this.model.get('is_assigned') == false){ + $button.addClass('no-maintenance'); + } + } + }, getDomainAttrs: function () { var that = this, diff --git a/gecoscc/static/js/group-form-views.js b/gecoscc/static/js/group-form-views.js index 284cdf3a..a1dc4d46 100644 --- a/gecoscc/static/js/group-form-views.js +++ b/gecoscc/static/js/group-form-views.js @@ -141,6 +141,8 @@ App.module("Group.Views", function (Views, App, Backbone, Marionette, $, _) { }, onRender: function () { + this.canMove(); + if (!_.isUndefined(this.model.id)) { this.$el.find("#name").attr('disabled', 'disabled'); } diff --git a/gecoscc/static/js/ou.js b/gecoscc/static/js/ou.js index 64084dde..cb177647 100644 --- a/gecoscc/static/js/ou.js +++ b/gecoscc/static/js/ou.js @@ -56,8 +56,35 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { policiesList: undefined, onBeforeRender: function () { + var path = this.model.get("path"); + //CHECK IS EMPTY + var id = this.model.get("id"); + + var page = new App.Tree.Models.Container({path:path+','+id}); + + page.goTo(1, { + success: function (data) { + var $button = $('#cut'); + if($button.hasClass('admin')==false && data.models.length != 0){ + $button.removeClass('btn-warning'); + $button.addClass('btn-group'); + $button.removeAttr('id'); + $button.unbind('click') + $button.css('margin-right','5px'); + + } + + if($button.hasClass('admin')==true && data.models.length == 0){ + $button.addClass('no-maintenance'); + } + + + } + }); + //END CHECK IS EMPTY + if (this.model.get("isEditable") !== undefined) { return; } if (path === "root") { diff --git a/gecoscc/static/js/printer.js b/gecoscc/static/js/printer.js index 4eac8c50..e7d97be5 100644 --- a/gecoscc/static/js/printer.js +++ b/gecoscc/static/js/printer.js @@ -82,6 +82,7 @@ App.module("Printer.Views", function (Views, App, Backbone, Marionette, $, _) { }, onRender: function () { + this.canMove(); var promise = $.get(this.modelsAPIUrl + "?manufacturers_list=true"), that = this; diff --git a/gecoscc/static/js/repository.js b/gecoscc/static/js/repository.js index 40a56496..6b5736ac 100644 --- a/gecoscc/static/js/repository.js +++ b/gecoscc/static/js/repository.js @@ -73,6 +73,8 @@ App.module("Repository.Views", function (Views, App, Backbone, Marionette, $, _) }, onRender: function () { + this.canMove(); + if (!_.isUndefined(this.model.id)) { this.$el.find("#name").attr('disabled', 'disabled'); } diff --git a/gecoscc/static/js/storage.js b/gecoscc/static/js/storage.js index 6b3b1f59..a8b2cb28 100644 --- a/gecoscc/static/js/storage.js +++ b/gecoscc/static/js/storage.js @@ -71,6 +71,7 @@ App.module("Storage.Views", function (Views, App, Backbone, Marionette, $, _) { }, onRender: function () { + this.canMove(); if (!_.isUndefined(this.model.id)) { this.$el.find("#name").attr('disabled', 'disabled'); } diff --git a/gecoscc/static/js/tree-views.js b/gecoscc/static/js/tree-views.js index db14cae2..c5ef27f5 100644 --- a/gecoscc/static/js/tree-views.js +++ b/gecoscc/static/js/tree-views.js @@ -259,13 +259,19 @@ App.module("Tree.Views", function (Views, App, Backbone, Marionette, $, _) { $html.find("a.text-warning").click(function (evt) { evt.preventDefault(); - var $modal = $('#maintenance-modal'); - $modal.modal('show'); - $('#set-maintenance').click(function(){ - _.bind(that._pasteOU, ouId)(); - $modal.modal('hide'); - }); + var $button = $('#cut'); + if($button.hasClass('admin') && !$button.hasClass('no-maintenance')){ + var $modal = $('#maintenance-modal'); + $modal.modal('show'); + $('#set-maintenance').click(function(){ + _.bind(that._pasteOU, ouId)(); + $modal.modal('hide'); + }); + }else{ + _.bind(that._pasteOU, ouId)(); + } + }); }, diff --git a/gecoscc/templates/bb-computer.html b/gecoscc/templates/bb-computer.html index 00775653..f88e952a 100644 --- a/gecoscc/templates/bb-computer.html +++ b/gecoscc/templates/bb-computer.html @@ -108,11 +108,7 @@ <% if (typeof id !== "undefined") { %> - {% if request.user and request.user.get('is_superuser') %} - - {% else %} - - {% endif %} + <% } %> <% } %> diff --git a/gecoscc/templates/bb-groups-form.html b/gecoscc/templates/bb-groups-form.html index b9001e61..120dc80f 100644 --- a/gecoscc/templates/bb-groups-form.html +++ b/gecoscc/templates/bb-groups-form.html @@ -34,11 +34,7 @@ <% if (typeof id !== "undefined") { %> - {% if request.user and request.user.get('is_superuser') %} - - {% else %} - - {% endif %} + <% } %> <% } %> diff --git a/gecoscc/templates/bb-ou.html b/gecoscc/templates/bb-ou.html index 4b4e88b0..7a5ffdde 100644 --- a/gecoscc/templates/bb-ou.html +++ b/gecoscc/templates/bb-ou.html @@ -59,11 +59,7 @@ <% if (typeof id !== "undefined") { %> - {% if request.user and request.user.get('is_superuser') %} - - {% else %} - - {% endif %} + <% } %> <% } %> diff --git a/gecoscc/templates/bb-printer.html b/gecoscc/templates/bb-printer.html index dafaaf9b..2ed6b112 100644 --- a/gecoscc/templates/bb-printer.html +++ b/gecoscc/templates/bb-printer.html @@ -105,11 +105,7 @@ <% if (typeof id !== "undefined") { %> - {% if request.user and request.user.get('is_superuser') %} - - {% else %} - - {% endif %} + <% } %> <% } %> diff --git a/gecoscc/templates/bb-repository.html b/gecoscc/templates/bb-repository.html index 9c37789e..831e9efd 100644 --- a/gecoscc/templates/bb-repository.html +++ b/gecoscc/templates/bb-repository.html @@ -69,13 +69,7 @@ <% if (typeof id !== "undefined") { %> - hola - {{request.user.get('is_superuser')}} - {% if request.user and request.user.get('is_superuser') %} - - {% else %} - - {% endif %} + <% } %> <% } %> diff --git a/gecoscc/templates/bb-storage.html b/gecoscc/templates/bb-storage.html index 42998332..8ef90c9d 100644 --- a/gecoscc/templates/bb-storage.html +++ b/gecoscc/templates/bb-storage.html @@ -27,11 +27,7 @@ <% if (typeof id !== "undefined") { %> - {% if request.user and request.user.get('is_superuser') %} - - {% else %} - - {% endif %} + <% } %> <% } %> diff --git a/gecoscc/templates/bb-user.html b/gecoscc/templates/bb-user.html index f3828dfb..c0194da3 100644 --- a/gecoscc/templates/bb-user.html +++ b/gecoscc/templates/bb-user.html @@ -88,11 +88,7 @@ <% if (typeof id !== "undefined") { %> - {% if request.user and request.user.get('is_superuser') %} - - {% else %} - - {% endif %} + <% } %> <% } %> From ca3d724cbc566545f3208e0c85fd5df437829e80 Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 4 Dec 2015 11:19:06 +0100 Subject: [PATCH 23/38] Code fixed --- gecoscc/api/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gecoscc/api/__init__.py b/gecoscc/api/__init__.py index 48bfc86f..416506ab 100644 --- a/gecoscc/api/__init__.py +++ b/gecoscc/api/__init__.py @@ -180,7 +180,7 @@ def get(self): if not node: raise HTTPNotFound() node = self.parse_item(node) - if node['type'] in RESOURCES_EMITTERS_TYPES: + if node.get('type', None) in RESOURCES_EMITTERS_TYPES: node['is_assigned'] = self.is_assigned(node) return node return node From 0a1760462f47bf1c2bca4c69ea4efd410dc57acc Mon Sep 17 00:00:00 2001 From: rastydnb Date: Fri, 4 Dec 2015 13:14:38 +0100 Subject: [PATCH 24/38] fix --- gecoscc/templates/bb-computer.html | 2 +- gecoscc/templates/bb-user.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gecoscc/templates/bb-computer.html b/gecoscc/templates/bb-computer.html index f88e952a..76f5903a 100644 --- a/gecoscc/templates/bb-computer.html +++ b/gecoscc/templates/bb-computer.html @@ -108,7 +108,7 @@ <% if (typeof id !== "undefined") { %> - + <% } %> <% } %> diff --git a/gecoscc/templates/bb-user.html b/gecoscc/templates/bb-user.html index c0194da3..0be8ae37 100644 --- a/gecoscc/templates/bb-user.html +++ b/gecoscc/templates/bb-user.html @@ -88,7 +88,7 @@ <% if (typeof id !== "undefined") { %> - + <% } %> <% } %> From 31a5da37ae3995d106b3edacb3b05647abb8087b Mon Sep 17 00:00:00 2001 From: rastydnb Date: Sun, 6 Dec 2015 17:01:02 +0100 Subject: [PATCH 25/38] fix --- gecoscc/static/js/app-utils.js | 10 +++++++--- gecoscc/static/js/ou.js | 10 +++++++--- gecoscc/static/js/tree-views.js | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index 3619251e..d48805d8 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -388,7 +388,9 @@ }, canMove: function(){ var $button = this.$('#cut'); - console.log(this.$('#cut') ); + if(typeof App.instances.noMaintenance == 'undefined'){ + App.instances.noMaintenance = []; + } var disable = function(){ $button.removeClass('btn-warning'); $button.addClass('btn-group'); @@ -400,17 +402,19 @@ if(this.model.get('type')=='group'){ if($button.hasClass('admin')==false && this.model.get('members').length != 0){ disable(); + App.instances.noMaintenance[this.model.get('id')] = false; } if($button.hasClass('admin')==true && this.model.get('members').length == 0){ - $button.addClass('no-maintenance'); + App.instances.noMaintenance[this.model.get('id')] = true; } } if(this.model.get('type')=='storage' || this.model.get('type')=='printer' || this.model.get('type')=='repository'){ if($button.hasClass('admin')==false && this.model.get('is_assigned') == true){ disable(); + App.instances.noMaintenance[this.model.get('id')] = false; } if($button.hasClass('admin')==true && this.model.get('is_assigned') == false){ - $button.addClass('no-maintenance'); + App.instances.noMaintenance[this.model.get('id')] = true; } } }, diff --git a/gecoscc/static/js/ou.js b/gecoscc/static/js/ou.js index cb177647..5cf1ebd9 100644 --- a/gecoscc/static/js/ou.js +++ b/gecoscc/static/js/ou.js @@ -56,10 +56,13 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { policiesList: undefined, onBeforeRender: function () { - + var that = this; var path = this.model.get("path"); //CHECK IS EMPTY + if(typeof App.instances.noMaintenance == 'undefined'){ + App.instances.noMaintenance = []; + } var id = this.model.get("id"); var page = new App.Tree.Models.Container({path:path+','+id}); @@ -71,13 +74,14 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { $button.removeClass('btn-warning'); $button.addClass('btn-group'); $button.removeAttr('id'); - $button.unbind('click') + $button.unbind('click'); $button.css('margin-right','5px'); + App.instances.noMaintenance[that.model.get('id')] = false; } if($button.hasClass('admin')==true && data.models.length == 0){ - $button.addClass('no-maintenance'); + App.instances.noMaintenance[that.model.get('id')] = true; } diff --git a/gecoscc/static/js/tree-views.js b/gecoscc/static/js/tree-views.js index c5ef27f5..f6796e12 100644 --- a/gecoscc/static/js/tree-views.js +++ b/gecoscc/static/js/tree-views.js @@ -261,7 +261,8 @@ App.module("Tree.Views", function (Views, App, Backbone, Marionette, $, _) { evt.preventDefault(); var $button = $('#cut'); - if($button.hasClass('admin') && !$button.hasClass('no-maintenance')){ + + if($button.hasClass('admin') && !App.instances.noMaintenance[App.instances.cut.get('id')]){ var $modal = $('#maintenance-modal'); $modal.modal('show'); $('#set-maintenance').click(function(){ From f86669117505241b25d8ace98b8afa2c063c9c52 Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 11 Dec 2015 11:55:34 +0100 Subject: [PATCH 26/38] Added translations --- gecoscc/locale/en/LC_MESSAGES/gecoscc.mo | Bin 13177 -> 13335 bytes gecoscc/locale/en/LC_MESSAGES/gecoscc.po | 134 ++++++++++-------- gecoscc/locale/en/LC_MESSAGES/gecoscc_js.mo | Bin 4456 -> 4456 bytes gecoscc/locale/en/LC_MESSAGES/gecoscc_js.po | 2 +- gecoscc/locale/es/LC_MESSAGES/gecoscc.mo | Bin 13581 -> 13747 bytes gecoscc/locale/es/LC_MESSAGES/gecoscc.po | 145 ++++++++++---------- gecoscc/locale/es/LC_MESSAGES/gecoscc_js.mo | Bin 4816 -> 4816 bytes gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po | 2 +- gecoscc/locale/gecoscc.pot | 133 ++++++++++-------- gecoscc/locale/gecoscc_js.pot | 2 +- 10 files changed, 223 insertions(+), 195 deletions(-) diff --git a/gecoscc/locale/en/LC_MESSAGES/gecoscc.mo b/gecoscc/locale/en/LC_MESSAGES/gecoscc.mo index 8e03e70da124aa0914d51f54006a0cc99498a279..3fe0f082d8115773d49640b96f37e61a17b4c7e4 100644 GIT binary patch literal 13335 zcmeI1dz4*OeaANt2!!wukb)rYG>J(dcOFTkWFUsgWF}0R$&7Pnf}#b^+feU%nfjO!*7& z1o$A7{3DR5%@e--pHM2l4BO$+rxkKr;F~F53e|s~=QY0lTDXGxIVimkK#lVOsP)_g zrSC0JdVLnIhIje;FTz!n{}%o#d=#RB`6)aduHZ-g&w^V2MyT~{gPN}gz76j2?KLPn zWKi?(_vH^l&2tm9@HVLN{?xZW2qph8)O?RY$$uY8pC3Z${VLSFC!SHrp8_R!rZ2C7 zvd2cKekG`WJE7J;05$Ij)O=U@_7KW1DU|(gfa?EYsPXQATGwZw=KlkzaSua{_W+b# zz6zz!w|)6Z-~Jrb{6B}9S5DQqD?L|3^?Q@&x$tPp8{iIjKD-D{!tL<0Q1kw)=QB`x z{S0ayFT!)+u>`&5Sp!x7cBnYo2BpV4q5Abg&EN0qN1^n6FO)w5sD9T$*Q{>Pl~C(F6>2@_ z`tlkmxf0YkTcPH?1WN8wsQG(62chgb2DPqtL+LdM6~|4eez!sGBez2f?}w6q9BzQm zLaqDMvx@Q8Ktj`Og1g`jScf-2>GdNhJzntTS3Os<8A<~Q17j`&&?ce;ms0PeJMP4Al59 zLXG<>)INL~L9KEJ)cSWr&GRlOJG~ETeb@T>15o-L^t>5jdhXt|0j3_tjAAI15VdZBYHzdTxY-j465Uf$J#;PiJj$5+AX}B$wzgQ;<&Y{9 zLXH0+sD6jwG4OYw{B%3Sh2}8Sx*mp#`+xHM0hInPK#j9vU17h~Q03F0?DH0={MiI0 zzZEL~yM1{CO8;wMJB)n&r=a5TE~x&0>G_ave+;gm{z-TYd>U$;XQ9^f6DWOOg7WL} z7)^dS8LIvqD0^Q36^|D}t@}Mt{+xo6yB=!&hoIJT2h@Cj1PKXquW$bcsC7R9HUCq- z{O?fn`~+I~3e6Q8(1O_Ct;T5qKi}I8^-q9#mZ4=j*@X z%YO$Y{{+9ZGV{HvhG4Waho zd0+knTuu3IsCEAtJPG~{)cPLt^-n|T^StMaQ0Lz-Ag(cIVQk6wz?0xUD1EC?=iM}v zULS?Zr(2-*$$Oym`X*Grr=j%yDO?9%_T}^13;otZ*{K6ct`BP7L8x=+8n_mI5bE6g zJk-77uc6}U1-Joj?-q_rmp*zYb;B=b-$ua!XM@1InHyD1ToF)&CM--Unsp z_d(6GA1WShfG5M7pzQo9DE;n%vd;rhcKbHed@n#!)*Q37(7OcXmrkg0cS6O2T~C$M zB+2d2m@6-g<4SqbC5CQZ#zd8+b5pF>?P!oq@ziM4=WS&&h-;xQMR9GhBCSkDGhs`( zC^2jr+WDkuvnCJuWRSbkY!K&KN)=6W)w7~z7N$Fokf+qlC#{Ucz>5}lwFA4mhl}=n zzJVE#WXVw_$XU#;pfY88hR5`02a=#_dV;tT)=f{Lz71GRgkVoS$wJeUOv_$D8nH48 z4QW-ixm&l&NlbIm)Xc*apSCo%lR;+dNv(!_6nD`(o``B%Y+-0u6B8=<**4N-9M@=| zxK-!0Uo5+}JWcAhhbi%CPct{WgFL|FIr_~o&qSI`Tg6hA2O8Jx4##Z~4jIoAL97wZUZCNJ&ZhFDLETJ5wC#?vN|06;yiR!v&k@gR z@{hPR52CtiP}Op_-dx6=VlbEdaMP2KcXqul-2^&1rjaWEZj%8D9{HWAfB z(_2VRM_9$iNmVtCe147TP16LI6j9nc*GN(qTRr7{rgskEIADS~k_iV*Bq=k?W_|D4 zz1Q@W?Wm%sZ*#=J3CtPAwlXydJS#RBWrx9cs zj>hFtSg&TARhh|YlEQ<{M%Bf;@7+o(#$`{Kw>2rT*%HnHy~4S$LiD3$fBU3NV|Mw z*E?*5G%}atJ975&a9)3wxR@a!1`4qOmZSo{K-gzfQFgvj*0VpEfuw@}-LG9@@}feq z;@VtD;6(~Gn~-vYLEM}ODmj^)9#O!sRXa`i)u|>v)H)YUNAC~KV3^jzfDAW-giKLY z2qx7C4_3{fe^43@CMkkRlbx`UU=p55ZZpUp@AjR&ePy#(QMNbC$CG4ARMMNh3IAkZ zX-`-VA;&c2WH_PFQ$Z$YuN@ET3463Vf!JbQJkTC9Xfo@(A{SYjg2H2N7k*tM$IEL3 zn$zR-OD0%I&Yn3Gb2QYG*)Xjr(%3#R4B;9(xy&Z1ttM=sLj;9OKRfJ>Gb&_x8q!)o zmbtc|ZpUKwgQBk3;#`dlX2?+)*d3~ASYv}hjU`)QhC-~11!-Ysh`>upvn9uA#*WQt zf(M;TWCS$UeuBQ7RH@BqU)bSnz*f#7k+<35B8{elDR-o$txeDdHA1@040jI}aXUP` z+m4O&n_*5NcE*f{B8|=Pq-^hgy={yi)ou39Bb6l8)xs@6k?aDlwGkL+Hyu;02V2Jo zMQPp)r^>CgMXMVNg+%v|7L^pfO6Pa6sV%7}qHm;o(C}y7;W-ip)lwoKw`MgXVHG16 zDXIA3R?}#N)rBpCoXkldlt0q^ZS<7e()pGFMu<@k=mKcWQ8E%vC+rkU($&|Li@Q@x zz@@Km^4BWY#8pbQxVawTtcAUZ+D1rPXggZ4D0SpfrnZC)N>{pa_u#H>JF~U*u+5YQ zcNM-ZmoFnP%jNQJUnW>gIhc_tIjM@{y&MMIe@p?(nX}+b>gsYXW_hEK_pQ@QH=kCW z+ewN7DbvMBX+)|NDW(#eZtT z)dpL3R{<8lcAeRc6PRm!lNr@Qb2A!dS|8V*Mv&(2<~>S;O(b=;L^ZhGrPz0hgSXmc zB*A8&i4~4PrJ}JHhFKV;;rEV=9h8CG&578eJI0d1;-oMKn}S6)s>Q6Ywd1#56YPAL zw=L<^3RMaE-NtC^#gvYHuqo>o?f^gjB)HS=U7@dV;P4&KdJk%m6Qz%2Og0jYWD9+zpSMhFYQ&lCg@U7jLe4p z#seq*40f|*4HmHw=e3!MY?JHm?o^VH~Q@s6{eR37Qeg|k>Pmf&8z9^hE zR}76@zGq};Y}i~8q%q!W-QTYW>lKB;y8TTbCkM1&JKUX^~FZTi$WX{ zB-89=OJ8c3G|wAd?d?l$L|409yKrk~d(>#O>!|BA*Xq`-pSCJ*Wm7qqB={pgorQW#0oina=*^9=b zeAS*X)?GNnit}A|SHM->cD8L@wfvcB`7;w=oR&W`Eq`WO{>+q_{^ie1%b%H+KQr+a zY56k~?{LeXnU+5@xsO!KpP6_G(U*?p&rG}m>tl|4WncVk)cSm|{F!O_Gt=^CCinlf J{@;9N`d=)%<-h;{ delta 4347 zcmYM$4Q!Rw8Nl(=Qrg=}DHJF&3%yvN1u3-EDn*OdG0P?lH^I1x_z?xFIM4vbRk@(} zHReQ7ghj|k2N?{atgtv>RZP*XD9NDC!8Ybl#>a4kVNeIz{QrGVwx;Rtob#TK=RD`U z_x7b(pU=n~D$aQ^@ROevLMh&rviARSW(0RUrIjkRUreNf^q7&VL?&uyg;``CS7Gn>5GPb{f1=N3r7vn3) z+F>8|!H>}KpP?B@(ddTyqU)7o8S94%3U+8hGjSstz%8+UC%Vu*n8x{N{}u81TD1R0 zbiplX|6OQ6@1TJnLKprA+W!=0?07adWc4*AM2Ze9Lm9T$4x^N-d zejyrY8F~~$(Q$QX2Ck0Jo6t)8~PyDkD&cBrztqmr|80=f6_4r4In?-8%^l|bZ4b#U?Z^%>(K?i zgMN-o$27K}{a?lk+=TAD3z*2x(D4s7aGVx z9EC^Y^AbL-JjyaOV^!!pm!bWy`m)aXf1QFy@GUg5Y0>-8j4VV0c@%k-!&0orHR#U% zh%RspP4y}C_Mby9b>UZ%_ENN7iT1w&y?xZn1oR9YZ z2|B(F4R{w0!cH`>N!v+eT{VVao zPBi83ps&mO=+6I*o@o#A>;!2v1J&q`u0j{Q9y#VPIX<6*W}*cR;IUZ$0e<=Y|2%~> z4_2cSw#N>g=zx9bf(OvRj-vs6f(D*DELpe@+P^>AZ&0ic#~kX_=(sv`T+=Y}-<`q~ z8eI6hn2R%Fhx^c!e;-ZZQ|JWGp%b>EJNr4h^HX)H4Ooj~a4y#426W*Mqo>fo&Y>ImFFJo=Wl}HBQ1B9^ zF&9Um18UHP>tg#gXrN8#QA|R|-HLfQGd`b#UgG)a_$M%h&!O}F8126X%~WPR1>VEZ zh6d1yDf~UUz`+`FIacU>aM|{vAkGLl?U9^XLMFBa*kJA6`p+IL^k|XkZ60&-edu zY&a1;gYMuw8c6mf$v+lF=)iI4SvH{=n~E+t4eftdtly6X)E`0vTM~T{&B%I8v3}S{ z!EduR^b);=?#!i41n?MD~*5S{o0`ceF!STC(gGEj{!)PQDc0=mJQVtX?h(7Y=0 zZ{cAY{1#k-WIe1#2mBTb@lR-=$I)-Sf1!c(9+muKQG$L_)}nz;MaMOx0Y8XCaAB;s zq5*CkMgC3Iw)kKVy6`^q%jgJ}W8UcG>+=%yAB*eIOVxrE*p3GNcO)61cXcvu9C~DT zVk6E&GyE%b13NPmybQb0Oze)ni=O#==nnpd_B)0SJQ+QWetVvc_Nqy~hDV?oy#ae* zbF42wGx;nUNMX@i{cWqS_=g7oi!u99{5c5C`k{_o)zrT~jJ diff --git a/gecoscc/locale/en/LC_MESSAGES/gecoscc.po b/gecoscc/locale/en/LC_MESSAGES/gecoscc.po index 9c6a102c..a80093fe 100644 --- a/gecoscc/locale/en/LC_MESSAGES/gecoscc.po +++ b/gecoscc/locale/en/LC_MESSAGES/gecoscc.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 0.2.2\n" "Report-Msgid-Bugs-To: gecos@guadalinex.org\n" -"POT-Creation-Date: 2015-11-12 12:25+0100\n" +"POT-Creation-Date: 2015-12-11 11:20+0100\n" "PO-Revision-Date: 2014-03-19 11:03+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: en \n" @@ -72,200 +72,200 @@ msgstr "" msgid "Type" msgstr "" -#: gecoscc/models.py:229 gecoscc/templates/bb-user.html:40 +#: gecoscc/models.py:230 gecoscc/templates/bb-user.html:40 #: gecoscc/templates/admins/list.jinja2:33 gecoscc/views/reports.py:80 msgid "First name" msgstr "" -#: gecoscc/models.py:233 gecoscc/templates/bb-user.html:44 +#: gecoscc/models.py:234 gecoscc/templates/bb-user.html:44 #: gecoscc/templates/admins/list.jinja2:34 gecoscc/views/reports.py:81 msgid "Last name" msgstr "" -#: gecoscc/models.py:326 gecoscc/templates/bb-user.html:36 +#: gecoscc/models.py:327 gecoscc/templates/bb-user.html:36 #: gecoscc/templates/login.jinja2:26 gecoscc/templates/admins/list.jinja2:31 #: gecoscc/views/reports.py:79 msgid "Username" msgstr "" -#: gecoscc/models.py:332 gecoscc/templates/login.jinja2:29 +#: gecoscc/models.py:333 gecoscc/templates/login.jinja2:29 msgid "Password" msgstr "" -#: gecoscc/models.py:337 +#: gecoscc/models.py:338 msgid "Repeat the password" msgstr "" -#: gecoscc/models.py:341 gecoscc/templates/bb-user.html:50 +#: gecoscc/models.py:342 gecoscc/templates/bb-user.html:50 #: gecoscc/views/reports.py:82 msgid "Email" msgstr "" -#: gecoscc/models.py:348 +#: gecoscc/models.py:349 msgid "There is a user with this email: ${val}" msgstr "" -#: gecoscc/models.py:349 +#: gecoscc/models.py:350 msgid "There is a user with this username: ${val}" msgstr "" -#: gecoscc/models.py:354 +#: gecoscc/models.py:355 msgid "This user can register workstation under these Organitation Units" msgstr "" -#: gecoscc/models.py:357 +#: gecoscc/models.py:358 msgid "Organitation Unit availables to register workstations by this user" msgstr "" -#: gecoscc/models.py:367 +#: gecoscc/models.py:368 msgid "uri" msgstr "" -#: gecoscc/models.py:370 +#: gecoscc/models.py:371 msgid "base" msgstr "" -#: gecoscc/models.py:373 +#: gecoscc/models.py:374 msgid "base group" msgstr "" -#: gecoscc/models.py:376 +#: gecoscc/models.py:377 msgid "binddn" msgstr "" -#: gecoscc/models.py:379 +#: gecoscc/models.py:380 msgid "bindpwd" msgstr "" -#: gecoscc/models.py:385 +#: gecoscc/models.py:386 msgid "FQDN" msgstr "" -#: gecoscc/models.py:387 +#: gecoscc/models.py:388 msgid "WORKGROUP" msgstr "" -#: gecoscc/models.py:393 +#: gecoscc/models.py:394 msgid "SSSD conf" msgstr "" -#: gecoscc/models.py:396 +#: gecoscc/models.py:397 msgid "KRB5 conf" msgstr "" -#: gecoscc/models.py:399 +#: gecoscc/models.py:400 msgid "SMB conf" msgstr "" -#: gecoscc/models.py:402 +#: gecoscc/models.py:403 msgid "PAM conf" msgstr "" -#: gecoscc/models.py:411 +#: gecoscc/models.py:412 msgid "URI ntp" msgstr "" -#: gecoscc/models.py:413 +#: gecoscc/models.py:414 msgid "Auth type" msgstr "" -#: gecoscc/models.py:417 +#: gecoscc/models.py:418 msgid "Specific conf" msgstr "" -#: gecoscc/models.py:419 +#: gecoscc/models.py:420 msgid "Auth LDAP" msgstr "" -#: gecoscc/models.py:420 gecoscc/models.py:421 +#: gecoscc/models.py:421 gecoscc/models.py:422 msgid "Auth Active directory" msgstr "" -#: gecoscc/models.py:461 gecoscc/templates/bb-computer.html:59 +#: gecoscc/models.py:462 gecoscc/templates/bb-computer.html:59 msgid "Desktop" msgstr "" -#: gecoscc/models.py:462 gecoscc/templates/bb-computer.html:60 +#: gecoscc/models.py:463 gecoscc/templates/bb-computer.html:60 msgid "Laptop" msgstr "" -#: gecoscc/models.py:463 gecoscc/templates/bb-computer.html:61 +#: gecoscc/models.py:464 gecoscc/templates/bb-computer.html:61 msgid "Netbook" msgstr "" -#: gecoscc/models.py:464 gecoscc/templates/bb-computer.html:62 +#: gecoscc/models.py:465 gecoscc/templates/bb-computer.html:62 msgid "Tablet" msgstr "" -#: gecoscc/models.py:500 gecoscc/templates/bb-printer.html:69 +#: gecoscc/models.py:501 gecoscc/templates/bb-printer.html:69 msgid "Laser" msgstr "" -#: gecoscc/models.py:501 gecoscc/templates/bb-printer.html:70 +#: gecoscc/models.py:502 gecoscc/templates/bb-printer.html:70 msgid "Ink" msgstr "" -#: gecoscc/models.py:502 gecoscc/templates/bb-printer.html:71 +#: gecoscc/models.py:503 gecoscc/templates/bb-printer.html:71 msgid "Dot matrix" msgstr "" -#: gecoscc/models.py:506 gecoscc/templates/bb-printer.html:35 +#: gecoscc/models.py:507 gecoscc/templates/bb-printer.html:35 msgid "Network" msgstr "" -#: gecoscc/models.py:507 gecoscc/templates/bb-printer.html:36 +#: gecoscc/models.py:508 gecoscc/templates/bb-printer.html:36 msgid "Local" msgstr "" -#: gecoscc/models.py:511 gecoscc/templates/bb-printer.html:52 +#: gecoscc/models.py:512 gecoscc/templates/bb-printer.html:52 msgid "Default" msgstr "" -#: gecoscc/models.py:512 gecoscc/templates/bb-printer.html:53 +#: gecoscc/models.py:513 gecoscc/templates/bb-printer.html:53 msgid "Authenticated" msgstr "" -#: gecoscc/models.py:557 +#: gecoscc/models.py:558 msgid "FTP" msgstr "" -#: gecoscc/models.py:558 +#: gecoscc/models.py:559 msgid "SSHFS" msgstr "" -#: gecoscc/models.py:559 +#: gecoscc/models.py:560 msgid "NFS" msgstr "" -#: gecoscc/models.py:560 +#: gecoscc/models.py:561 msgid "SAMBA v3" msgstr "" -#: gecoscc/models.py:561 +#: gecoscc/models.py:562 msgid "SAMBA v4" msgstr "" -#: gecoscc/models.py:565 +#: gecoscc/models.py:566 msgid "System mounts (fstab)" msgstr "" -#: gecoscc/models.py:566 +#: gecoscc/models.py:567 msgid "User space mounts (gvfs)" msgstr "" -#: gecoscc/models.py:597 +#: gecoscc/models.py:598 msgid "Processing" msgstr "" -#: gecoscc/models.py:600 +#: gecoscc/models.py:601 msgid "Applying changes" msgstr "" -#: gecoscc/models.py:603 +#: gecoscc/models.py:604 msgid "Changes applied" msgstr "" -#: gecoscc/models.py:606 gecoscc/models.py:609 +#: gecoscc/models.py:607 gecoscc/models.py:610 msgid "There were errors" msgstr "" @@ -368,7 +368,25 @@ msgstr "" msgid "Search" msgstr "" -#: gecoscc/templates/base_tree.jinja2:206 gecoscc/templates/bb-computer.html:93 +#: gecoscc/templates/base_tree.jinja2:136 +msgid "This action requires a little time" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:139 +msgid "Is the website maintenance?" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:142 +#: gecoscc/templates/admins/list.jinja2:49 +msgid "No" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:143 +#: gecoscc/templates/admins/list.jinja2:47 +msgid "Yes" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:224 gecoscc/templates/bb-computer.html:93 #: gecoscc/templates/bb-groups-form.html:27 gecoscc/templates/bb-user.html:74 msgid "Loading" msgstr "" @@ -525,7 +543,11 @@ msgstr "" msgid "Save" msgstr "" -#: gecoscc/templates/bb-computer.html:111 gecoscc/templates/bb-user.html:91 +#: gecoscc/templates/bb-computer.html:111 +#: gecoscc/templates/bb-groups-form.html:37 gecoscc/templates/bb-ou.html:62 +#: gecoscc/templates/bb-printer.html:108 +#: gecoscc/templates/bb-repository.html:72 gecoscc/templates/bb-storage.html:30 +#: gecoscc/templates/bb-user.html:91 msgid "Cut" msgstr "" @@ -579,7 +601,7 @@ msgid "Data retrieved from workstation" msgstr "" #: gecoscc/templates/bb-computer.html:202 -#: gecoscc/templates/bb-groups-form.html:48 gecoscc/templates/bb-ou.html:73 +#: gecoscc/templates/bb-groups-form.html:49 gecoscc/templates/bb-ou.html:74 #: gecoscc/templates/bb-user.html:103 msgid "Policies list" msgstr "" @@ -1034,14 +1056,6 @@ msgstr "" msgid "Is superuser?" msgstr "" -#: gecoscc/templates/admins/list.jinja2:47 -msgid "Yes" -msgstr "" - -#: gecoscc/templates/admins/list.jinja2:49 -msgid "No" -msgstr "" - #: gecoscc/templates/admins/ou_manage.jinja2:52 msgid "Select an Organisational Unit" msgstr "" diff --git a/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.mo b/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.mo index f6e2cc92993ea14929fcee8a4c144f4578810beb..46b937da83901f4e558edf0a7be27602a653ed14 100644 GIT binary patch delta 23 ecmaE%^g?NaG8dPTuA!lVp`n$L!Dd}9Yjyxurv?WA delta 23 ecmaE%^g?NaG8dPjuAz~Fp^=r5>1JInYjyxu%LWYq diff --git a/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.po b/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.po index 17215431..f4d6fffa 100644 --- a/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.po +++ b/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 0.2.2\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2015-11-12 12:25+0100\n" +"POT-Creation-Date: 2015-12-11 11:20+0100\n" "PO-Revision-Date: 2014-03-19 11:03+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: en \n" diff --git a/gecoscc/locale/es/LC_MESSAGES/gecoscc.mo b/gecoscc/locale/es/LC_MESSAGES/gecoscc.mo index f8e9d9809a70a3339d64ea2233ed5d8ab40e5557..2197097fbe8dec5339f210e9229ddf264a5d8daa 100644 GIT binary patch delta 4322 zcmX}u4Um;p8Nl(we!#MeAh^2{?7~I9mX(iPSWG^O0c%)F$y}Mtj9lRrmUfqAxeJUj zTs|amz+4?@vM7y`D6FUpqS%Ndpr$PUz)Bo>16SH%F?|I*I&hwn- zocCVtS(5!`=Jf#u+k*dkgirw$MW3|(|50&i2<5aY@l#lb!*DM4!Zz%Qt1urk*dI4w zC2qqK%wj)07<~~hp?f&Rg%h2{LOdVa-Po6QKC|`40my(*fjkP;u{{mVc@9p%8{+-- zSVp@O9ltZWCq6%b1;h`}abf0N=tM80D>{K@{5LeQbJzzzjQ0x$giuVo6tBRc$fGa| zFT)$r@r%)gtU}}5g+p;OmJmPe=E4f>M*|;>?Pt&cM=^!R(NcaCpZ6q+{rjSU%FzBJ z(L`#{glD0Fzl8R0K>OW{8E+(96kszta2Yyq1G@4~H1K!P{yXCHpQBsyC|bG0==d&l zzEf!6H_`dtLgzV;R-{KM^*57COLI2{qaCWzz*nIGr=t^I6Rk(bU59yi6MhE2hF9YQ zI0cWP^Y!5%=s+}~5oqF7Wz>H#7guq^05`-3UqKH|f+nyO9k>Dwd`G;$5lwUpx&`;6 z<9481`bd1f7aey1t<({8zM~l~?05_<(Fyc*JA(%P7#&c^O(*V)wg;kthsE}2bcHqO zLZ-*|Otjy1=(q+n@GWS+%&lCQKoV_1OWJ|1Xcd~+CiK*9LkI3dzb_783SUF}U%=5= zbb0PItwFXs%*0tZ51a9ONJ5!VI53w$Uo^w==ukBCDl~!dI3B0P=S$E%T#i<19lDTB zX#Y;M(J6pLr?c?^z?o;x)|-Z z64|Y=23_%1G@)H+B74vUJ`p{vzW-fZxYAeAJwAz+_%xcxJ7|DzbmF{0xv$o8v|Wd; zxE>8O53S6t$XY@xR^wghLVp{dAHj?n{gI0ycoGfVjlLCr_{~;<2AY9R+<+$3h$C=u zY~O<>uobPugYo`8H1O}x-;Nh?IG!6!{fQOII7xL_gC3FuJw&_E%wNK>*o_XX;+Ms( zxE4)tKF-8-XeAG!3;8{|*GJK6_gpMSqg{aRCL^YG|-~xQsh++E75-Uq6^3(70iUExZpb@97iX956!%Q-cHyL zZ4X4>hT-V@JSnz6hn|HSWBYcr{|cOh>(KuDkhO+q&^V{D-1q+@E-YRD5xEr)#eCYM z&;+WZlh8oZ(aOw4w`d-Ex*KCVjT30EMFZ|Z7x)r7{!H{D_9T8Nq5kgi0Cd7}XbGpF zfo8^beSCgBj^h3;Xel?KXQ(qi|2`UMCt8WeV*3!f&{wb!-@uH4{>gw_ETH`$TG^kXTe)i#^*6v{vEv`GC+$<{ zM5m+Yv5?vA56vRxH`5UM-%TxE7z-v`a4l+Rc-}?kn-T)?eQ4oFHGUX?}3HrmaoS7zW<$Eba3Nc zEW+f<+=Q)Ydj+~@8SIUl(L}c4Ec^u)<5_g#3uwPSV{?|H_fu%UI&^Dhd?Ne*WiG71 z0yN+v^mS~*dfbdo@F#TQx6lgw2c0N?T<+JdEP5qc;+bfL>f`+-==^K31n;)(`@bzd z_)+v{=posI27DAP@l)u^pF;!u75PC7Z=#2`$M{@gBhbVqqk(3}`weLSh3LZ8Va6NJ zbK%5iurK}>`Em*+e2sZ{YLFkoFd6Hx0o}_@Xr&%P6M6#4B|IJ5?_odMAEF8Ns>v;+ z8XZ5ehW+=!7r4O>UucPLLH@#SKIY&_oP?ulL*Osm%tsY&!O6G}{SU`G=ppPek>3Lx ziB|FsbRlcet=@=M^zMn&-;4XW(FY$uSF$s9{3SZUZ_s}G(O5t?8t-v2{U`EiJpOsIqZEx@l=^sy$iO(bS$S zPc^2Ro6_m#B$aMzNwUK#llApwluq@_TK#e E0pQiL4gdfE delta 4167 zcmYM$3v8Cv8Nl%~dcO#i3bjI6DMea^LR-k>Iw65UWDZC}z?l&QF_Y>b3K^RDv5N|l zZ3+&vLc}cKaIVPsX4Gx2b75ZQWx-*FMYjobVS&M>l`sXm|G(dpj3B>r&U-G;dCqy? z&+MA--;w$2ko+Gd{#@q25&TzPZ0-MlE)Gg*7}ZNyjaLp%X%seL5iZ0+T#9+P94l}o z*5G<9!|livX?OT6UXfBJby0Alx3B=;jruVhNc{ws;77=SbP@TRN?FDFa5UydoPaIS zek%^8z7`$-VE9Np@4$T4Px~ksc_%v2FVG$R3XS+>G_b>1j(>^vlUPc<7wfPO`J3v7 zq*RHM(DC!ojVwjixg9@`Yp{&<(^d**;Bj=}-BEuEU0^@f;)`f1yW{yk(Eex9g+4+1 z7qGg43`PU4Ll>Ta_HRY|O~s52b13BF0(9Uabl^&K=WEf0H=zB$6VJDxN3a9U+#Ym% zCpupjy6_=%zSq!s-bFL=VI}!Dl7C0TXVIbb%G|=k&;>`J6OIlW&~f8&0A7zXa2j5Z z8*vIAL>D|0UO)rN=VBOm@lf*b#KWRtIC@zcu|HMlfT`$$GoyVznwf=Y>X)G7R-;F` zHlBYI9d|#Pp)Kfq+t7YHG89bB6Xf=m6Yc*S9E)$FuV*iE znyH{FrP)}G?RX3JZwv__lirDj?(hT}`582TkFW{*;(60mxwHEMnyESHP8Oj3+t8G+ zKm%zHzlCPt2WSA>aER~!P6}R@{pe0kp%Y&~Q`v{!>M}lm-rAaQ9NKRhlKnIr-SJX1 zpmsEnd(Z_l;pXsBEb#sBpx_xliKh5xXdus`3v{6qzk+^JyQ6*q-EsNVxrM6HTV0RD zoLcZ&yb<{{qz&EgoNeV99g~Ra>`bGOYx^NziPF#fsGzRN&T+|n#J6(!q zVr8^%L>JzK{$^~)(fAxPb$V|&`JY6gmj*9MBR9)S)Q(2}7>>g(bl@56|FV&WS=8&$ zyRr)1z#Zrre*-;&yTkj?qx>$qfghs%cGSfC-$8>D>_)Ph_JqI1G1QNuDZPxQyo$70 zuSZik0}W&@I(|XaS0jH@JO4QUR`jSJLGMzB`8UN+qY=J@rsj1tWhc=E3wZ|{u@a4Z z26`m3(22i-9zh$r!{ulOR>$+Z@E+=SqZ>LE?U{kKxgAuZ14p0>jK&8($8n$mb`p&{ zdl^ULF?8pB=t9L@7#)nfsp%@T-$Zl+ZD__;AfJYGFEVc?JxamI_o5RXi294@TW|<{ zkB>yX2fYKIM7@Yr9AAa4Scmpsf^0I~j&9%~bm5(7<_=<^@Bi;8O*k?^-<`8i_nGEq2o7)9q2qiM~^s*{lEWjQ!sVi(cyU1|7i!> z|AW`yB{Y@w9H5t|8GSwtUFb__CYD8g6}r<6Sb*O{*LfHnzYQ~{W)}q`JAl@oM+d$U z_4m+){)GU*&epNaaxsK0;)*cHBov#1}#=~y#1SHBqzd>5LzedxT;p#l7QEaz{eZ_{83|BUXi z2Mh5WI^aAy;9@)<)R22#jgG5D$F*QFPDjVhL679da0!}`74iJGOcd6j8CZu!xCxzb zbGR+sg$DK%I&mjD?gexsucEjAO|;(!Xup%_!snv>V|1O&r_nH=G57mlg8W}nDn}<8 zg}maa1s%|aya4GIB-?2ddbU5sYw>yX{XdSL^{4nX9LU4miI?=b$U$^by(`bsj&Rac^+kPNQ*Ped&^vQ4X85M0Efl;w z`;i~Gltq7*52I&U$mh*3)<`se&3F_Wu$0PVY()3`F^ffzzZlD`IHE`Sb={;&-{IKd=ENrA9^\n" "Language-Team: es \n" @@ -71,204 +71,204 @@ msgstr "Valor" msgid "Type" msgstr "Tipo" -#: gecoscc/models.py:229 gecoscc/templates/bb-user.html:40 +#: gecoscc/models.py:230 gecoscc/templates/bb-user.html:40 #: gecoscc/templates/admins/list.jinja2:33 gecoscc/views/reports.py:80 msgid "First name" msgstr "Nombre" -#: gecoscc/models.py:233 gecoscc/templates/bb-user.html:44 +#: gecoscc/models.py:234 gecoscc/templates/bb-user.html:44 #: gecoscc/templates/admins/list.jinja2:34 gecoscc/views/reports.py:81 msgid "Last name" msgstr "Apellidos" -#: gecoscc/models.py:326 gecoscc/templates/bb-user.html:36 +#: gecoscc/models.py:327 gecoscc/templates/bb-user.html:36 #: gecoscc/templates/login.jinja2:26 gecoscc/templates/admins/list.jinja2:31 #: gecoscc/views/reports.py:79 msgid "Username" msgstr "Nombre de usuario" -#: gecoscc/models.py:332 gecoscc/templates/login.jinja2:29 +#: gecoscc/models.py:333 gecoscc/templates/login.jinja2:29 msgid "Password" msgstr "Contraseña" -#: gecoscc/models.py:337 +#: gecoscc/models.py:338 msgid "Repeat the password" msgstr "Repite la contraseña" -#: gecoscc/models.py:341 gecoscc/templates/bb-user.html:50 +#: gecoscc/models.py:342 gecoscc/templates/bb-user.html:50 #: gecoscc/views/reports.py:82 msgid "Email" msgstr "Correo electrónico" -#: gecoscc/models.py:348 +#: gecoscc/models.py:349 msgid "There is a user with this email: ${val}" msgstr "Hay un usuario con este correo electrónico: ${val}" -#: gecoscc/models.py:349 +#: gecoscc/models.py:350 msgid "There is a user with this username: ${val}" msgstr "Hay un usuario con este nombre de usuario: ${val}" -#: gecoscc/models.py:354 +#: gecoscc/models.py:355 msgid "This user can register workstation under these Organitation Units" msgstr "" "Este usuario puede registrar estaciones de trabajo bajo estas unidades " "organizativas" -#: gecoscc/models.py:357 +#: gecoscc/models.py:358 msgid "Organitation Unit availables to register workstations by this user" msgstr "" "Unidades organizativas disponibles para que este usuario pueda registrar " "estaciones de trabajo" -#: gecoscc/models.py:367 +#: gecoscc/models.py:368 msgid "uri" msgstr "uri" -#: gecoscc/models.py:370 +#: gecoscc/models.py:371 msgid "base" msgstr "" -#: gecoscc/models.py:373 +#: gecoscc/models.py:374 msgid "base group" msgstr "" -#: gecoscc/models.py:376 +#: gecoscc/models.py:377 msgid "binddn" msgstr "" -#: gecoscc/models.py:379 +#: gecoscc/models.py:380 msgid "bindpwd" msgstr "" -#: gecoscc/models.py:385 +#: gecoscc/models.py:386 msgid "FQDN" msgstr "" -#: gecoscc/models.py:387 +#: gecoscc/models.py:388 msgid "WORKGROUP" msgstr "" -#: gecoscc/models.py:393 +#: gecoscc/models.py:394 msgid "SSSD conf" msgstr "" -#: gecoscc/models.py:396 +#: gecoscc/models.py:397 msgid "KRB5 conf" msgstr "" -#: gecoscc/models.py:399 +#: gecoscc/models.py:400 msgid "SMB conf" msgstr "" -#: gecoscc/models.py:402 +#: gecoscc/models.py:403 msgid "PAM conf" msgstr "" -#: gecoscc/models.py:411 +#: gecoscc/models.py:412 msgid "URI ntp" msgstr "" -#: gecoscc/models.py:413 +#: gecoscc/models.py:414 msgid "Auth type" msgstr "Tipo de autenticación" -#: gecoscc/models.py:417 +#: gecoscc/models.py:418 msgid "Specific conf" msgstr "Configuración específica" -#: gecoscc/models.py:419 +#: gecoscc/models.py:420 msgid "Auth LDAP" msgstr "Autenticación LDAP" -#: gecoscc/models.py:420 gecoscc/models.py:421 +#: gecoscc/models.py:421 gecoscc/models.py:422 msgid "Auth Active directory" msgstr "Autenticación Active directory" -#: gecoscc/models.py:461 gecoscc/templates/bb-computer.html:59 +#: gecoscc/models.py:462 gecoscc/templates/bb-computer.html:59 msgid "Desktop" msgstr "Sobremesa" -#: gecoscc/models.py:462 gecoscc/templates/bb-computer.html:60 +#: gecoscc/models.py:463 gecoscc/templates/bb-computer.html:60 msgid "Laptop" msgstr "Portátil" -#: gecoscc/models.py:463 gecoscc/templates/bb-computer.html:61 +#: gecoscc/models.py:464 gecoscc/templates/bb-computer.html:61 msgid "Netbook" msgstr "" -#: gecoscc/models.py:464 gecoscc/templates/bb-computer.html:62 +#: gecoscc/models.py:465 gecoscc/templates/bb-computer.html:62 msgid "Tablet" msgstr "Tableta" -#: gecoscc/models.py:500 gecoscc/templates/bb-printer.html:69 +#: gecoscc/models.py:501 gecoscc/templates/bb-printer.html:69 msgid "Laser" msgstr "Láser" -#: gecoscc/models.py:501 gecoscc/templates/bb-printer.html:70 +#: gecoscc/models.py:502 gecoscc/templates/bb-printer.html:70 msgid "Ink" msgstr "Tinta" -#: gecoscc/models.py:502 gecoscc/templates/bb-printer.html:71 +#: gecoscc/models.py:503 gecoscc/templates/bb-printer.html:71 msgid "Dot matrix" msgstr "Matricial" -#: gecoscc/models.py:506 gecoscc/templates/bb-printer.html:35 +#: gecoscc/models.py:507 gecoscc/templates/bb-printer.html:35 msgid "Network" msgstr "En red" -#: gecoscc/models.py:507 gecoscc/templates/bb-printer.html:36 +#: gecoscc/models.py:508 gecoscc/templates/bb-printer.html:36 msgid "Local" msgstr "Local" -#: gecoscc/models.py:511 gecoscc/templates/bb-printer.html:52 +#: gecoscc/models.py:512 gecoscc/templates/bb-printer.html:52 msgid "Default" msgstr "" -#: gecoscc/models.py:512 gecoscc/templates/bb-printer.html:53 +#: gecoscc/models.py:513 gecoscc/templates/bb-printer.html:53 msgid "Authenticated" msgstr "" -#: gecoscc/models.py:557 +#: gecoscc/models.py:558 msgid "FTP" msgstr "" -#: gecoscc/models.py:558 +#: gecoscc/models.py:559 msgid "SSHFS" msgstr "" -#: gecoscc/models.py:559 +#: gecoscc/models.py:560 msgid "NFS" msgstr "" -#: gecoscc/models.py:560 +#: gecoscc/models.py:561 msgid "SAMBA v3" msgstr "" -#: gecoscc/models.py:561 +#: gecoscc/models.py:562 msgid "SAMBA v4" msgstr "" -#: gecoscc/models.py:565 +#: gecoscc/models.py:566 msgid "System mounts (fstab)" msgstr "En el arranque del sistema (fstab)" -#: gecoscc/models.py:566 +#: gecoscc/models.py:567 msgid "User space mounts (gvfs)" msgstr "En espacio de usuario (gvfs)" -#: gecoscc/models.py:597 +#: gecoscc/models.py:598 msgid "Processing" msgstr "Procesando" -#: gecoscc/models.py:600 +#: gecoscc/models.py:601 msgid "Applying changes" msgstr "Aplicando cambios" -#: gecoscc/models.py:603 +#: gecoscc/models.py:604 msgid "Changes applied" msgstr "Cambios aplicados" -#: gecoscc/models.py:606 gecoscc/models.py:609 +#: gecoscc/models.py:607 gecoscc/models.py:610 msgid "There were errors" msgstr "Se produjeron errores" @@ -371,7 +371,25 @@ msgstr "Salir" msgid "Search" msgstr "Buscar" -#: gecoscc/templates/base_tree.jinja2:206 gecoscc/templates/bb-computer.html:93 +#: gecoscc/templates/base_tree.jinja2:136 +msgid "This action requires a little time" +msgstr "Esta acción puede llevar un tiempo" + +#: gecoscc/templates/base_tree.jinja2:139 +msgid "Is the website maintenance?" +msgstr "¿Esta el portal en mantenimiento?" + +#: gecoscc/templates/base_tree.jinja2:142 +#: gecoscc/templates/admins/list.jinja2:49 +msgid "No" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:143 +#: gecoscc/templates/admins/list.jinja2:47 +msgid "Yes" +msgstr "Si" + +#: gecoscc/templates/base_tree.jinja2:224 gecoscc/templates/bb-computer.html:93 #: gecoscc/templates/bb-groups-form.html:27 gecoscc/templates/bb-user.html:74 msgid "Loading" msgstr "Cargando" @@ -530,7 +548,11 @@ msgstr "Si tu quieres añadir un grupo, por favor encola los cambios" msgid "Save" msgstr "Guardar" -#: gecoscc/templates/bb-computer.html:111 gecoscc/templates/bb-user.html:91 +#: gecoscc/templates/bb-computer.html:111 +#: gecoscc/templates/bb-groups-form.html:37 gecoscc/templates/bb-ou.html:62 +#: gecoscc/templates/bb-printer.html:108 +#: gecoscc/templates/bb-repository.html:72 gecoscc/templates/bb-storage.html:30 +#: gecoscc/templates/bb-user.html:91 msgid "Cut" msgstr "Cortar" @@ -584,7 +606,7 @@ msgid "Data retrieved from workstation" msgstr "Datos extraidos del puesto" #: gecoscc/templates/bb-computer.html:202 -#: gecoscc/templates/bb-groups-form.html:48 gecoscc/templates/bb-ou.html:73 +#: gecoscc/templates/bb-groups-form.html:49 gecoscc/templates/bb-ou.html:74 #: gecoscc/templates/bb-user.html:103 msgid "Policies list" msgstr "Lista de políticas" @@ -1041,14 +1063,6 @@ msgstr "Correo electrónico" msgid "Is superuser?" msgstr "¿Es superusuario?" -#: gecoscc/templates/admins/list.jinja2:47 -msgid "Yes" -msgstr "Si" - -#: gecoscc/templates/admins/list.jinja2:49 -msgid "No" -msgstr "" - #: gecoscc/templates/admins/ou_manage.jinja2:52 msgid "Select an Organisational Unit" msgstr "Selecciona una Unidad Organizativa" @@ -1058,25 +1072,21 @@ msgstr "Selecciona una Unidad Organizativa" #: gecoscc/templates/server/status.jinja2:8 #: gecoscc/templates/server/status.jinja2:11 #, fuzzy -#| msgid "Key server" msgid "Servers" msgstr "Servidor de claves" #: gecoscc/templates/server/connections.jinja2:11 #, fuzzy -#| msgid "Last connection" msgid "Server connections" msgstr "Última conexión" #: gecoscc/templates/server/connections.jinja2:21 #, fuzzy -#| msgid "Device" msgid "Service" msgstr "Dispositivo" #: gecoscc/templates/server/connections.jinja2:22 #, fuzzy -#| msgid "IP address" msgid "Local IP address" msgstr "Dirección IP" @@ -1090,19 +1100,16 @@ msgstr "" #: gecoscc/templates/server/connections.jinja2:25 #, fuzzy -#| msgid "Remote storage" msgid "Remote port" msgstr "Almacenamiento remoto" #: gecoscc/templates/server/log.jinja2:11 #, fuzzy -#| msgid "Key server" msgid "Server log" msgstr "Servidor de claves" #: gecoscc/templates/server/log.jinja2:23 #, fuzzy -#| msgid "Processing" msgid "Process" msgstr "Procesando" @@ -1125,19 +1132,16 @@ msgstr "" #: gecoscc/templates/server/status.jinja2:34 #, fuzzy -#| msgid "Auth type" msgid "FS Type" msgstr "Tipo de autenticación" #: gecoscc/templates/server/status.jinja2:35 #, fuzzy -#| msgid "User options" msgid "Options" msgstr "Opciones de usuario" #: gecoscc/templates/server/status.jinja2:68 #, fuzzy -#| msgid "IP address" msgid "IP Address" msgstr "Dirección IP" @@ -1159,7 +1163,6 @@ msgstr "" #: gecoscc/templates/server/status.jinja2:96 #, fuzzy -#| msgid "Last connection" msgid "Connections" msgstr "Última conexión" diff --git a/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.mo b/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.mo index 54ff1620e7c10de77e6416831deeba7c3d4ad170..74088ced7f0ff834fabefa92f4da3fd80cf25cbd 100644 GIT binary patch delta 23 ecmcbhdO>xA78jS1uA!lVp`n$L!DbV#IUE2~Vg^kB delta 23 ecmcbhdO>xA78jSHuAz~Fp^=r5>1GqIIUE2~h6Ymr diff --git a/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po b/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po index ea7d6db8..afc5dbdc 100644 --- a/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po +++ b/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 0.2.1\n" "Report-Msgid-Bugs-To: gecos@guadalinex.org\n" -"POT-Creation-Date: 2015-11-12 12:25+0100\n" +"POT-Creation-Date: 2015-12-11 11:20+0100\n" "PO-Revision-Date: 2014-03-07 13:25+0100\n" "Last-Translator: Alejandro Blanco \n" "Language-Team: es \n" diff --git a/gecoscc/locale/gecoscc.pot b/gecoscc/locale/gecoscc.pot index 58930a22..3ab4ebdf 100644 --- a/gecoscc/locale/gecoscc.pot +++ b/gecoscc/locale/gecoscc.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 2.1.10\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2015-11-12 12:25+0100\n" +"POT-Creation-Date: 2015-12-11 11:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -72,200 +72,200 @@ msgstr "" msgid "Type" msgstr "" -#: gecoscc/models.py:229 gecoscc/templates/bb-user.html:40 +#: gecoscc/models.py:230 gecoscc/templates/bb-user.html:40 #: gecoscc/templates/admins/list.jinja2:33 gecoscc/views/reports.py:80 msgid "First name" msgstr "" -#: gecoscc/models.py:233 gecoscc/templates/bb-user.html:44 +#: gecoscc/models.py:234 gecoscc/templates/bb-user.html:44 #: gecoscc/templates/admins/list.jinja2:34 gecoscc/views/reports.py:81 msgid "Last name" msgstr "" -#: gecoscc/models.py:326 gecoscc/templates/bb-user.html:36 +#: gecoscc/models.py:327 gecoscc/templates/bb-user.html:36 #: gecoscc/templates/login.jinja2:26 gecoscc/templates/admins/list.jinja2:31 #: gecoscc/views/reports.py:79 msgid "Username" msgstr "" -#: gecoscc/models.py:332 gecoscc/templates/login.jinja2:29 +#: gecoscc/models.py:333 gecoscc/templates/login.jinja2:29 msgid "Password" msgstr "" -#: gecoscc/models.py:337 +#: gecoscc/models.py:338 msgid "Repeat the password" msgstr "" -#: gecoscc/models.py:341 gecoscc/templates/bb-user.html:50 +#: gecoscc/models.py:342 gecoscc/templates/bb-user.html:50 #: gecoscc/views/reports.py:82 msgid "Email" msgstr "" -#: gecoscc/models.py:348 +#: gecoscc/models.py:349 msgid "There is a user with this email: ${val}" msgstr "" -#: gecoscc/models.py:349 +#: gecoscc/models.py:350 msgid "There is a user with this username: ${val}" msgstr "" -#: gecoscc/models.py:354 +#: gecoscc/models.py:355 msgid "This user can register workstation under these Organitation Units" msgstr "" -#: gecoscc/models.py:357 +#: gecoscc/models.py:358 msgid "Organitation Unit availables to register workstations by this user" msgstr "" -#: gecoscc/models.py:367 +#: gecoscc/models.py:368 msgid "uri" msgstr "" -#: gecoscc/models.py:370 +#: gecoscc/models.py:371 msgid "base" msgstr "" -#: gecoscc/models.py:373 +#: gecoscc/models.py:374 msgid "base group" msgstr "" -#: gecoscc/models.py:376 +#: gecoscc/models.py:377 msgid "binddn" msgstr "" -#: gecoscc/models.py:379 +#: gecoscc/models.py:380 msgid "bindpwd" msgstr "" -#: gecoscc/models.py:385 +#: gecoscc/models.py:386 msgid "FQDN" msgstr "" -#: gecoscc/models.py:387 +#: gecoscc/models.py:388 msgid "WORKGROUP" msgstr "" -#: gecoscc/models.py:393 +#: gecoscc/models.py:394 msgid "SSSD conf" msgstr "" -#: gecoscc/models.py:396 +#: gecoscc/models.py:397 msgid "KRB5 conf" msgstr "" -#: gecoscc/models.py:399 +#: gecoscc/models.py:400 msgid "SMB conf" msgstr "" -#: gecoscc/models.py:402 +#: gecoscc/models.py:403 msgid "PAM conf" msgstr "" -#: gecoscc/models.py:411 +#: gecoscc/models.py:412 msgid "URI ntp" msgstr "" -#: gecoscc/models.py:413 +#: gecoscc/models.py:414 msgid "Auth type" msgstr "" -#: gecoscc/models.py:417 +#: gecoscc/models.py:418 msgid "Specific conf" msgstr "" -#: gecoscc/models.py:419 +#: gecoscc/models.py:420 msgid "Auth LDAP" msgstr "" -#: gecoscc/models.py:420 gecoscc/models.py:421 +#: gecoscc/models.py:421 gecoscc/models.py:422 msgid "Auth Active directory" msgstr "" -#: gecoscc/models.py:461 gecoscc/templates/bb-computer.html:59 +#: gecoscc/models.py:462 gecoscc/templates/bb-computer.html:59 msgid "Desktop" msgstr "" -#: gecoscc/models.py:462 gecoscc/templates/bb-computer.html:60 +#: gecoscc/models.py:463 gecoscc/templates/bb-computer.html:60 msgid "Laptop" msgstr "" -#: gecoscc/models.py:463 gecoscc/templates/bb-computer.html:61 +#: gecoscc/models.py:464 gecoscc/templates/bb-computer.html:61 msgid "Netbook" msgstr "" -#: gecoscc/models.py:464 gecoscc/templates/bb-computer.html:62 +#: gecoscc/models.py:465 gecoscc/templates/bb-computer.html:62 msgid "Tablet" msgstr "" -#: gecoscc/models.py:500 gecoscc/templates/bb-printer.html:69 +#: gecoscc/models.py:501 gecoscc/templates/bb-printer.html:69 msgid "Laser" msgstr "" -#: gecoscc/models.py:501 gecoscc/templates/bb-printer.html:70 +#: gecoscc/models.py:502 gecoscc/templates/bb-printer.html:70 msgid "Ink" msgstr "" -#: gecoscc/models.py:502 gecoscc/templates/bb-printer.html:71 +#: gecoscc/models.py:503 gecoscc/templates/bb-printer.html:71 msgid "Dot matrix" msgstr "" -#: gecoscc/models.py:506 gecoscc/templates/bb-printer.html:35 +#: gecoscc/models.py:507 gecoscc/templates/bb-printer.html:35 msgid "Network" msgstr "" -#: gecoscc/models.py:507 gecoscc/templates/bb-printer.html:36 +#: gecoscc/models.py:508 gecoscc/templates/bb-printer.html:36 msgid "Local" msgstr "" -#: gecoscc/models.py:511 gecoscc/templates/bb-printer.html:52 +#: gecoscc/models.py:512 gecoscc/templates/bb-printer.html:52 msgid "Default" msgstr "" -#: gecoscc/models.py:512 gecoscc/templates/bb-printer.html:53 +#: gecoscc/models.py:513 gecoscc/templates/bb-printer.html:53 msgid "Authenticated" msgstr "" -#: gecoscc/models.py:557 +#: gecoscc/models.py:558 msgid "FTP" msgstr "" -#: gecoscc/models.py:558 +#: gecoscc/models.py:559 msgid "SSHFS" msgstr "" -#: gecoscc/models.py:559 +#: gecoscc/models.py:560 msgid "NFS" msgstr "" -#: gecoscc/models.py:560 +#: gecoscc/models.py:561 msgid "SAMBA v3" msgstr "" -#: gecoscc/models.py:561 +#: gecoscc/models.py:562 msgid "SAMBA v4" msgstr "" -#: gecoscc/models.py:565 +#: gecoscc/models.py:566 msgid "System mounts (fstab)" msgstr "" -#: gecoscc/models.py:566 +#: gecoscc/models.py:567 msgid "User space mounts (gvfs)" msgstr "" -#: gecoscc/models.py:597 +#: gecoscc/models.py:598 msgid "Processing" msgstr "" -#: gecoscc/models.py:600 +#: gecoscc/models.py:601 msgid "Applying changes" msgstr "" -#: gecoscc/models.py:603 +#: gecoscc/models.py:604 msgid "Changes applied" msgstr "" -#: gecoscc/models.py:606 gecoscc/models.py:609 +#: gecoscc/models.py:607 gecoscc/models.py:610 msgid "There were errors" msgstr "" @@ -363,7 +363,23 @@ msgstr "" msgid "Search" msgstr "" -#: gecoscc/templates/base_tree.jinja2:206 gecoscc/templates/bb-computer.html:93 +#: gecoscc/templates/base_tree.jinja2:136 +msgid "This action requires a little time" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:139 +msgid "Is the website maintenance?" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:142 gecoscc/templates/admins/list.jinja2:49 +msgid "No" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:143 gecoscc/templates/admins/list.jinja2:47 +msgid "Yes" +msgstr "" + +#: gecoscc/templates/base_tree.jinja2:224 gecoscc/templates/bb-computer.html:93 #: gecoscc/templates/bb-groups-form.html:27 gecoscc/templates/bb-user.html:74 msgid "Loading" msgstr "" @@ -512,7 +528,10 @@ msgstr "" msgid "Save" msgstr "" -#: gecoscc/templates/bb-computer.html:111 gecoscc/templates/bb-user.html:91 +#: gecoscc/templates/bb-computer.html:111 gecoscc/templates/bb-groups-form.html:37 +#: gecoscc/templates/bb-ou.html:62 gecoscc/templates/bb-printer.html:108 +#: gecoscc/templates/bb-repository.html:72 gecoscc/templates/bb-storage.html:30 +#: gecoscc/templates/bb-user.html:91 msgid "Cut" msgstr "" @@ -560,8 +579,8 @@ msgstr "" msgid "Data retrieved from workstation" msgstr "" -#: gecoscc/templates/bb-computer.html:202 gecoscc/templates/bb-groups-form.html:48 -#: gecoscc/templates/bb-ou.html:73 gecoscc/templates/bb-user.html:103 +#: gecoscc/templates/bb-computer.html:202 gecoscc/templates/bb-groups-form.html:49 +#: gecoscc/templates/bb-ou.html:74 gecoscc/templates/bb-user.html:103 msgid "Policies list" msgstr "" @@ -1010,14 +1029,6 @@ msgstr "" msgid "Is superuser?" msgstr "" -#: gecoscc/templates/admins/list.jinja2:47 -msgid "Yes" -msgstr "" - -#: gecoscc/templates/admins/list.jinja2:49 -msgid "No" -msgstr "" - #: gecoscc/templates/admins/ou_manage.jinja2:52 msgid "Select an Organisational Unit" msgstr "" diff --git a/gecoscc/locale/gecoscc_js.pot b/gecoscc/locale/gecoscc_js.pot index 27cc57cd..a26c98eb 100644 --- a/gecoscc/locale/gecoscc_js.pot +++ b/gecoscc/locale/gecoscc_js.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 2.1.10\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2015-11-12 12:25+0100\n" +"POT-Creation-Date: 2015-12-11 11:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From c50ceaf3cc16171008abaa39a5b6c0c57a029d66 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Fri, 11 Dec 2015 12:07:19 +0100 Subject: [PATCH 27/38] change maintenance modal --- gecoscc/static/js/app-utils.js | 33 +++++++++++++++++++++++++-------- gecoscc/static/js/tree-views.js | 16 +--------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index d48805d8..1a5a4dfe 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -375,15 +375,32 @@ }, cutModel: function (evt) { - evt.preventDefault(); - var $button = $(evt.target); - $button.attr("disabled", "disabled"); - App.instances.cut = this.model; - App.instances.tree.trigger("change"); + var that = this; + var $button = $('#cut'); + var cutModel = function(){ + evt.preventDefault(); + var $button = $(evt.target); + $button.attr("disabled", "disabled"); + App.instances.cut = that.model; + App.instances.tree.trigger("change"); + + setTimeout(function () { + $button.attr("disabled", false); + }, 2000); + }; + + if($button.hasClass('admin') && !App.instances.noMaintenance[this.model.get('id')]){ + var $modal = $('#maintenance-modal'); + $modal.modal('show'); + $('#set-maintenance').click(function(){ + cutModel(); + $modal.modal('hide'); + }); + }else{ + cutModel(); + } + - setTimeout(function () { - $button.attr("disabled", false); - }, 2000); }, canMove: function(){ diff --git a/gecoscc/static/js/tree-views.js b/gecoscc/static/js/tree-views.js index f6796e12..feb54ad3 100644 --- a/gecoscc/static/js/tree-views.js +++ b/gecoscc/static/js/tree-views.js @@ -259,21 +259,7 @@ App.module("Tree.Views", function (Views, App, Backbone, Marionette, $, _) { $html.find("a.text-warning").click(function (evt) { evt.preventDefault(); - - var $button = $('#cut'); - - if($button.hasClass('admin') && !App.instances.noMaintenance[App.instances.cut.get('id')]){ - var $modal = $('#maintenance-modal'); - $modal.modal('show'); - $('#set-maintenance').click(function(){ - _.bind(that._pasteOU, ouId)(); - $modal.modal('hide'); - }); - }else{ - _.bind(that._pasteOU, ouId)(); - } - - + _.bind(that._pasteOU, ouId)(); }); }, From 2f6265ed5a3e941dac0755c978b3ea037b7d8fc0 Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 11 Dec 2015 12:44:36 +0100 Subject: [PATCH 28/38] Fixed some details --- gecoscc/api/__init__.py | 36 ++++++++++++++++-------------- gecoscc/api/organisationalunits.py | 8 ++++--- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/gecoscc/api/__init__.py b/gecoscc/api/__init__.py index 416506ab..65c6d4ff 100644 --- a/gecoscc/api/__init__.py +++ b/gecoscc/api/__init__.py @@ -537,26 +537,28 @@ def check_obj_is_related(self, obj): ''' Check if the emitter object is related with any object ''' - if obj['type'] == 'printer': - slug = 'printer_can_view' - elif obj['type'] == 'repository': - slug = 'repository_can_view' - elif obj['type'] == 'storage': - slug == 'storage_can_view' - elif obj['type'] == 'group': - members_group = obj['members'] - if not members_group: - return True - return False + if obj.get('_id'): + if obj['type'] == 'printer': + slug = 'printer_can_view' + elif obj['type'] == 'repository': + slug = 'repository_can_view' + elif obj['type'] == 'storage': + slug = 'storage_can_view' + elif obj['type'] == 'group': + members_group = obj['members'] + if not members_group: + return True + return False - policy_id = self.request.db.policies.find_one({'slug': slug}).get('_id') - nodes_related_with_obj = self.request.db.nodes.find({"policies.%s.object_related_list" - % unicode(policy_id): {'$in': [unicode(obj['_id'])]}}) + policy_id = self.request.db.policies.find_one({'slug': slug}).get('_id') + nodes_related_with_obj = self.request.db.nodes.find({"policies.%s.object_related_list" + % unicode(policy_id): {'$in': [unicode(obj['_id'])]}}) - if nodes_related_with_obj.count() == 0: - return True + if nodes_related_with_obj.count() == 0: + return True - return False + return False + return True def integrity_validation(self, obj, real_obj=None): result = super(PassiveResourcePaginated, self).integrity_validation( diff --git a/gecoscc/api/organisationalunits.py b/gecoscc/api/organisationalunits.py index b28aa318..649f5af9 100644 --- a/gecoscc/api/organisationalunits.py +++ b/gecoscc/api/organisationalunits.py @@ -36,15 +36,17 @@ class OrganisationalUnitResource(TreeResourcePaginated): def integrity_validation(self, obj, real_obj=None): status = super(OrganisationalUnitResource, self).integrity_validation(obj, real_obj) - status_user = self.request.user.get('is_superuser', False) or self.is_ou_empty(obj) - status = status and status_user + + if obj['path'] != real_obj['path']: + status_user = self.request.user.get('is_superuser', False) or self.is_ou_empty(obj) + status = status and status_user return status def is_ou_empty(self, obj): ''' Check if the Ou contains any object ''' - ou_children = self.get_db().nodes.find({'path': {'$regex': '.*' + unicode(obj['_id']) + '.*'}}).count() + ou_children = self.collection.find({'path': {'$regex': '.*' + unicode(obj['_id']) + '.*'}}).count() if ou_children == 0: return True From f05ef9745fb1de250591ae7aec1c0e794f620a55 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Fri, 11 Dec 2015 13:23:29 +0100 Subject: [PATCH 29/38] add mesage for non admin user --- gecoscc/static/css/scp-gecos.css | 5 +++++ gecoscc/static/js/app-utils.js | 5 ++++- gecoscc/static/js/ou.js | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gecoscc/static/css/scp-gecos.css b/gecoscc/static/css/scp-gecos.css index 513d0915..28853467 100644 --- a/gecoscc/static/css/scp-gecos.css +++ b/gecoscc/static/css/scp-gecos.css @@ -462,3 +462,8 @@ legend { .btn.refresh, .btn.archiveTasks { margin-right: 3px; } + +.no-admin-message{ + float: right; + margin-right: 85px; +} \ No newline at end of file diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index 1a5a4dfe..99e4d105 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -412,8 +412,11 @@ $button.removeClass('btn-warning'); $button.addClass('btn-group'); $button.removeAttr('id'); - $button.unbind('click') + $button.unbind('click'); $button.css('margin-right','5px'); + $button.click(function(){ + $button.parent().parent().after('
Solo el administrador puede cortar el elemento
'); + }); }; if(this.model.get('type')=='group'){ diff --git a/gecoscc/static/js/ou.js b/gecoscc/static/js/ou.js index 5cf1ebd9..c31df8c5 100644 --- a/gecoscc/static/js/ou.js +++ b/gecoscc/static/js/ou.js @@ -76,6 +76,9 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { $button.removeAttr('id'); $button.unbind('click'); $button.css('margin-right','5px'); + $button.click(function(){ + $button.parent().parent().after('
Solo el administrador puede cortar el elemento
'); + }); App.instances.noMaintenance[that.model.get('id')] = false; } From f57e719592796cdfb8c6d64b3a6b32ad1a17616d Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 11 Dec 2015 13:38:57 +0100 Subject: [PATCH 30/38] fixed details --- gecoscc/api/__init__.py | 16 ++++++++++------ gecoscc/api/organisationalunits.py | 2 +- gecoscc/utils.py | 2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gecoscc/api/__init__.py b/gecoscc/api/__init__.py index 65c6d4ff..b6c82ff1 100644 --- a/gecoscc/api/__init__.py +++ b/gecoscc/api/__init__.py @@ -451,24 +451,28 @@ def check_memberof_integrity(self, obj): return False return True - def check_policies_integrity(self, obj): + def check_policies_integrity(self, obj, is_moved=False): """ Check if the policie is out of scope """ obj_original = deepcopy(obj) visibility_object_related(self.request.db, obj) - if obj != obj_original: - self.request.errors.add(unicode(obj[self.key]), 'policies', - "The related object is out of scope") - return False + if not is_moved: + if obj != obj_original: + self.request.errors.add(unicode(obj[self.key]), 'policies', + "The related object is out of scope") + return False return True def integrity_validation(self, obj, real_obj=None): result = super(TreeLeafResourcePaginated, self).integrity_validation( obj, real_obj) result = result and self.check_memberof_integrity(obj) - result = result and self.check_policies_integrity(obj) result = result and self.check_unique_node_name_by_type_at_domain(obj) + if real_obj is not None and real_obj['path'] == obj['path']: + result = result and self.check_policies_integrity(obj) + else: + result = result and self.check_policies_integrity(obj, is_moved=True) return result def computers_to_group(self, obj): diff --git a/gecoscc/api/organisationalunits.py b/gecoscc/api/organisationalunits.py index 649f5af9..cc49b7b4 100644 --- a/gecoscc/api/organisationalunits.py +++ b/gecoscc/api/organisationalunits.py @@ -37,7 +37,7 @@ def integrity_validation(self, obj, real_obj=None): status = super(OrganisationalUnitResource, self).integrity_validation(obj, real_obj) - if obj['path'] != real_obj['path']: + if real_obj is not None and obj['path'] != real_obj['path']: status_user = self.request.user.get('is_superuser', False) or self.is_ou_empty(obj) status = status and status_user return status diff --git a/gecoscc/utils.py b/gecoscc/utils.py index aa6a4aac..bcb00c41 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -650,6 +650,8 @@ def apply_policies_to_ou(nodes_collection, ou, auth_user, api=None, initialize=F children_path = ou['path'] + ',' + unicode(ou['_id']) ou_children = nodes_collection.find({'path': {'$regex': '.*' + unicode(ou['_id']) + '.*'}}) + visibility_object_related(nodes_collection.database, ou) + if ou_children.count() == 0: return From 50acdf000db3135732cd94d402e5693e63b2acb3 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Fri, 11 Dec 2015 14:08:58 +0100 Subject: [PATCH 31/38] fix --- gecoscc/static/js/app-utils.js | 2 +- gecoscc/static/js/ou.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index 99e4d105..a2b04404 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -415,7 +415,7 @@ $button.unbind('click'); $button.css('margin-right','5px'); $button.click(function(){ - $button.parent().parent().after('
Solo el administrador puede cortar el elemento
'); + App.showAlert('warning','Solo el administrador puede cortar el elemento'); }); }; diff --git a/gecoscc/static/js/ou.js b/gecoscc/static/js/ou.js index c31df8c5..a8deec55 100644 --- a/gecoscc/static/js/ou.js +++ b/gecoscc/static/js/ou.js @@ -77,7 +77,7 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { $button.unbind('click'); $button.css('margin-right','5px'); $button.click(function(){ - $button.parent().parent().after('
Solo el administrador puede cortar el elemento
'); + App.showAlert('warning','Solo el administrador puede cortar el elemento'); }); App.instances.noMaintenance[that.model.get('id')] = false; From 71643b151efe767fec74d37c766e4914480622e6 Mon Sep 17 00:00:00 2001 From: iPablo Date: Fri, 11 Dec 2015 14:38:54 +0100 Subject: [PATCH 32/38] Fixed error moving nodes --- gecoscc/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index bcb00c41..7679e1c2 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -664,16 +664,16 @@ def apply_policies_to_ou(nodes_collection, ou, auth_user, api=None, initialize=F def update_data_ou(nodes_collection, obj, policy, api, auth_user): - members_path = obj['path'] + ',' + obj[unicode('_id')] + members_path = obj['path'] + ',' + unicode(obj['_id']) members = nodes_collection.find({'path': members_path}) - for member_id in members: - member = nodes_collection.find_one({'_id': member_id}) + + for member in members: if member['type'] in RESOURCES_RECEPTOR_TYPES: try: - func = 'update_data_%s' % obj['type'] + func = globals()['update_data_%s' % member['type']] except KeyError: raise NotImplementedError - func(nodes_collection, obj, policy, api, auth_user) + func(nodes_collection, member, policy, api, auth_user) def update_data_group(nodes_collection, obj, policy, api, auth_user): From 4953b02c551fcaf923a15ba0dcc49b3b91c468a4 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Sat, 12 Dec 2015 20:17:46 +0100 Subject: [PATCH 33/38] fix --- gecoscc/static/js/app-utils.js | 8 ++++++++ gecoscc/static/js/policies.js | 20 ++++++++++++++++++++ gecoscc/static/js/staging.js | 9 +++++++++ 3 files changed, 37 insertions(+) diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index a2b04404..5a35acf0 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -408,6 +408,9 @@ if(typeof App.instances.noMaintenance == 'undefined'){ App.instances.noMaintenance = []; } + if(typeof App.instances.refresh == 'undefined'){ + App.instances.refresh = {}; + } var disable = function(){ $button.removeClass('btn-warning'); $button.addClass('btn-group'); @@ -429,6 +432,11 @@ } } if(this.model.get('type')=='storage' || this.model.get('type')=='printer' || this.model.get('type')=='repository'){ + if(App.instances.refresh[this.model.get('id')]){ + this.refresh(); + delete App.instances.refresh[this.model.get('id')]; + } + if($button.hasClass('admin')==false && this.model.get('is_assigned') == true){ disable(); App.instances.noMaintenance[this.model.get('id')] = false; diff --git a/gecoscc/static/js/policies.js b/gecoscc/static/js/policies.js index 71de7f54..01cef2ca 100644 --- a/gecoscc/static/js/policies.js +++ b/gecoscc/static/js/policies.js @@ -77,7 +77,18 @@ App.module("Policies.Models", function (Models, App, Backbone, Marionette, $, _) var that = this, promise; + if(typeof App.instances.refresh == 'undefined'){ + App.instances.refresh = {}; + } + + _.each(this.get("policies")[id],function(obj){ + _.each(obj,function(idAttach){ + App.instances.refresh[idAttach] = false; + }); + }); + this.get("policyCollection").remove(id); + delete this.get("policies")[id]; promise = this.saveWithToken(); @@ -91,6 +102,15 @@ App.module("Policies.Models", function (Models, App, Backbone, Marionette, $, _) var that = this, promise; + if(typeof App.instances.refresh == 'undefined'){ + App.instances.refresh = {}; + } + _.each(values,function(obj){ + _.each(obj,function(idAttach){ + App.instances.refresh[idAttach] = false; + }); + }); + this.get("policyCollection").add(policyModel); this.get("policies")[policyModel.get("id")] = values; diff --git a/gecoscc/static/js/staging.js b/gecoscc/static/js/staging.js index a860173d..5fcca1af 100644 --- a/gecoscc/static/js/staging.js +++ b/gecoscc/static/js/staging.js @@ -273,9 +273,18 @@ App.module("Staging.Views", function (Views, App, Backbone, Marionette, $, _) { this.inProgress = true; $.when.apply($, promises) .done(function () { + if(typeof App.instances.refresh == 'undefined'){ + App.instances.refresh = {}; + } + App.tree.currentView.activeNode = null; App.instances.tree.trigger("change"); App.instances.router.navigate("", { trigger: true }); + + _.each(App.instances.refresh,function(value,key){ + App.instances.refresh[key] = true; + }); + }).always(function () { that.inProgress = false; that.render(); From 61b4afbaff16936438579f0c87e9bd38853f4055 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Sun, 13 Dec 2015 16:37:01 +0100 Subject: [PATCH 34/38] fix preventDefault --- gecoscc/static/js/app-utils.js | 3 ++- gecoscc/static/js/ou.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index 5a35acf0..e90b851f 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -417,7 +417,8 @@ $button.removeAttr('id'); $button.unbind('click'); $button.css('margin-right','5px'); - $button.click(function(){ + $button.click(function(e){ + e.preventDefault(); App.showAlert('warning','Solo el administrador puede cortar el elemento'); }); }; diff --git a/gecoscc/static/js/ou.js b/gecoscc/static/js/ou.js index a8deec55..e0a14ab6 100644 --- a/gecoscc/static/js/ou.js +++ b/gecoscc/static/js/ou.js @@ -76,7 +76,8 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { $button.removeAttr('id'); $button.unbind('click'); $button.css('margin-right','5px'); - $button.click(function(){ + $button.click(function (e){ + e.preventDefault(); App.showAlert('warning','Solo el administrador puede cortar el elemento'); }); App.instances.noMaintenance[that.model.get('id')] = false; From 152203fb3f9cc520869f82b3e6eb9ad85dd6d136 Mon Sep 17 00:00:00 2001 From: rastydnb Date: Sun, 13 Dec 2015 16:59:31 +0100 Subject: [PATCH 35/38] add preventDefault on maintenance modal --- gecoscc/static/js/app-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index e90b851f..8eccf6c5 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -377,8 +377,8 @@ cutModel: function (evt) { var that = this; var $button = $('#cut'); + evt.preventDefault(); var cutModel = function(){ - evt.preventDefault(); var $button = $(evt.target); $button.attr("disabled", "disabled"); App.instances.cut = that.model; From dd1113b053bf6b090b2bc7f76fc3ac2b43ee105a Mon Sep 17 00:00:00 2001 From: iPablo Date: Sun, 13 Dec 2015 20:15:56 +0100 Subject: [PATCH 36/38] Fixed error moving emitter objects --- gecoscc/utils.py | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index 7679e1c2..576ec553 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -224,7 +224,10 @@ def remove_chef_computer_data(computer, api, policies=None): for policy in policies: policy_path = policy[1] policy_field = policy[2] - cookbook[policy_path].pop(policy_field) + try: + cookbook[policy_path].pop(policy_field) + except KeyError: + continue else: for mgmt in cookbook.keys(): if mgmt == USER_MGMT: @@ -567,7 +570,6 @@ def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api Checks if a emitter object is within the scope of the objects that is related and then update policies ''' from gecoscc.tasks import object_changed, object_created - policy = policies_collection.find_one({'slug': slug}) policy_id = unicode(policy.get('_id')) @@ -592,14 +594,17 @@ def apply_policies_to_emitter_object(nodes_collection, obj, auth_user, slug, api del node['policies'][policy_id] else: node['policies'][policy_id]['object_related_list'] = object_related_list - obj = update_collection_and_get_obj(nodes_collection, node['_id'], node['policies']) - - if obj['type'] in RESOURCES_RECEPTOR_TYPES: + obj_related = update_collection_and_get_obj(nodes_collection, node['_id'], node['policies']) + if obj_related['type'] in RESOURCES_RECEPTOR_TYPES: try: - func = globals()['update_data_%s' % obj['type']] + func = globals()['update_data_%s' % obj_related['type']] except KeyError: raise NotImplementedError - func(nodes_collection, obj, policy, api, auth_user) + func(nodes_collection, obj_related, policy, api, auth_user) + if obj_related['type'] == 'user': + apply_policies_to_user(nodes_collection, obj_related, auth_user, api) + if obj_related['type'] == 'computer': + apply_policies_to_computer(nodes_collection, obj_related, auth_user, api) object_created(auth_user, obj['type'], obj) @@ -614,10 +619,8 @@ def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initia object_changed = object_changed.delay policies = group['policies'].keys() members_group = copy(group['members']) - if not members_group: return - for member_id in members_group: member = nodes_collection.find_one({'_id': member_id}) is_visible = is_visible_group(nodes_collection.database, group['_id'], member) @@ -633,6 +636,7 @@ def apply_policies_to_group(nodes_collection, group, auth_user, api=None, initia if member['type'] == 'user': update_data_user(nodes_collection, member, policies, api, auth_user) + apply_policies_to_user(nodes_collection, member, auth_user, api) elif member['type'] == 'computer': update_data_computer(nodes_collection, member, policies, api, auth_user) @@ -674,41 +678,45 @@ def update_data_ou(nodes_collection, obj, policy, api, auth_user): except KeyError: raise NotImplementedError func(nodes_collection, member, policy, api, auth_user) + if member['type'] == 'user': + apply_policies_to_user(nodes_collection, member, auth_user, api) def update_data_group(nodes_collection, obj, policy, api, auth_user): for member_id in obj['members']: member = nodes_collection.find_one({'_id': member_id}) if member['type'] == 'user': - update_data_user(nodes_collection, obj, member, policy, api) + update_data_user(nodes_collection, member, policy, api, auth_user) elif member['type'] == 'computer': update_data_computer(nodes_collection, member, policy, api) def update_data_user(nodes_collection, obj, policy, api, auth_user): - from gecoscc.tasks import object_created + from gecoscc.tasks import object_changed, object_created computers = get_computer_of_user(nodes_collection, obj) if isinstance(policy, list): policy_field_name = [] for policy_id in policy: - policy = nodes_collection.database.policies.find_one({'_id': policy_id}) + policy = nodes_collection.database.policies.find_one({'_id': ObjectId(policy_id)}) policy_field_name.append(policy['path'].split('.')[2]) else: policy_field_name = [policy['path'].split('.')[2]] remove_chef_user_data(obj, computers, api, policy_field_name) object_created(auth_user, 'user', obj, computers=computers) + object_changed(auth_user, 'user', obj, {}, computers=computers) def update_data_computer(nodes_collection, obj, policy, api, auth_user): from gecoscc.tasks import object_created - if isinstance(policy, list): - policy_field_name = [] - for policy_id in policy: - policy = nodes_collection.database.policies.find_one({'_id': policy_id}) - policy_field_name.append(policy['path'].split('.')[:3]) - else: - policy_field_name = [policy['path'].split('.')[:3]] - remove_chef_computer_data(obj, api, policy_field_name) + if policy and policy['slug'] != 'storage_can_view': + if isinstance(policy, list): + policy_field_name = [] + for policy_id in policy: + policy = nodes_collection.database.policies.find_one({'_id': ObjectId(policy_id)}) + policy_field_name.append(policy['path'].split('.')[:3]) + else: + policy_field_name = [policy['path'].split('.')[:3]] + remove_chef_computer_data(obj, api, policy_field_name) object_created(auth_user, 'computer', obj, computers=[obj]) From f7d1ce8ba947abc90094c47e3cb9bb947cf9b56e Mon Sep 17 00:00:00 2001 From: iPablo Date: Sun, 13 Dec 2015 21:18:48 +0100 Subject: [PATCH 37/38] Added translations --- gecoscc/locale/en/LC_MESSAGES/gecoscc.mo | Bin 13335 -> 13335 bytes gecoscc/locale/en/LC_MESSAGES/gecoscc.po | 2 +- gecoscc/locale/en/LC_MESSAGES/gecoscc_js.mo | Bin 4456 -> 4554 bytes gecoscc/locale/en/LC_MESSAGES/gecoscc_js.po | 6 +++++- gecoscc/locale/es/LC_MESSAGES/gecoscc.mo | Bin 13747 -> 13747 bytes gecoscc/locale/es/LC_MESSAGES/gecoscc.po | 2 +- gecoscc/locale/es/LC_MESSAGES/gecoscc_js.mo | Bin 4816 -> 4926 bytes gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po | 6 +++++- gecoscc/locale/gecoscc.pot | 2 +- gecoscc/locale/gecoscc_js.pot | 6 +++++- gecoscc/static/js/app-utils.js | 2 +- gecoscc/static/js/ou.js | 2 +- 12 files changed, 20 insertions(+), 8 deletions(-) diff --git a/gecoscc/locale/en/LC_MESSAGES/gecoscc.mo b/gecoscc/locale/en/LC_MESSAGES/gecoscc.mo index 3fe0f082d8115773d49640b96f37e61a17b4c7e4..4a9830b49e94d6c3d137d49f17f494653e82dc14 100644 GIT binary patch delta 20 bcmbQ9F+F30q!PQaf{~$>q48z~rSF0OMfwIp delta 20 bcmbQ9F+F30q!PQKf}x?6k-=sKrSF0OMa>31 diff --git a/gecoscc/locale/en/LC_MESSAGES/gecoscc.po b/gecoscc/locale/en/LC_MESSAGES/gecoscc.po index a80093fe..ec903668 100644 --- a/gecoscc/locale/en/LC_MESSAGES/gecoscc.po +++ b/gecoscc/locale/en/LC_MESSAGES/gecoscc.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 0.2.2\n" "Report-Msgid-Bugs-To: gecos@guadalinex.org\n" -"POT-Creation-Date: 2015-12-11 11:20+0100\n" +"POT-Creation-Date: 2015-12-13 21:13+0100\n" "PO-Revision-Date: 2014-03-19 11:03+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: en \n" diff --git a/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.mo b/gecoscc/locale/en/LC_MESSAGES/gecoscc_js.mo index 46b937da83901f4e558edf0a7be27602a653ed14..05be4791f38d67640f1832d7a5288e586ed5d7ee 100644 GIT binary patch delta 1064 zcmb8sPe_w-9LMpWZ8mMr{4)Z@)`P?5kg02i_J<1U5)xtu58*){olZ$7x*`36K@ikI zL?q}E1s&SKI4P6YW+Pn;&*i84j#nv0*?zz?j%O+1OasD}J3R%0F3VhbklGG4?icHuAd zP~QZ~iiJ*NE8_@iC;ixga~Q=up2B|^Mt^y+;3d=vT*b54gGqdd)G#}EpIG;u@m;>G z4L!h&vV6{qI?p4UFe})NtEepND~juFs3YybCcK6^v2ka8${D9oQQkvE`4|=D7gR(0 zs3=Q)oWCYc@NG2^Kx&#G>IB*_gafF;j~t((vdm&LuAq*3+ZnsbMU6#JQN~akn?UV6 zg^F^alJi#sOH6Q?cRZBkXH-KQs4Rb@3hZG5E9gd9rcqhGMg7kfs?c9-#R6(0VYaI% zZ=s@`M@9K5#!Hx&4OBrd)pPWi8oON@|e5g?Ku*fynV+?CF0ghdMZ9`4GvF? sO4FL9*+;Da&x{l*Wz-y?TJ}uqUWQrT;!PT`mbLf0LF%UEC2ui delta 965 zcmYMx%PT}-9LDjNVO++YEaWngW-MHe$bG>=xfD&x(q(~_`3KZlu$f#+A`2`O<&w?p zTsBe)8%w#wVoFmANlN7VaLRP%e9n8`&ii|R?{il2SZv>A#Vs0s_5Abs-^6J2|66ex zlfZBlHNSzyc#LrvK{rOR3tun?TbR^*fLl8DV=0beJkBDQZ5Est%b3c<8aClB*5M;+ z175z$KtF2SfJ~WI^k6$yVE}zNi7LF~cz}hB&oLXL=%>E<=7G!jXrlqkQ5}tPQ^(_& zhtsISo0x`sSb#^Uja*|U-lGb<;uyO5s2PK(Q{F|b6XE8jzIo!I0^d*_lq4EcgMDaW z2#fFl%kUaiFh1$8^JJ`LoQpy1Min^33F16)#;qKa8tOnrID)no3h}^Z%^Y^&A}YfN z)ciZ@C_k|jJt==DW})WmoN+TM!ZuWdy{HIhP#ZcyMR?(iZ&NsbEfC=aYnv$Q1m4ky zK2}rV9>)PxhC$R3&!HdJQ4yY_BD_R3\n" "Language-Team: en \n" @@ -85,6 +85,10 @@ msgstr "" msgid "Please, fix the errors in the fields below and try again." msgstr "" +#: gecoscc/static/js/app-utils.js:422 gecoscc/static/js/ou.js:81 +msgid "Only the super admin can cut this object" +msgstr "" + #: gecoscc/static/js/app.js:322 msgid "New element" msgstr "" diff --git a/gecoscc/locale/es/LC_MESSAGES/gecoscc.mo b/gecoscc/locale/es/LC_MESSAGES/gecoscc.mo index 2197097fbe8dec5339f210e9229ddf264a5d8daa..142438b5ff33307b1dba75cc746e0ee016a6e341 100644 GIT binary patch delta 20 ccmdm-y*Ycs3k7y#1tUW%L*vcw6^@7i09j@S>Hq)$ delta 20 ccmdm-y*Ycs3k7yV1w%tCBZJNF6^@7i09iQ)\n" "Language-Team: es \n" diff --git a/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.mo b/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.mo index 74088ced7f0ff834fabefa92f4da3fd80cf25cbd..436135f27f3bb7aca3c8da400434f0aefedf282a 100644 GIT binary patch delta 1071 zcmYk*OK1~89LMo#o3>i}GKtiR#zjqQv1(&$Tk9i=9;_0y3Z6We$7(8Rwk7EU$evF{vF>XzG0fRV>)i{lu zIdiYvF^dfZ^0*hDVjnJ`66j)7Gxnp}gGk5>;VL|XT^Pf5yn&kdN!gbepgoUUaS?sY zZ#I*@I{J`4a}HIF^T=uLa?{FZa2>utCGZX#@e^*q@2G_Q1Xp7#`fwX2F^v0g7W?rd z)-t~dtXQ6?4R_Gqj#|lC?7{08!Xj?OZ`gtUmCF+zKvm!{?#2`7;ALbEQ^IR(>k_KM zlf1kWZ)2{LhdCa!@)EKL^AjUjS#L}Wp2Rv#q8Brmz$>V6Ur^(|mfH)c3j9V@vYA;A z;xQz5a}^c8*+Bi3;e9$(x;(0+1?P@e8x)CmVfu617#Yuoah3m1tpk z5e%UAJcS{AfLho*cA_^#J+*=`YC;$F_ql|6aSBIpt{m_674B3GRkn|&CM-8;Tbb;b zowlNhk>OD*9_7lq^bcn&Cw9?}yM@oyM?AIN)~?V%sJqZpSMTXL?W7#bPW?Y}IOC?H e2`6ohW$lD*#htVpOz delta 962 zcmYMzOGs2v7y#gFj$@kd9#&XcY8qHN(Q7n8TeK+&MFL0vFY) zgi0iuO`tuHf}%~Wf{bX95JFJVTKfJR=yKq>pQOl${)8D=#quKPouOt;X-TmP>3CKUsF;Oj?zZkA+IXhU#E}mmQ!3Rg4FlnBytN18?f`4~qv@<(tz-Ql**3Or~pZXFgY6k;>0hT~GZ5F|=B_ diff --git a/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po b/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po index afc5dbdc..b4a75800 100644 --- a/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po +++ b/gecoscc/locale/es/LC_MESSAGES/gecoscc_js.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 0.2.1\n" "Report-Msgid-Bugs-To: gecos@guadalinex.org\n" -"POT-Creation-Date: 2015-12-11 11:20+0100\n" +"POT-Creation-Date: 2015-12-13 21:13+0100\n" "PO-Revision-Date: 2014-03-07 13:25+0100\n" "Last-Translator: Alejandro Blanco \n" "Language-Team: es \n" @@ -86,6 +86,10 @@ msgstr "Datos inválidos." msgid "Please, fix the errors in the fields below and try again." msgstr "Por favor, corrija los errores mostrados abajo y pruebe de nuevo." +#: gecoscc/static/js/app-utils.js:422 gecoscc/static/js/ou.js:81 +msgid "Only the super admin can cut this object" +msgstr "Solo el super administrador puede cortar este objeto" + #: gecoscc/static/js/app.js:322 msgid "New element" msgstr "Nuevo elemento" diff --git a/gecoscc/locale/gecoscc.pot b/gecoscc/locale/gecoscc.pot index 3ab4ebdf..74bc83a0 100644 --- a/gecoscc/locale/gecoscc.pot +++ b/gecoscc/locale/gecoscc.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 2.1.10\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2015-12-11 11:20+0100\n" +"POT-Creation-Date: 2015-12-13 21:13+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/gecoscc/locale/gecoscc_js.pot b/gecoscc/locale/gecoscc_js.pot index a26c98eb..1487d7e7 100644 --- a/gecoscc/locale/gecoscc_js.pot +++ b/gecoscc/locale/gecoscc_js.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gecoscc 2.1.10\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2015-12-11 11:20+0100\n" +"POT-Creation-Date: 2015-12-13 21:13+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -84,6 +84,10 @@ msgstr "" msgid "Please, fix the errors in the fields below and try again." msgstr "" +#: gecoscc/static/js/app-utils.js:422 gecoscc/static/js/ou.js:81 +msgid "Only the super admin can cut this object" +msgstr "" + #: gecoscc/static/js/app.js:322 msgid "New element" msgstr "" diff --git a/gecoscc/static/js/app-utils.js b/gecoscc/static/js/app-utils.js index 8eccf6c5..ff4c7a4a 100644 --- a/gecoscc/static/js/app-utils.js +++ b/gecoscc/static/js/app-utils.js @@ -419,7 +419,7 @@ $button.css('margin-right','5px'); $button.click(function(e){ e.preventDefault(); - App.showAlert('warning','Solo el administrador puede cortar el elemento'); + App.showAlert('warning',gettext('Only the super admin can cut this object')); }); }; diff --git a/gecoscc/static/js/ou.js b/gecoscc/static/js/ou.js index e0a14ab6..44494e61 100644 --- a/gecoscc/static/js/ou.js +++ b/gecoscc/static/js/ou.js @@ -78,7 +78,7 @@ App.module("OU.Views", function (Views, App, Backbone, Marionette, $, _) { $button.css('margin-right','5px'); $button.click(function (e){ e.preventDefault(); - App.showAlert('warning','Solo el administrador puede cortar el elemento'); + App.showAlert('warning',gettext('Only the super admin can cut this object')); }); App.instances.noMaintenance[that.model.get('id')] = false; From 7caaecb385ef51fda9e7f5c1eb2d5fb868f94c94 Mon Sep 17 00:00:00 2001 From: iPablo Date: Sun, 13 Dec 2015 23:49:52 +0100 Subject: [PATCH 38/38] Fixed detail --- gecoscc/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gecoscc/utils.py b/gecoscc/utils.py index 576ec553..05f3fdb4 100644 --- a/gecoscc/utils.py +++ b/gecoscc/utils.py @@ -680,6 +680,8 @@ def update_data_ou(nodes_collection, obj, policy, api, auth_user): func(nodes_collection, member, policy, api, auth_user) if member['type'] == 'user': apply_policies_to_user(nodes_collection, member, auth_user, api) + if member['type'] == 'computer': + apply_policies_to_computer(nodes_collection, member, auth_user, api) def update_data_group(nodes_collection, obj, policy, api, auth_user):