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


Python nereid.redirect函数代码示例

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


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

示例1: 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

示例2: linkedin_authorized_login

    def linkedin_authorized_login(cls):
        """Authorized handler to which linkedin will redirect the user to
        after the login attempt is made.
        """
        Party = Pool().get('party.party')

        linkedin = request.nereid_website.get_linkedin_oauth_client()
        if linkedin is None:
            return redirect(
                request.referrer or url_for('nereid.website.login')
            )

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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: render_comments

    def render_comments(self):
        """
        Render comments

        GET: Return json of all the comments of this post.
        POST: Create new comment for this post.
        """
        if self.state != 'Published':
            abort(404)

        # Add re_captcha if the configuration has such an option and user
        # is guest
        if 're_captcha_public' in CONFIG.options and request.is_guest_user:
            comment_form = GuestCommentForm(
                request.form, captcha={'ip_address': request.remote_addr}
            )
        else:
            comment_form = PostCommentForm(request.form)

        if request.method == 'GET':
            if self.nereid_user == request.nereid_user:
                return jsonify(comments=[
                    comment.serialize() for comment in self.comments
                ])
            return jsonify(comments=[
                comment.serialize() for comment in self.comments
                if not comment.is_spam
            ])

        # If post does not allow guest comments,
        # then dont allow guest user to comment
        if not self.allow_guest_comments and request.is_guest_user:
            flash('Guests are not allowed to write comments')
            if request.is_xhr:
                return jsonify(
                    success=False,
                    errors=['Guests are not allowed to write comments']
                )
            return redirect(url_for(
                'blog.post.render', user_id=self.nereid_user.id, uri=self.uri
            ))

        if request.method == 'POST' and comment_form.validate():
            self.write([self], {
                'comments': [('create', [{
                    'nereid_user': current_user.id
                        if not current_user.is_anonymous() else None,
                    'name': current_user.display_name
                        if not current_user.is_anonymous()
                            else comment_form.name.data,
                    'content': comment_form.content.data,
                }])]
            })

        if request.is_xhr:
            return jsonify(success=True) if comment_form.validate() \
                else jsonify(success=False, errors=comment_form.errors)
        return redirect(url_for(
            'blog.post.render', user_id=self.nereid_user.id, uri=self.uri
        ))
开发者ID:openlabs,项目名称:nereid-blog,代码行数:60,代码来源:blog.py

示例8: 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

示例9: 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

示例10: checkout

    def checkout(self):
        '''Submit of default checkout

        A GET to the method will result in passing of control to begin as
        that is basically the entry point to the checkout

        A POST to the method will result in the confirmation of the order and
        subsequent handling of data.
        '''
        cart_obj = Pool().get('nereid.cart')
        sale_obj = Pool().get('sale.sale')

        cart = cart_obj.open_cart()
        if not cart.sale:
            # This case is possible if the user changes his currency at
            # the point of checkout and the cart gets cleared.
            return redirect(url_for('nereid.cart.view_cart'))

        sale = cart.sale
        if not sale.lines:
            flash(_("Add some items to your cart before you checkout!"))
            return redirect(url_for('nereid.website.home'))
        if request.method == 'GET':
            return (self._begin_guest() if request.is_guest_user \
                else self._begin_registered())

        elif request.method == 'POST':
            form, do_process = self._submit_guest() if request.is_guest_user \
                else self._submit_registered()
            if do_process:
                # Process Shipping
                self._process_shipment(sale, form)

                # Process Payment, if the returned value from the payment
                # is a response object (isinstance) then return that instead
                # of the success page. This will allow reidrects to a third 
                # party gateway or service to collect payment.
                response = self._process_payment(sale, form)
                if isinstance(response, BaseResponse):
                    return response

                if sale.state == 'draft':
                    # Ensure that the order date is that of today
                    cart_obj.check_update_date(cart)
                    # Confirm the order
                    sale_obj.quote([sale.id])
                    sale_obj.confirm([sale.id])

                flash(_("Your order #%(sale)s has been processed", sale=sale.reference))
                if request.is_guest_user:
                    return redirect(url_for('nereid.website.home'))
                else:
                    return redirect(
                        url_for(
                            'sale.sale.render', sale=sale.id, 
                            confirmation=True
                        )
                    )

            return render_template('checkout.jinja', form=form, cart=cart)
