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,
}
评论列表
文章目录