Exemplo n.º 1
0
def cancel(request, ticket_id):
    user = request.user
    if user.is_authenticated() is False:
        return HttpResponseRedirect('/home/')
    tour_ticket = TourTicket.objects.get(pk=ticket_id)
    if tour_ticket is None:
        return HttpResponseRedirect('/home/')
    if tour_ticket.customer.global_user.user.id is not user.id:
        return HttpResponseRedirect('/home/')
    user.globaluser.credit += Util.get_cancel_cost(tour_ticket.tour.service.price)
    user.globaluser.save()
    tour_ticket.delete()
    return HttpResponseRedirect('/profile/')
Exemplo n.º 2
0
 def get_cost(self):
     if self.is_reserved:
         return -Util.get_reserve_cost(self.tour.service.price)
     return self.tour.service.price