示例#1
0
def insert_tickets(user,no_tickets):
        events = Event.objects.all()
        for e in events:
            ticket = Ticket()
            ticket.event = e
            ticket.price = e.price
            ticket.quantity = no_tickets
            ticket.user = User.objects.get(username=user.username)
            ticket.save()
示例#2
0
def build_ticket():
    form = Add_ticket()
    if form.validate_on_submit():
        info = Ticket(number=form.number.data,
                      summary=form.summary.data,
                      ticket_type=form.ticket_type.data,
                      assinge_date=form.assigne_date.data,
                      assigne_id=form.assigne_id.data)
        info.save()
        return redirect(url_for('main.index'))
    return render_template('main/build_ticket.html', form=form)
示例#3
0
    def create(self, validated_data):
        log.debug("TicketCreateSerializer:create")
        instance = Ticket()
        title = validated_data.get('title', "No Title")
        description = validated_data.get('description', "No Description")
        user = validated_data.get('user', None)
        speed_test = validated_data.get("speed_test", None)
        wifi_points = validated_data.get("wifi_points", None)
        location_point = validated_data.get("location_point", None)

        instance.title = title
        instance.description = description
        instance.user = user if user else None
        instance.speed_test = speed_test
        instance.wifi_points = wifi_points
        instance.location_point = location_point
        instance.save()
        return instance
示例#4
0
def tickets(request):
    logged_user = request.user.username
    user = User.objects.get(username=logged_user)

    if request.method == 'POST':
        trip_id = request.POST.get('trip_id')

        trip = Trip.objects.get(id=trip_id)
        seats = trip.seats
        if seats:
            trip.seats = seats - 1
            trip.save()

        t = Ticket(trip=trip, user=user, ticket_number=(randint(1000, 9999)))
        t.save()

    all_tickets = Ticket.objects.all().filter(user=user)
    context_dict = {'tickets': all_tickets}
    return render(request, 'app/tickets.html', context_dict)