• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nereid.flash函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nereid.flash函数的典型用法代码示例。如果您正苦于以下问题:Python flash函数的具体用法?Python flash怎么用?Python flash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: revenue_opportunity

    def revenue_opportunity(self):
        """
        Set the Conversion Probability and estimated revenue amount
        """
        NereidUser = Pool().get('nereid.user')

        nereid_user = NereidUser.search(
            [('employee', '=', self.employee.id)], limit=1
        )
        if nereid_user:
            employee = nereid_user[0]
        else:
            employee = None

        if request.method == 'POST':
            self.write([self], {
                'probability': request.form['probability'],
                'amount': Decimal(request.form.get('amount'))
            })
            flash('Lead has been updated.')
            return redirect(
                url_for('sale.opportunity.admin_lead', active_id=self.id)
                + "#tab-revenue"
            )
        return render_template(
            'crm/admin-lead.jinja', lead=self, employee=employee,
        )
开发者ID:openlabs,项目名称:nereid-crm,代码行数:27,代码来源:opportunity.py


示例2: get_linkedin_oauth_client

    def get_linkedin_oauth_client(
        self, scope='r_basicprofile,r_emailaddress',
        token='linkedin_oauth_token'
    ):
        """Returns a instance of WebCollect

        :param scope: Scope of information to be fetched from linkedin
        :param token: Token for authentication
        """
        if not all([self.linkedin_api_key, self.linkedin_api_secret]):
            current_app.logger.error("LinkedIn api settings are missing")
            flash(_("LinkedIn login is not available at the moment"))
            return None

        oauth = OAuth()
        linkedin = oauth.remote_app(
            'linkedin',
            base_url='https://api.linkedin.com',
            request_token_url='/uas/oauth/requestToken',
            access_token_url='/uas/oauth/accessToken',
            authorize_url='/uas/oauth/authenticate',
            consumer_key=self.linkedin_api_key,
            consumer_secret=self.linkedin_api_secret,
            request_token_params={'scope': scope}
        )
        linkedin.tokengetter_func = lambda *a: session.get(token)
        return linkedin
开发者ID:openlabs,项目名称:nereid-auth-linkedin,代码行数:27,代码来源:user.py


示例3: set_language

    def set_language(self):
        """Sets the language in the session of the user. Also try to guess the
        currency of the user, if not use the default currency of the website

        Accepted Methods: GET, POST
        Accepts XHR: Yes

        The language has to be provided in the GET arguments of POST form. It 
        is more convenient to pass the language code than the id of the 
        language because it makes it more readable in URLs
        """
        raise DeprecationWarning("Set language is deprecated")
        lang_obj = Pool().get('ir.lang')

        language = request.values.get('language')
        exists = lang_obj.search([('code', '=', language)], limit=1)

        if exists:
            flash(_('Your language preference have been saved.'))
        else:
            flash(_('Sorry! we do not speak your language yet!'))

        # redirect to the next url if given else take to home page
        redirect_to = request.values.get('next')
        if redirect_to:
            redirect_to.replace(session['language'], language)
        return redirect(
            request.values.get('next', url_for('nereid.website.home'))
            )
开发者ID:shalabhaggarwal,项目名称:nereid,代码行数:29,代码来源:routing.py


示例4: delete_from_cart

    def delete_from_cart(cls, line):
        """
        Delete a line from the cart. The required argument in POST is:

            line_id : ID of the line

        Response: 'OK' if X-HTTPRequest else redirect to shopping cart
        """
        SaleLine = Pool().get('sale.line')

        cart = cls.open_cart()
        if not cart.sale:
            abort(404)

        try:
            sale_line, = SaleLine.search([
                ('id', '=', line),
                ('sale', '=', cart.sale.id),
            ])
        except ValueError:
            message = 'Looks like the item is already deleted.'
        else:
            SaleLine.delete([sale_line])
            message = 'The order item has been successfully removed.'

        flash(_(message))

        if request.is_xhr:
            return jsonify(message=message)

        return redirect(url_for('nereid.cart.view_cart'))
开发者ID:2cadz,项目名称:nereid-cart-b2c,代码行数:31,代码来源:cart.py


示例5: edit_post

    def edit_post(self):
        """
            Edit an existing post
        """
        if self.nereid_user != request.nereid_user:
            abort(404)

        # Search for a post with same uri
        post_form = BlogPostForm(request.form, obj=self)

        with Transaction().set_context(blog_id=self.id):
            if request.method == 'POST' and post_form.validate():
                self.title = post_form.title.data
                self.content = post_form.content.data
                self.allow_guest_comments = post_form.allow_guest_comments.data
                self.save()
                flash('Your post has been updated.')
                if request.is_xhr:
                    return jsonify(success=True, item=self.serialize())
                return redirect(url_for(
                    'blog.post.render', user_id=self.nereid_user.id,
                    uri=self.uri
                ))
        if request.is_xhr:
            return jsonify(
                success=request.method != 'POST',  # False for POST, else True
                errors=post_form.errors or None,
            )
        return render_template(
            'blog_post_edit.jinja', form=post_form, post=self
        )
