当前位置: 首页>>代码示例>>Python>>正文


Python helpers.flash_success方法代码示例

本文整理汇总了Python中ckan.lib.helpers.flash_success方法的典型用法代码示例。如果您正苦于以下问题:Python helpers.flash_success方法的具体用法?Python helpers.flash_success怎么用?Python helpers.flash_success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ckan.lib.helpers的用法示例。


在下文中一共展示了helpers.flash_success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _action

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def _action(self, action, context, username, groupname, 
                dataset_type, classification, success_msg):
        try:
            toolkit.get_action(action)(context,
                            data_dict={'username': username, 
                                       'groupname': groupname, 
                                       'dataset_type': dataset_type,
                                       'classification': classification}
            )
        except toolkit.NotAuthorized:
            toolkit.abort(401,
                          toolkit._('Unauthorized to perform that action'))
        except toolkit.ObjectNotFound as e :
            error_message = (e.message or e.error_summary
                         or e.error_dict)
            helpers.flash_error(error_message)
        except toolkit.ValidationError as e:
            error_message = e.error_dict
            helpers.flash_error(error_message['message'])
        else:
            helpers.flash_success(toolkit._(success_msg)) 
开发者ID:abgov,项目名称:ckanext-classification,代码行数:23,代码来源:security_controller.py

示例2: follow

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def follow(self, id):
        '''Start following this group.'''
        self._ensure_controller_matches_group_type(id)
        context = {'model': model,
                   'session': model.Session,
                   'user': c.user}
        data_dict = {'id': id}
        try:
            get_action('follow_group')(context, data_dict)
            group_dict = get_action('group_show')(context, data_dict)
            h.flash_success(_("You are now following {0}").format(
                group_dict['title']))
        except ValidationError as e:
            error_message = (e.message or e.error_summary
                             or e.error_dict)
            h.flash_error(error_message)
        except NotAuthorized as e:
            h.flash_error(e.message)
        h.redirect_to(controller='group', action='read', id=id) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:21,代码来源:group.py

示例3: unfollow

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def unfollow(self, id):
        '''Stop following this group.'''
        self._ensure_controller_matches_group_type(id)
        context = {'model': model,
                   'session': model.Session,
                   'user': c.user}
        data_dict = {'id': id}
        try:
            get_action('unfollow_group')(context, data_dict)
            group_dict = get_action('group_show')(context, data_dict)
            h.flash_success(_("You are no longer following {0}").format(
                group_dict['title']))
        except ValidationError as e:
            error_message = (e.message or e.error_summary
                             or e.error_dict)
            h.flash_error(error_message)
        except (NotFound, NotAuthorized) as e:
            error_message = e.message
            h.flash_error(error_message)
        h.redirect_to(controller='group', action='read', id=id) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:22,代码来源:group.py

示例4: follow

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def follow(self, id):
        '''Start following this dataset.'''
        context = {'model': model,
                   'session': model.Session,
                   'user': c.user, 'auth_user_obj': c.userobj}
        data_dict = {'id': id}
        try:
            get_action('follow_dataset')(context, data_dict)
            package_dict = get_action('package_show')(context, data_dict)
            h.flash_success(_("You are now following {0}").format(
                package_dict['title']))
        except ValidationError as e:
            error_message = (e.message or e.error_summary
                             or e.error_dict)
            h.flash_error(error_message)
        except NotAuthorized as e:
            h.flash_error(e.message)
        h.redirect_to(controller='package', action='read', id=id) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:20,代码来源:package.py

示例5: unfollow

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def unfollow(self, id):
        '''Stop following this dataset.'''
        context = {'model': model,
                   'session': model.Session,
                   'user': c.user, 'auth_user_obj': c.userobj}
        data_dict = {'id': id}
        try:
            get_action('unfollow_dataset')(context, data_dict)
            package_dict = get_action('package_show')(context, data_dict)
            h.flash_success(_("You are no longer following {0}").format(
                package_dict['title']))
        except ValidationError as e:
            error_message = (e.message or e.error_summary
                             or e.error_dict)
            h.flash_error(error_message)
        except (NotFound, NotAuthorized) as e:
            error_message = e.message
            h.flash_error(error_message)
        h.redirect_to(controller='package', action='read', id=id) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:21,代码来源:package.py

