def test_check_permissions_fails_with_nobody(self, browser): self.login(self.regular_user) url = ResolveOGUIDView.url_for( Oguid.for_object(self.task), get_current_admin_unit()) with browser.expect_unauthorized(): browser.open(url)
def test_check_permissions_fails_with_nobody(self, browser): self.login(self.regular_user) url = ResolveOGUIDView.url_for(Oguid.for_object(self.task), get_current_admin_unit()) with browser.expect_unauthorized(): browser.open(url)
def test_redirect_if_correct_client(self, browser): self.login(self.regular_user, browser=browser) url = ResolveOGUIDView.url_for(Oguid.for_object(self.task), get_current_admin_unit()) browser.open(url) self.assertEqual(self.task.absolute_url(), browser.url)
def test_redirect_if_correct_client(self, browser): self.login(self.regular_user, browser=browser) url = ResolveOGUIDView.url_for( Oguid.for_object(self.task), get_current_admin_unit()) browser.open(url) self.assertEqual(self.task.absolute_url(), browser.url)
def prepare_data(self, notifications): items = [] language = self.get_users_language() data = self.group_by_resource(notifications).items() for resource, notifications in data: activities = [ self.serialize_activity(notification.activity, language) for notification in notifications] items.append({ 'title': activities[0]['title'], 'url': ResolveOGUIDView.url_for(resource.oguid), 'activities': activities}) return items
def prepare_data(self, notifications): items = [] language = self.get_users_language() data = self.group_by_resource(notifications).items() for resource, notifications in data: activities = [ self.serialize_activity(notification.activity, language) for notification in notifications ] items.append({ 'title': activities[0]['title'], 'url': ResolveOGUIDView.url_for(resource.oguid), 'activities': activities }) return items
def redirect(self): """Redirect to the affected resource. If the resource is stored in an other admin_unit than the current one, it redirects to the resolve_oguid view on this admin_unit.""" oguid = self.notification.activity.resource.oguid if oguid.is_on_current_admin_unit: url = oguid.resolve_object().absolute_url() else: admin_unit = ogds_service().fetch_admin_unit(oguid.admin_unit_id) url = ResolveOGUIDView.url_for(oguid, admin_unit) return self.request.RESPONSE.redirect(url)
def redirect(self): """Redirect to the affected resource. If the resource is stored in an other admin_unit than the current one, it redirects to the resolve_oguid view on this admin_unit.""" oguid = self.notification.activity.resource.oguid if oguid.is_on_current_admin_unit: url = oguid.resolve_object().absolute_url() else: admin_unit = ogds_service().fetch_admin_unit(oguid.admin_unit_id) url = ResolveOGUIDView.url_for(oguid, admin_unit) return self.request.RESPONSE.redirect(url)
def get_url(self): """Return an url to the object represented by this Oguid. Resolves the object and returns its absolute_url for objects on the same admin-unit. Returns an url to the resolve_oguid view for objects on foreign admin-units. """ obj = self.resolve_object() if obj: return obj.absolute_url() admin_unit = ogds_service().fetch_admin_unit(self.admin_unit_id) # XXX have some kind ouf routes to avoid cyclic dependecies from opengever.base.browser.resolveoguid import ResolveOGUIDView return ResolveOGUIDView.url_for(self, admin_unit=admin_unit)
def get_url(self): """Return an url to the object represented by this Oguid. Resolves the object and returns its absolute_url for objects on the same admin-unit. Returns an url to the resolve_oguid view for objects on foreign admin-units. """ obj = self.resolve_object() if obj: return obj.absolute_url() admin_unit = ogds_service().fetch_admin_unit(self.admin_unit_id) # XXX have some kind ouf routes to avoid cyclic dependecies from opengever.base.browser.resolveoguid import ResolveOGUIDView return ResolveOGUIDView.url_for(self, admin_unit=admin_unit)
def redirect(self): """Redirect to the affected resource. If the resource is stored in an other admin_unit than the current one, it redirects to the resolve_oguid view on this admin_unit.""" oguid = self.notification.activity.resource.oguid if oguid.is_on_current_admin_unit: try: url = oguid.resolve_object().absolute_url() except KeyError: raise NotFound('Requested object has been deleted') else: admin_unit = ogds_service().fetch_admin_unit(oguid.admin_unit_id) url = ResolveOGUIDView.url_for(oguid, admin_unit) return self.request.RESPONSE.redirect(self.preserve_query_string(url))
def test_redirect_if_correct_client(self, browser): url = ResolveOGUIDView.url_for('client1:{}'.format(self.task_id), self.admin_unit) browser.login().open(url) self.assertEqual(self.task.absolute_url(), browser.url)
def test_check_permissions_fails_with_nobody(self, browser): logout() url = ResolveOGUIDView.url_for('client1:{}'.format(self.task_id), self.admin_unit) with browser.expect_unauthorized(): browser.open(url)
def test_redirect_if_correct_client(self, browser): url = ResolveOGUIDView.url_for('client1:{}'.format(self.task_id), self.admin_unit) browser.login().open(url) self.assertEqual(self.task.absolute_url(), browser.url)
def test_check_permissions_fails_with_nobody(self, browser): logout() url = ResolveOGUIDView.url_for('client1:{}'.format(self.task_id), self.admin_unit) with self.assertRaises(Unauthorized): browser.open(url)