开发者ID:openlabs,项目名称:nereid-blog,代码行数:31,代码来源:blog.py


示例6: get_facebook_oauth_client

    def get_facebook_oauth_client(self, site=None):
        """Returns a instance of WebCollect

        :param site: Browserecord of the website, If not specified, it will be
                     guessed from the request context
        """
        if site is None:
            site = request.nereid_website

        if not all([site.facebook_app_id, site.facebook_app_secret]):
            current_app.logger.error("Facebook api settings are missing")
            flash(_("Facebook login is not available at the moment"))
            return None

        oauth = OAuth()
        facebook = oauth.remote_app('facebook',
            base_url='https://graph.facebook.com/',
            request_token_url=None,
            access_token_url='/oauth/access_token',
            authorize_url='https://www.facebook.com/dialog/oauth',
            consumer_key=site.facebook_app_id,
            consumer_secret=site.facebook_app_secret,
            request_token_params={'scope': 'email'}
        )
        facebook.tokengetter_func = lambda *a: session.get(
                'facebook_oauth_token'
        )
        return facebook
开发者ID:prakashpp,项目名称:nereid-auth-facebook,代码行数:28,代码来源:user.py


示例7: change_password

    def change_password(cls):
        """
        Changes the password

        .. tip::
            On changing the password, the user is logged out and the login page
            is thrown at the user
        """
        form = ChangePasswordForm(request.form)

        if request.method == 'POST' and form.validate():
            if request.nereid_user.match_password(form.old_password.data):
                cls.write(
                    [request.nereid_user],
                    {'password': form.password.data}
                )
                flash(
                    _('Your password has been successfully changed! '
                        'Please login again')
                )
                logout_user()
                return redirect(url_for('nereid.website.login'))
            else:
                flash(_("The current password you entered is invalid"))

        return render_template(
            'change-password.jinja', change_password_form=form
        )
开发者ID:sharoonthomas,项目名称:nereid,代码行数:28,代码来源:user.py


示例8: github_authorized_login

    def github_authorized_login(cls):
        """
        Authorized handler to which github will redirect the user to
        after the login attempt is made.
        """
        github = request.nereid_website.get_github_oauth_client()
        if github is None:
            return redirect(
                request.referrer or url_for('nereid.website.login')
            )

        try:
            # The response is an oauth2 response with code. But Github API
            # requires the
            if 'oauth_verifier' in request.args:
                data = github.handle_oauth1_response()
            elif 'code' in request.args:
                data = github.handle_oauth2_response()
            else:
                data = github.handle_unknown_response()
            github.free_request_token()
        except Exception, exc:
            current_app.logger.error("Github login failed %s" % exc)
            flash(_("We cannot talk to github at this time. Please try again"))
            return redirect(
                request.referrer or url_for('nereid.website.login')
            )
开发者ID:openlabs,项目名称:nereid-auth-github,代码行数:27,代码来源:user.py


示例9: remove_tag

    def remove_tag(cls, task_id, tag_id):
        """
        Assigns the provided to this task

        :param task_id: ID of task
        :param tag_id: ID of tag
        """
        Activity = Pool().get("nereid.activity")
        task = cls.get_task(task_id)

        cls.write([task], {"tags": [("unlink", [tag_id])]})
        Activity.create(
            [
                {
                    "actor": request.nereid_user.id,
                    "object_": "project.work, %d" % task.id,
                    "verb": "removed_tag_from_task",
                    "target": "project.work, %d" % task.parent.id,
                    "project": task.parent.id,
                }
            ]
        )

        if request.method == "POST":
            flash("Tag removed from task %s" % task.rec_name)
            return redirect(request.referrer)

        flash("Tag cannot be removed")
        return redirect(request.referrer)
开发者ID:GauravButola,项目名称:nereid-project,代码行数:29,代码来源:task.py


示例10: create_task

    def create_task(self, project_id):
        """Create a new task for the specified project

        POST will create a new task
        """
        project = self.get_project(project_id)
        # Check if user is among the participants
        self.can_write(project, request.nereid_user)

        if request.method == 'POST':
            task_id = self.create({
                'parent': project_id,
                'name': request.form['name'],
                'type': 'task',
                'comment': request.form.get('description', False),
            })
            flash("Task successfully added to project %s" % project.name)
            return redirect(
                url_for('project.work.render_task',
                    project_id=project_id, task_id=task_id
                )
            )

        flash("Could not create task. Try again.")
        return redirect(request.referrer)