示例6: generate_apikey

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def generate_apikey(self, id):
        '''Cycle the API key of a user'''
        context = {'model': model,
                   'session': model.Session,
                   'user': c.user,
                   'auth_user_obj': c.userobj,
                   }
        if id is None:
            if c.userobj:
                id = c.userobj.id
            else:
                abort(400, _('No user specified'))
        data_dict = {'id': id}

        try:
            result = get_action('user_generate_apikey')(context, data_dict)
        except NotAuthorized:
            abort(403, _('Unauthorized to edit user %s') % '')
        except NotFound:
            abort(404, _('User not found'))

        h.flash_success(_('Profile updated'))
        h.redirect_to(controller='user', action='read', id=result['name']) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:25,代码来源:user.py

示例7: follow

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def follow(self, id):
        '''Start following this user.'''
        context = {'model': model,
                   'session': model.Session,
                   'user': c.user,
                   'auth_user_obj': c.userobj}
        data_dict = {'id': id, 'include_num_followers': True}
        try:
            get_action('follow_user')(context, data_dict)
            user_dict = get_action('user_show')(context, data_dict)
            h.flash_success(_("You are now following {0}").format(
                user_dict['display_name']))
        except ValidationError as e:
            error_message = (e.message or e.error_summary
                             or e.error_dict)
            h.flash_error(error_message)
        except NotAuthorized as e:
            h.flash_error(e.message)
        h.redirect_to(controller='user', action='read', id=id) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:21,代码来源:user.py

示例8: unfollow

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def unfollow(self, id):
        '''Stop following this user.'''
        context = {'model': model,
                   'session': model.Session,
                   'user': c.user,
                   'auth_user_obj': c.userobj}
        data_dict = {'id': id, 'include_num_followers': True}
        try:
            get_action('unfollow_user')(context, data_dict)
            user_dict = get_action('user_show')(context, data_dict)
            h.flash_success(_("You are no longer following {0}").format(
                user_dict['display_name']))
        except (NotFound, NotAuthorized) as e:
            error_message = e.message
            h.flash_error(error_message)
        except ValidationError as e:
            error_message = (e.error_summary or e.message
                             or e.error_dict)
            h.flash_error(error_message)
        h.redirect_to(controller='user', action='read', id=id) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:22,代码来源:user.py

示例9: delete

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def delete(self,id):
        try:
            context = {'model':model, 'user':c.user}

            context['clear_source'] = request.params.get('clear', '').lower() in (u'true', u'1')

            p.toolkit.get_action('harvest_source_delete')(context, {'id':id})

            if context['clear_source']:
                h.flash_success(_('Harvesting source successfully cleared'))
            else:
                h.flash_success(_('Harvesting source successfully inactivated'))

            h.redirect_to(h.url_for('{0}_admin'.format(DATASET_TYPE_NAME), id=id))
        except p.toolkit.ObjectNotFound:
            abort(404,_('Harvest source not found'))
        except p.toolkit.NotAuthorized:
            abort(401,self.not_auth_message) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:20,代码来源:view.py

示例10: refresh

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def refresh(self, id):
        try:
            context = {'model':model, 'user':c.user, 'session':model.Session}
            p.toolkit.get_action('harvest_job_create')(
                context, {'source_id': id, 'run': True})
            h.flash_success(_('Harvest will start shortly. Refresh this page for updates.'))
        except p.toolkit.ObjectNotFound:
            abort(404,_('Harvest source not found'))
        except p.toolkit.NotAuthorized:
            abort(401,self.not_auth_message)
        except HarvestSourceInactiveError, e:
            h.flash_error(_('Cannot create new harvest jobs on inactive '
                            'sources. First, please change the source status '
                            'to \'active\'.'))
        except HarvestJobExists, e:
            h.flash_notice(_('A harvest job has already been scheduled for '
                             'this source'))
        except Exception, e:
                msg = 'An error occurred: [%s]' % str(e)
                h.flash_error(msg)

        h.redirect_to(h.url_for('{0}_admin'.format(DATASET_TYPE_NAME), id=id)) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:24,代码来源:view.py

