def get_public_config(): """Expose additional permissions-dependent config to client.""" if settings.INTEGRATION_SERVICE_URL: external_service = "/people/suggest" else: external_service = None public_config = { "external_help_url": getattr(settings, "EXTERNAL_HELP_URL", ""), "external_import_help_url": getattr(settings, "EXTERNAL_IMPORT_HELP_URL", ""), "snapshotable_objects": list(rules.Types.all), "snapshotable_ignored": list(rules.Types.ignore), "snapshotable_parents": list(rules.Types.parents), "snapshot_related": list(rules.Types.parents | rules.Types.scoped | rules.Types.trans_scope), "external_services": { "Person": external_service }, "enable_release_notes": settings.ENABLE_RELEASE_NOTES, } if permissions.is_admin(): if hasattr(settings, "RISK_ASSESSMENT_URL"): public_config["RISK_ASSESSMENT_URL"] = settings.RISK_ASSESSMENT_URL return public_config
def check_block_restrictions(self): """Check some block related restrictions""" if not self.object_class: self.add_errors(errors.WRONG_OBJECT_TYPE, line=self.offset + 2, object_name=self.class_name) return if self.object_class is CycleTaskGroupObjectTask and \ not permissions.is_admin(): self.add_errors(errors.PERMISSION_ERROR, line=self.offset + 2) logger.error("Import failed with: Only admin can update existing " "cycle-tasks via import") if self._has_non_importable_columns: importable_column_names = [] for field_name in self.object_class.IMPORTABLE_FIELDS: if field_name == 'slug': continue if field_name not in self.headers: continue importable_column_names.append( self.headers[field_name]["display_name"]) self.add_warning(errors.ONLY_IMPORTABLE_COLUMNS_WARNING, line=self.offset + 2, columns=", ".join(importable_column_names)) # Check mandatory column "code" for slugged objects. if issubclass(self.object_class, models.mixins.Slugged) and \ "slug" not in self.headers: self.add_errors(errors.MISSING_COLUMN, column_names="Code", line=self.offset + 2, s="")
def get_public_config(current_user): """Expose additional permissions-dependent config to client. Specifically here, expose RISK_ASSESSMENT_URL values to ADMIN users. """ public_config = {} if permissions.is_admin(): if hasattr(settings, 'RISK_ASSESSMENT_URL'): public_config['RISK_ASSESSMENT_URL'] = settings.RISK_ASSESSMENT_URL return public_config
def get_public_config(_): """Expose additional permissions-dependent config to client. Specifically here, expose GGRC_BOOTSTRAP_ADMIN values to ADMIN users. """ public_config = {} if rbac_permissions.is_admin(): if hasattr(settings, 'BOOTSTRAP_ADMIN_USERS'): public_config['BOOTSTRAP_ADMIN_USERS'] = settings.BOOTSTRAP_ADMIN_USERS return public_config
def check_block_restrictions(self): """Check some block related restrictions""" if not self.object_class: self.add_errors(errors.WRONG_OBJECT_TYPE, line=self.offset + 2, object_name=self.class_name) return if (self.operation == 'import' and self.object_class is CycleTaskGroupObjectTask and not permissions.is_admin()): self.add_errors(errors.PERMISSION_ERROR, line=self.offset + 2) logger.error("Import failed with: Only admin can update existing " "cycle-tasks via import")
def show_daily_digest_notifications(): """Get notification html for today's notifications. Returns: str: Html containing all today's notifications. """ # pylint: disable=invalid-name if not permissions.is_admin(): raise Forbidden() _, notif_data = get_daily_notifications() for data in notif_data.itervalues(): data = modify_data(data) return settings.EMAIL_DAILY.render(data=notif_data)
def show_pending_notifications(): """Get notification html for all future notifications. The data shown here is grouped by dates on which notifications should be sent. Note that the dates for all future notifications will be wrong since they are based on the current date which will be different when the notification is actually sent. Returns: str: Html containing all future notifications. """ if not permissions.is_admin(): raise Forbidden() _, notif_data = get_pending_notifications() for day_notif in notif_data.itervalues(): for data in day_notif.itervalues(): data = modify_data(data) return settings.EMAIL_PENDING.render(data=sorted(notif_data.iteritems()))
def get_public_config(): """Expose additional permissions-dependent config to client.""" if settings.INTEGRATION_SERVICE_URL: external_service = "/people/suggest" else: external_service = None public_config = { "external_help_url": getattr(settings, "EXTERNAL_HELP_URL", ""), "external_import_help_url": getattr(settings, "EXTERNAL_IMPORT_HELP_URL", ""), "snapshotable_objects": list(rules.Types.all), "snapshotable_ignored": list(rules.Types.ignore), "snapshotable_parents": list(rules.Types.parents), "snapshot_related": list( rules.Types.parents | rules.Types.scoped | rules.Types.trans_scope), "external_services": {"Person": external_service}, "enable_release_notes": settings.ENABLE_RELEASE_NOTES, } if permissions.is_admin(): if hasattr(settings, "RISK_ASSESSMENT_URL"): public_config["RISK_ASSESSMENT_URL"] = settings.RISK_ASSESSMENT_URL return public_config