开发者ID:Anoopsmohan,项目名称:nereid-project,代码行数:25,代码来源:project.py


示例11: assign_task

    def assign_task(self, task_id):
        """Assign task to a user

        :param task_id: Id of Task
        """
        nereid_user_obj = Pool().get('nereid.user')

        task = self.get_task(task_id)

        new_assignee = nereid_user_obj.browse(int(request.form['user']))

        if self.can_write(task.parent, new_assignee):
            self.write(task.id, {
                'assigned_to': new_assignee.id
            })

            if request.is_xhr:
                return jsonify({
                    'success': True,
                })

            flash("Task assigned to %s" % new_assignee.name)
            return redirect(request.referrer)

        flash("Only employees can be assigned to tasks.")
        return redirect(request.referrer)
开发者ID:Anoopsmohan,项目名称:nereid-project,代码行数:26,代码来源:project.py


示例12: add

    def add(cls):
        """
        Adds a contact mechanism to the party's contact mechanisms
        """
        form = cls.get_form()
        if form.validate_on_submit():
            cls.create(
                [
                    {
                        "party": request.nereid_user.party.id,
                        "type": form.type.data,
                        "value": form.value.data,
                        "comment": form.comment.data,
                    }
                ]
            )
            if request.is_xhr:
                return jsonify({"success": True})
            return redirect(request.referrer)

        if request.is_xhr:
            return jsonify({"success": False})
        else:
            for field, messages in form.errors:
                flash("<br>".join(messages), "Field %s" % field)
            return redirect(request.referrer)
开发者ID:GauravButola,项目名称:nereid,代码行数:26,代码来源:party.py


示例13: remove_tag

    def remove_tag(cls, task_id, tag_id):
        """
        Assigns the provided to this task

        :param task_id: ID of task
        :param tag_id: ID of tag
        """
        Activity = Pool().get('nereid.activity')
        task = cls.get_task(task_id)

        cls.write(
            [task], {'tags': [('remove', [tag_id])]}
        )
        Activity.create([{
            'actor': request.nereid_user.id,
            'object_': 'project.work, %d' % task.id,
            'verb': 'removed_tag_from_task',
            'target': 'project.work, %d' % task.parent.id,
            'project': task.parent.id,
        }])

        if request.method == 'POST':
            flash('Tag removed from task %s' % task.rec_name)
            return redirect(request.referrer)

        flash("Tag cannot be removed")
        return redirect(request.referrer)
开发者ID:openlabs,项目名称:nereid-project,代码行数:27,代码来源:task.py


示例14: get_linkedin_oauth_client

    def get_linkedin_oauth_client(self, site=None, 
            scope='r_basicprofile,r_emailaddress',
            token='linkedin_oauth_token'):
        """Returns a instance of WebCollect

        :param site: Browserecord of the website, If not specified, it will be
                     guessed from the request context
        """
        if site is None:
            site = request.nereid_website

        if not all([site.linkedin_api_key, site.linkedin_api_secret]):
            current_app.logger.error("LinkedIn api settings are missing")
            flash(_("LinkedIn login is not available at the moment"))
            return None

        oauth = OAuth()
        linkedin = oauth.remote_app('linkedin',
            base_url='https://api.linkedin.com',
            request_token_url='/uas/oauth/requestToken',
            access_token_url='/uas/oauth/accessToken',
            authorize_url='/uas/oauth/authenticate',
            consumer_key=site.linkedin_api_key,
            consumer_secret=site.linkedin_api_secret,
            request_token_params={'scope': scope}
        )
        linkedin.tokengetter_func = lambda *a: session.get(token)
        return linkedin
开发者ID:shalabhaggarwal,项目名称:nereid-auth-linkedin,代码行数:28,代码来源:user.py


示例15: new_password

    def new_password(self):
        """Create a new password

        .. tip::

            Unlike change password this does not demand the old password.
            And hence this method will check in the session for a parameter
            called allow_new_password which has to be True. This acts as a
            security against attempts to POST to this method and changing
            password.

            The allow_new_password flag is popped on successful saving

        This is intended to be used when a user requests for a password reset.
        """
        form = NewPasswordForm(request.form)

        if request.method == "POST" and form.validate():
            if not session.get("allow_new_password", False):
                current_app.logger.debug("New password not allowed in session")
                abort(403)

            self.write(request.nereid_user.id, {"password": form.password.data})
            session.pop("allow_new_password")
            flash(_("Your password has been successfully changed! " "Please login again"))
            session.pop("user")
            return redirect(url_for("nereid.website.login"))

        return render_template("new-password.jinja", password_form=form)
开发者ID:shalabhaggarwal,项目名称:trytond-nereid,代码行数:29,代码来源:party.py