示例11: dataset_doi_admin_process

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def dataset_doi_admin_process(self, dataset_url, dataset):
        # If running on local machine, just resolve DOI to the dev server
        if 'localhost' in dataset_url or '127.0.0.1' in dataset_url:
            xml_url = config.get('ckanext.ands.debug_url')
        else:
            xml_url = dataset_url

        post_data = request.POST['xml']

        resp = post_doi_request(xml_url, post_data)
        try:
            json = loads(resp.content)
        except ValueError as exp:
            h.flash_error("Invalid response from DOI server: {} :: {}".format(exp, resp.content))
            return toolkit.redirect_to(dataset_url)
        try:
            response_dict = json["response"]
        except KeyError:
            h.flash_error("Response had no response key: {}".format(json))
            return toolkit.redirect_to(dataset_url)

        doi = response_dict["doi"]
        response_code = response_dict["responsecode"]
        success_code = "MT001"

        if response_code == success_code:
            dataset['doi_id'] = doi
            toolkit.get_action('package_update')(None, dataset)

            email_requestors(dataset['id'])

            h.flash_success("DOI Created successfully")
        else:
            type = response_dict["type"]
            err_msg = response_dict["message"]
            verbose_msg = response_dict["verbosemessage"]
            msg = response_code + ' - ' + type + '. ' + verbose_msg + '. ' + err_msg
            h.flash_error(_(msg))

        return toolkit.redirect_to(dataset_url) 
开发者ID:Psykar,项目名称:ckanext-ands,代码行数:42,代码来源:controller.py

示例12: handle_submit

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def handle_submit(self, id):
        data = clean_dict(dict_fns.unflatten(tuplize_dict(parse_params(
            request.params))))

        data['dataset_url'] = toolkit.url_for(
            controller='package',
            action='read',
            id=id,
            qualified=True
        )

        package = get_action('package_show')(None, {'id': id})
        self.fail_if_private(package, data['dataset_url'])

        # Comma separated config var
        to_addrs = config['ckanext.ands.support_emails'].split(',')

        subject = 'DataPortal Support: Request to publish dataset'

        body = base.render(
            'package/doi_email.text',
            extra_vars=data)

        for email in to_addrs:
            mail_recipient('Dataportal support', email, subject, body)

        data['package_id'] = package['id']
        data['user_id'] = c.userobj.id

        doi_request = DoiRequest(**data)
        Session.add(doi_request)
        Session.commit()

        h.flash_success("DOI Request sent")
        return toolkit.redirect_to(data['dataset_url']) 
开发者ID:Psykar,项目名称:ckanext-ands,代码行数:37,代码来源:controller.py

示例13: clear

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def clear(self, id):
        try:
            context = {'model':model, 'user':c.user, 'session':model.Session}
            p.toolkit.get_action('harvest_source_clear')(context,{'id':id})
            h.flash_success(_('Harvest source cleared'))
        except p.toolkit.ObjectNotFound:
            abort(404,_('Harvest source not found'))
        except p.toolkit.NotAuthorized:
            abort(401,self.not_auth_message)
        except Exception, e:
            msg = 'An error occurred: [%s]' % str(e)
            h.flash_error(msg)

        h.redirect_to(h.url_for('{0}_admin'.format(DATASET_TYPE_NAME), id=id)) 
开发者ID:italia,项目名称:dati-ckan-docker,代码行数:16,代码来源:view.py

示例14: email

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def email(self):
        '''
            Handles creating the email template in admin dashboard.

            :returns template
        '''
        data = request.POST
        if 'save' in data:
            try:
                data_dict = dict(request.POST)
                del data_dict['save']
                data = _get_action('config_option_update', data_dict)
                h.flash_success(_('Successfully updated.'))
            except logic.ValidationError, e:
                errors = e.error_dict
                error_summary = e.error_summary
                vars = {'data': data, 'errors': errors,
                        'error_summary': error_summary}
                return base.render('admin/email.html', extra_vars=vars)

            h.redirect_to(controller=self.ctrl, action='email')

        schema = logic.schema.update_configuration_schema()
        data = {}
        for key in schema:
            data[key] = config.get(key)

        vars = {'data': data, 'errors': {}}
        return toolkit.render('admin/email.html', extra_vars=vars) 
开发者ID:ViderumGlobal,项目名称:ckanext-requestdata,代码行数:31,代码来源:admin.py

示例15: clear

# 需要导入模块: from ckan.lib import helpers [as 别名]
# 或者: from ckan.lib.helpers import flash_success [as 别名]
def clear(self):
        '''
        Clears the PyCSW database
        '''
        config_path = config.get('ckan.ioos_theme.pycsw_config')
        if os.path.exists(config_path):
            try:
                self._clear_pycsw(config_path)
                h.flash_success(_('PyCSW has been cleared'))
            except Exception:
                h.flash_error('Unable to clear PyCSW, see logs for details')
        else:
            h.flash_error('Config for PyCSW doesn\'t exist')
        h.redirect_to(controller='ckanext.ioos_theme.controllers.csw:CswController', action='index')
        return 
开发者ID:ioos,项目名称:catalog-ckan,代码行数:17,代码来源:csw.py


注:本文中的ckan.lib.helpers.flash_success方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。