开发者ID:shalabhaggarwal,项目名称:nereid-checkout,代码行数:60,代码来源:checkout.py

示例11: change_estimated_hours

    def change_estimated_hours(self):
        """Change estimated hours.

        :param task_id: ID of the task.
        """
        if not request.nereid_user.employee:
            flash("Sorry! You are not allowed to change estimate hours.")
            return redirect(request.referrer)

        estimated_hours = request.form.get("new_estimated_hours", None, type=float)
        if estimated_hours:
            self.write([self], {"effort": estimated_hours})
        flash("The estimated hours have been changed for this task.")
        return redirect(request.referrer)
开发者ID:GauravButola,项目名称:nereid-project,代码行数:14,代码来源:task.py

示例12: assign_lead

    def assign_lead(self):
        "Change the employee on lead"
        NereidUser = Pool().get('nereid.user')

        new_assignee = NereidUser(int(request.form['user']))
        if self.employee.id == new_assignee.employee.id:
            flash("Lead already assigned to %s" % new_assignee.party.name)
            return redirect(request.referrer)

        self.write([self], {
            'employee': new_assignee.employee.id
        })

        flash("Lead assigned to %s" % new_assignee.party.name)
        return redirect(request.referrer)
开发者ID:openlabs,项目名称:nereid-crm,代码行数:15,代码来源:opportunity.py

示例13: render_wishlist

    def render_wishlist(self):
        """
        Render specific wishlist of current user.
        rename wishlist on post  and delete on delete request
        """
        Wishlist = Pool().get('wishlist.wishlist')

        if self.nereid_user != current_user and \
                (request.method != "GET" or not self.is_public):

            abort(404)

        if request.method == "POST" and request.form.get('name'):

            name = request.form.get('name')
            wishlist = Wishlist.search([
                ('nereid_user', '=', current_user.id),
                ('id', '!=', self.id),
                ('name', '=', name),
            ], limit=1)
            if wishlist:
                flash(
                    _(
                        'Wishlist with name: %(name)s already exists.',
                        name=name
                    )
                )
                return redirect(request.referrer)
            else:
                self.name = name
                self.is_public = True if request.form.get('is_public') \
                    else False
                self.save()
                flash(_('Wishlist Updated'))
            if request.is_xhr:
                return 'success', 200

            return redirect(request.referrer)

        elif request.method == "DELETE":
            Wishlist.delete([self])
            if request.is_xhr:
                # TODO: send serialized data of current wishlist
                return 'success', 200

            return url_for('wishlist.wishlist.render_wishlists')

        return render_template('wishlist.jinja', wishlist=self)
开发者ID:fulfilio,项目名称:nereid-wishlist,代码行数:48,代码来源:wishlist.py

示例14: edit_task

    def edit_task(self):
        """
        Edit the task
        """
        Activity = Pool().get('nereid.activity')
        Work = Pool().get('timesheet.work')

        task = self.get_task(self.id)

        Work.write([task.work], {
            'name': request.form.get('name'),
        })
        self.write([task], {
            'comment': request.form.get('comment')
        })
        Activity.create([{
            'actor': request.nereid_user.id,
            'object_': 'project.work, %d' % task.id,
            'verb': 'edited_task',
            'target': 'project.work, %d' % task.parent.id,
            'project': task.parent.id,
        }])
        if request.is_xhr:
            return jsonify({
                'success': True,
                'name': self.rec_name,
                'comment': self.comment,
            })
        return redirect(request.referrer)
开发者ID:openlabs,项目名称:nereid-project,代码行数:29,代码来源:task.py

示例15: 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


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