示例16: change_constraint_dates

    def change_constraint_dates(cls, task_id):
        """
        Change the constraint dates
        """
        Activity = Pool().get("nereid.activity")

        task = cls.get_task(task_id)

        data = {"constraint_start_time": False, "constraint_finish_time": False}

        constraint_start = request.form.get("constraint_start_time", None)
        constraint_finish = request.form.get("constraint_finish_time", None)

        if constraint_start:
            data["constraint_start_time"] = datetime.strptime(constraint_start, "%m/%d/%Y")
        if constraint_finish:
            data["constraint_finish_time"] = datetime.strptime(constraint_finish, "%m/%d/%Y")

        cls.write([task], data)
        Activity.create(
            [
                {
                    "actor": request.nereid_user.id,
                    "object_": "project.work, %d" % task.id,
                    "verb": "changed_date",
                    "project": task.parent.id,
                }
            ]
        )

        if request.is_xhr:
            return jsonify({"success": True})

        flash("The constraint dates have been changed for this task.")
        return redirect(request.referrer)
开发者ID:GauravButola,项目名称:nereid-project,代码行数:35,代码来源:task.py


示例17: reset_account

    def reset_account(self):
        """
        Reset the password for the user.

        .. tip::
            This does NOT reset the password, but just creates an activation
            code and sends the link to the email of the user. If the user uses
            the link, he can change his password.
        """
        if request.method == "POST":
            user_ids = self.search(
                [("email", "=", request.form["email"]), ("company", "=", request.nereid_website.company.id)]
            )

            if not user_ids:
                flash(_("Invalid email address"))
                return render_template("reset-password.jinja")

            self.create_act_code(user_ids[0], "reset")
            user = self.browse(user_ids[0])
            self.send_reset_email(user)
            flash(_("An email has been sent to your account for resetting" " your credentials"))
            return redirect(url_for("nereid.website.login"))

        return render_template("reset-password.jinja")
开发者ID:shalabhaggarwal,项目名称:trytond-nereid,代码行数:25,代码来源:party.py


示例18: delete_task

    def delete_task(cls, task_id):
        """
        Delete the task from project

        Tasks can be deleted only if
            1. The user is project admin
            2. The user is an admin member in the project

        :param task_id: Id of the task to be deleted
        """
        task = cls.get_task(task_id)

        # Check if user is among the project admins
        if not request.nereid_user.is_admin_of_project(task.parent):
            flash(
                "Sorry! You are not allowed to delete tasks. \
                Contact your project admin for the same."
            )
            return redirect(request.referrer)

        cls.write([task], {"active": False})

        if request.is_xhr:
            return jsonify({"success": True})

        flash("The task has been deleted")
        return redirect(url_for("project.work.render_project", project_id=task.parent.id))
开发者ID:GauravButola,项目名称:nereid-project,代码行数:27,代码来源:task.py


示例19: facebook_authorized_login

    def facebook_authorized_login(self):
        """Authorized handler to which facebook will redirect the user to
        after the login attempt is made.
        """
        website_obj = Pool().get('nereid.website')

        facebook = website_obj.get_facebook_oauth_client()
        if facebook is None:
            return redirect(
                request.referrer or url_for('nereid.website.login')
            )

        try:
            if 'oauth_verifier' in request.args:
                data = facebook.handle_oauth1_response()
            elif 'code' in request.args:
                data = facebook.handle_oauth2_response()
            else:
                data = facebook.handle_unknown_response()
            facebook.free_request_token()
        except Exception, exc:
            current_app.logger.error("Facebook login failed", exc)
            flash(_("We cannot talk to facebook at this time. Please try again"))
            return redirect(
                request.referrer or url_for('nereid.website.login')
            )
开发者ID:prakashpp,项目名称:nereid-auth-facebook,代码行数:26,代码来源:user.py


示例20: reset_account

    def reset_account(cls):
        """
        Reset the password for the user.

        .. tip::
            This does NOT reset the password, but just creates an activation
            code and sends the link to the email of the user. If the user uses
            the link, he can change his password.
        """
        form = ResetAccountForm()
        if form.validate_on_submit():
            try:
                nereid_user, = cls.search([
                    ('email', '=', form.email.data),
                    ('company', '=', current_website.company.id),
                ])
            except ValueError:
                return cls.build_response(
                    'Invalid email address',
                    render_template('reset-password.jinja'),
                    400
                )
            nereid_user.send_reset_email()
            return cls.build_response(
                'An email has been sent to your account for resetting'
                ' your credentials',
                redirect(url_for('nereid.website.login')), 200
            )
        elif form.errors:
            if request.is_xhr or request.is_json:
                return jsonify(error=form.errors), 400
            flash(_('Invalid email address.'))

        return render_template('reset-password.jinja')
开发者ID:2cadz,项目名称:nereid,代码行数:34,代码来源:user.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nereid.jsonify函数代码示例发布时间:2022-05-27
下一篇:
Python nereid.abort函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap