return.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Tktr 作者: Intuity 项目源码 文件源码
def return_view(self):
        tick_id = self.request.matchdict["tick_id"]
        user = self.user
        ticket = None
        # Find ticket
        for tick in user.tickets:
            if tick.__name__ == tick_id:
                ticket = tick
                break
        # If not found, user doesn't own it!
        if ticket == None:
            self.request.session.flash("The requested ticket does not exist.", "error")
            return HTTPFound(location=self.request.route_path("user_profile"))
        # Check this is not a purchased ticket
        if ticket.payment.paid:
            self.request.session.flash("The requested ticket has already been paid for and cannot be returned.", "error")
            return HTTPFound(location=self.request.route_path("user_profile"))
        # If this is their ticket, check they have no others
        if ticket.guest_info == ticket.owner.profile and len(user.tickets) > 1 and self.guest_details_required:
            self.request.session.flash("You may not return your own ticket whilst you still hold guest tickets.", "error")
            return HTTPFound(location=self.request.route_path("user_profile"))
        return {
            "ticket" : ticket,
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号