def form_to_db_schema_options(self, context): '''Returns the schema for the customized DGU form.''' schema = self.form_to_db_schema() # Sysadmins can save UKLP datasets with looser validation # constraints. This is because UKLP datasets are created using # a custom schema passed in from the harvester. However, when it # comes to re-saving the dataset via the dataset form, there are # some validation requirements we need to drop. That's what this # section of code does. pkg = context.get('package') if dgu_helpers.is_sysadmin_by_context(context) and \ pkg and pkg.extras.get('UKLP') == 'True': self._uklp_sysadmin_schema_updates(schema) if dgu_helpers.is_sysadmin_by_context(context) and \ pkg and pkg.extras.get('external_reference') == 'ONSHUB': self._ons_sysadmin_schema_updates(schema) return schema
def dgu_extra_fields_editable(context, data_dict): """ Determines whether a dataset's extra-fields are editable directly. Typically, this is only something we want sysadmins to be able to do. """ user = context.get('user') if dgu_helpers.is_sysadmin_by_context(context): return {'success': True} else: return {'success': False, 'msg': _('User %s not authorized to edit a dataset\'s extra fields') % str(user)}
def dgu_user_list(context, data_dict): model = context['model'] user = context.get('user','') user_obj = model.User.get(user) if dgu_helpers.is_sysadmin_by_context(context): return {'success': True} if not user or not user_obj: return {'success': False, 'msg': _('You must be logged in to view the user list')} if not len(user_obj.get_groups('organization')): return { 'success': False, 'msg': _('Only publishers may view this page') } return {'success': True}
def form_to_db_schema_options(self, context): '''Returns the schema for the customized DGU form.''' schema = self.form_to_db_schema() # Sysadmins can save UKLP datasets with looser validation # constraints. This is because UKLP datasets are created using # a custom schema passed in from the harvester. However, when it # comes to re-saving the dataset via the dataset form, there are # some validation requirements we need to drop. That's what this # section of code does. pkg = context.get('package') if dgu_helpers.is_sysadmin_by_context(context) and \ pkg and pkg.extras.get('UKLP') == 'True': self._uklp_sysadmin_schema_updates(schema) if pkg and pkg.extras.get('external_reference') == 'ONSHUB': self._ons_schema_updates(schema) return schema