def select_route(request):
    passenger_id = request.session['passenger_id']

    form = TicketForm(request.POST or None)
    routes = Route.objects.all()

    context = {}
    context.update({'routes': routes, 'passenger_id': passenger_id})

    if form.is_valid():
        id = request.POST['route']
        journey_type = request.POST['journey_type']
        request.session['passenger_id'] = passenger_id
        obj = Route.objects.get(id=id)
        out_ticket = generate_ticket(obj, passenger_id, form, 1)
        if journey_type == 'R':
            in_ticket = generate_ticket(obj, passenger_id, form, 2)
        form = TicketForm()
        context['ticket'] = out_ticket  #why did i do this?
        if Ticket.objects.latest('id').journey_type == 'R':
            return HttpResponseRedirect('/return', request)
        else:
            return HttpResponseRedirect('/single', request)

    context.update({'form': form})
    print(context)
    return render(request, 'select_route.html', context)
Example #2
0
def create(request):
    if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_OWNERS:
        assignable_users = User.objects.filter(is_active=True, is_staff=True).order_by(User.USERNAME_FIELD)
    else:
        assignable_users = User.objects.filter(is_active=True).order_by(User.USERNAME_FIELD)

    if request.method == 'POST':
        form = TicketForm(request.POST, request.FILES)
        form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.all()]
        form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.get_username()] for u in assignable_users]
        if form.is_valid():
            ticket = form.save(user=request.user)
            return HttpResponseRedirect(ticket.get_absolute_url())
    else:
        initial_data = {}
        if request.user.usersettings.settings.get('use_email_as_submitter', False) and request.user.email:
            initial_data['submitter_email'] = request.user.email
        if request.GET.has_key('queue'):
            initial_data['queue'] = request.GET['queue']

        form = TicketForm(initial=initial_data)
        form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.all()]
        form.fields['assigned_to'].choices = [('', '--------')] + [[u.id, u.get_username()] for u in assignable_users]
        if helpdesk_settings.HELPDESK_CREATE_TICKET_HIDE_ASSIGNED_TO:
            form.fields['assigned_to'].widget = forms.HiddenInput()

    return render_to_response('tickets/create_ticket.html',
        RequestContext(request, {
            'form': form,
        }))
Example #3
0
def ticket_create(request):
    if request.method == 'POST':
        form = TicketForm(request.POST)
        if form.is_valid():
            ticket = Ticket(
                author=request.user,
                user=form.cleaned_data.get('user'),
                department=form.cleaned_data.get('department'),
                title=form.cleaned_data.get('title'),
                description=form.cleaned_data.get('description'),
                priority=form.cleaned_data.get('priority'),
                due_date=form.cleaned_data.get('due_date')
            )
            ticket.save()

            attachment_list = request.FILES.getlist('attachments')
            for attachment in attachment_list:
                ta = TicketAttachment(
                    user=request.user,
                    ticket=ticket,
                    attachment=attachment,
                )
                ta.save()

            messages.success(request, 'Successfully created ticket.')
            return redirect('dashboard')
    else:
        initial = {'priority': Ticket.SOON_PRIORITY, 'user': request.user}
        if request.user.department:
            initial.update({'department': request.user.department})
        form = TicketForm(initial=initial)

    dict_context = {'form': form}

    return render(request, 'tickets/create.html', dict_context)
Example #4
0
def tickets_list(request):
    if request.user.is_authenticated:
        if request.method == 'POST':
            form = TicketForm(request.POST)
            if form.is_valid():
                ticket = form.save(commit=False)
                ticket.owner = request.user
                ticket.save()
                logger.debug(f'{ticket} created.')
                request.session['ticket-uuid'] = str(ticket.uuid)
                return redirect('ticket_submitted')

        else:
            try:
                if request.user.is_superuser:
                    tickets = Ticket.objects.all()
                else:
                    tickets = Ticket.objects.filter(owner=request.user)
            except:    # noqa: E722
                tickets = None

            return render(
                request,
                'tickets/tickets-list.html',
                {'tickets': tickets}
            )

    else:
        return render(request, 'tickets/tickets-list.html', {})
Example #5
0
def create_ticket(request):
    """Allows Ticket Creation"""

    # Form is handled based on it's ticket type
    if request.method == 'POST':
        form = TicketForm(request.POST)

        if form.is_valid():
            # ticket = form.save(commit=False)
            if form.cleaned_data['type'] == 'bug':
                ticket = Bug()
            elif form.cleaned_data['type'] == 'feature':
                ticket = Feature()

            ticket.status = 'todo'
            ticket.title = form.cleaned_data['title']
            ticket.description = form.cleaned_data['description']
            ticket.creator = auth.get_user(request)
            ticket.save()
            messages.success(request, "Ticket successfully created!")

            return redirect('show_' + form.cleaned_data['type'], id=ticket.id)

    else:
        form = TicketForm()

    return render(request, 'ticket_create.html', {'form': form})
Example #6
0
    def post(self, request):
        ticketForm = TicketForm(request.POST, request=request)
        commentForm = CommentForm(request.POST)

        if ticketForm.is_valid() and commentForm.is_valid():
            ticket = ticketForm.save(request)
            comment = commentForm.save(request, ticket)
            return redirect('ticket details', ticket_id=ticket.id)
        context = self.get_context_data()
        context['ticketForm'] = ticketForm
        context['commentForm'] = commentForm
        return render(request, 'tickets/add-ticket.html', context)
Example #7
0
def create_ticket(request, user_id):
    html = "create_ticket.html"
    if request.method == "POST":
        form = TicketForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            user = CustomUser.objects.get(id=user_id)
            ticket = Ticket.objects.create(title=data['title'],
                                           description=data['description'],
                                           filed_user=user)
            return HttpResponseRedirect(reverse('home'))
    form = TicketForm()
    return render(request, html, {"form": form})
Example #8
0
def edit(request, pk):
    ticket = get_object_or_404(Ticket, pk=pk)
    form = TicketForm(instance=ticket)
    if request.POST:
        data = request.POST.copy()
        form = TicketForm(data, instance=ticket)
        if form.is_valid():
            t = form.save()
            return redirect("/tickets/%s" % t.pk)
    return render_to_response('tickets/form.html',
            {'ticket': ticket,
             'form': form},
            context_instance=RequestContext(request))
Example #9
0
def add(request):

	if request.method == 'POST':
		form = TicketForm(request.POST)
		if form.is_valid():
			ticket = form.save(commit=False)
			if request.user.is_authenticated():
				ticket.usuario = request.user.get_profile()
				
			ticket.save()
			messages.add_message(request, messages.INFO, 'Su pregunta ha sido enviada correctamente.')
	else:
		form = TicketForm()
			
	return render_to_response('tickets/new.html', locals() , context_instance=RequestContext(request))
Example #10
0
    def test_ticket_form_is_valid(self):
        testTicket = self.get_test_ticket()
        data = {
            'ticketType': testTicket.ticketType,
            'subject': testTicket.subject,
            'project': testTicket.project,
            'description': testTicket.description,
            # 'priority': testTicket.priority,
            # 'status': testTicket.status,
            'creator': testTicket.creator,
            # 'owner': testTicket.owner
        }
        form = TicketForm(data)

        self.assertTrue(form.is_valid())
Example #11
0
def checkout(request):
    form = TicketForm(request.POST)
    new_feature = Feature(name="One Feature")

    if request.method == "POST":
        token = request.POST.get("stripeToken")

    try:
        charge = stripe.Charge.create(
            amount=3000,
            currency="eur",
            source=token,
            description="One Feature Added - {0}".format(
                request.user.username))

        new_feature.charge_id = charge.id

    except stripe.error.CardError as ce:
        return False, ce

    else:
        new_feature.save()
        return redirect('create_feature')

    return redirect('create_feature')
Example #12
0
 def test_from_pending_order_for_self(self):
     order = factories.create_pending_order_for_self()
     expected = {
         'who': 'self',
         'rate': 'individual',
     }
     self.assertEqual(TicketForm.from_pending_order(order).data, expected)
Example #13
0
def edit_ticket(request, ticket_id):
    ticket = Ticket.objects.get(id=ticket_id)
    if request.method == "POST":
        form = TicketForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            ticket.title = data['title']
            ticket.description = data['description']
            ticket.save()
        return HttpResponseRedirect(
            reverse('ticket_detail', args=(ticket_id, )))
    form = TicketForm(initial={
        'title': ticket.title,
        'description': ticket.description
    })
    return render(request, 'create_ticket.html', {'form': form})
Example #14
0
    def get(self, request, slug):
        try:
            board = Board.objects.get(slug=slug)
        except Board.DoesNotExist:
            text = 'Oops! The board you are looking for ' \
                'no longer exists..'
            messages.error(request, text)

            return HttpResponseRedirect(reverse('boards'))

        initial = {'board': board.id}
        form = TicketForm(initial=initial)
        ticket_update_once_form = TicketUpdateOnceForm()
        cycle = request.GET.get('cycle')
        tickets = self.get_tickets(slug, cycle)
        RequestConfig(request).configure(tickets)

        context = self.get_context_to_render(
            board_name=board.name,
            board_slug=board.slug,
            form=form,
            ticket_update_once_form=ticket_update_once_form,
            tickets=tickets,
            cycle=cycle)

        return render(request, self.template_name, context)
Example #15
0
def new_ticket(request):
    form = TicketForm(
        initial={
            'name': f'{request.user.first_name} {request.user.last_name}'
        }
    )
    return render(request, 'tickets/new-ticket.html', {'form': form})
Example #16
0
    def test_missing_ticket_type(self):
        """Ticket type is a required field - the form should not be valid
        if ticket type is omitted.
        """

        initial = {
            "title": "Ticket Title",
            "assigned_to": 1,
            "status": "new",
            #'ticket_type':'bug',
            "description": "this is a test",
            "priority": 3,
        }

        form = TicketForm(data=initial, instance=self.ticket)
        self.assertFalse(form.is_valid())
Example #17
0
def ticket_search(request):
    tickets = Ticket.objects.filter(ticketName__icontains=request.GET['query'])
    form = TicketForm(instance=None)
    return render(request, "search_results.html", {
        "tickets": tickets,
        'form': form
    })
Example #18
0
def dev_ticket(request, id):
    """
    this view will return a dev ticket and allow us to edit changes to a dev ticket
    """
    ticket = get_object_or_404(Ticket, pk=id)

    if request.method == "POST":
        form = TicketForm(request.POST, request.FILES, instance=ticket)
        save_form(request, form, ticket, "edit")
        return redirect("dev_area")
    else:
        form = TicketForm(instance=ticket)

    return render(request, "development-ticket.html", {
        'form': form,
        'ticket': ticket
    })
Example #19
0
    def test_missing_description(self):
        """Description is a required field - the form should not be valid
        if description is omitted.
        """

        initial = {
            "title": "Ticket Title",
            "assigned_to": 1,
            "status": "new",
            "application": 1,
            "ticket_type": "bug",
            #'description': 'this is a test',
            "priority": 3,
        }

        form = TicketForm(data=initial, instance=self.ticket)
        self.assertFalse(form.is_valid())
Example #20
0
def create_ticket_view(request):
    html = 'genericForm.html'

    if request.method == 'POST':
        form = TicketForm(request.POST)

        if form.is_valid():
            data = form.cleaned_data
            Ticket.objects.create(
                title=data['title'],
                description=data['description'],
                filed_by=request.user
            )
            return redirect(request.GET.get("next", "/"))
    
    form = TicketForm()

    return render(request, html, {'form': form})
Example #21
0
    def test_missing_status(self):
        """Status is no longer a required field as it is inferred from actions
        applied to each ticket rather than entered as a field on a form.

        """

        initial = {
            "title": "Ticket Title",
            "assigned_to": 1,
            #'status': 'new',
            "application": 1,
            "ticket_type": "bug",
            "description": "this is a test",
            "priority": 3,
        }

        form = TicketForm(data=initial, instance=self.ticket)
        self.assertTrue(form.is_valid())
Example #22
0
def create_ticket(request):
    if request.method == 'POST':
        data = json.loads(request.body.decode('utf-8'))
        form = TicketForm(data)
        error = form.get_error()
        if error != '':
            error = {'id': 2, 'message': error}
            return HttpResponseBadRequest(json.dumps(error))

        edition = Edition.objects.get(year=EDITION_YEAR)
        attendant = Attendant()
        attendant.edition = edition
        attendant.name = data['name'].strip()
        attendant.lastname = data['lastname'].strip()
        attendant.email = data['email'].strip()
        attendant.student = data['student']
        attendant.identity = data['identity'].strip().upper()

        if attendant.student:
            attendant.upm_student = data['upm_student']
            if attendant.upm_student:
                attendant.college = data['college'].strip()
                attendant.degree = data['degree'].strip()
                attendant.grade = data['grade']
                attendant.phone = data['phone'].strip()

        # create attendant
        try:
            attendant.save()
        except:
            error = {'id': 1, 'message': 'Email ya registrado'}
            return HttpResponseBadRequest(json.dumps(error))

        ticket = Ticket()
        ticket_type = TicketType.objects.get(edition__year=EDITION_YEAR, name='General')
        ticket.type = ticket_type
        ticket.attendant = attendant

        # create ticket
        ticket.save()
        generate_pdf(ticket)
        return HttpResponse('ok')
    else:
        return HttpResponseNotAllowed(permitted_methods=['POST'])
Example #23
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     context['ticketForm'] = TicketForm()
     context['commentForm'] = CommentForm()
     context['is_support'] = is_member(self.request.user, 'supports')
     if (context['is_support']):
         context['clients'] = []
         context['clients'] = get_user_model().objects.filter(groups__name='clients')
     context['user_name'] = str(self.request.user)
     return context
def create_ticket(request):
    if request.method == 'POST':
        ticket_form = TicketForm(request.POST, request.FILES or None)

        if ticket_form.is_valid():
            title = ticket_form.cleaned_data['title']
            owner = request.user
            content = ticket_form.cleaned_data['content']
            priority = ticket_form.cleaned_data['priority']

            Ticket.objects.create(title=title,
                                  owner=owner,
                                  content=content,
                                  priority=priority)
            return HttpResponseRedirect(reverse('tickets:list_of_tickets'))

    else:
        ticket_form = TicketForm()

    return render(request, 'create_ticket.html', {'form': ticket_form})
Example #25
0
    def test_good_data(self):
        """verify that the same data comes out as went in"""

        initial = {
            "title": "Ticket Title",
            "status": "new",
            "application": 1,
            "ticket_type": "bug",
            "description": "this is a test",
            "priority": 3,
        }

        form = TicketForm(data=initial, instance=self.ticket)
        form.is_valid()

        self.assertTrue(form.is_valid())
        # check the data
        self.assertEqual(form.cleaned_data["ticket_type"], "bug")
        self.assertEqual(form.cleaned_data["description"], "this is a test")
        self.assertEqual(form.cleaned_data["priority"], 3)
Example #26
0
def new_ticket(request, slug):
    repo = get_object_or_404(CodeRepository, slug=slug)
    TicketDetailForm = get_ticket_form(repo)
    if request.method == "POST":
        form = TicketForm(request.POST)
        detail_form = TicketDetailForm(request.POST)
        if form.is_valid() and detail_form.is_valid():
            ticket = form.save(commit=False)
            ticket.repo = repo
            ticket.creator = request.user
            ticket.created_at = datetime.now()
            ticket.save()
            detail_form.save(ticket)
            return redirect(ticket)
    else:
        form = TicketForm()
        detail_form = TicketDetailForm()
    return render_to_response([
        'tickets/%s/new_ticket.html' % repo.name,
        'tickets/new_ticket.html',
    ], {'repo': repo, 'form': form, 'detail_form': detail_form}, context_instance=RequestContext(request))
Example #27
0
def new_ticket(request, projectslug):
    project = get_object_or_404(Project, slug=projectslug)
    TicketDetailForm = get_ticket_form(project)
    if request.method == "POST":
        form = TicketForm(request.POST)
        detail_form = TicketDetailForm(request.POST)
        if form.is_valid() and detail_form.is_valid():
            ticket = form.save(commit=False)
            ticket.project = project
            ticket.creator = request.user
            ticket.created_at = datetime.now()
            ticket.save()
            detail_form.save(ticket)
            return redirect(ticket)
    else:
        form = TicketForm()
        detail_form = TicketDetailForm()
    return render_to_response([
        'tickets/%s/new_ticket.html' % project.name,
        'tickets/new_ticket.html',
    ], {'project': project, 'form': form, 'detail_form': detail_form}, context_instance=RequestContext(request))
Example #28
0
def new_ticket(request, slug):
    repo = get_object_or_404(CodeRepository, slug=slug)
    TicketDetailForm = get_ticket_form(repo)
    if request.method == "POST":
        form = TicketForm(request.POST)
        detail_form = TicketDetailForm(request.POST)
        if form.is_valid() and detail_form.is_valid():
            ticket = form.save(commit=False)
            ticket.repo = repo
            ticket.creator = request.user
            ticket.created_at = datetime.now()
            ticket.save()
            detail_form.save(ticket)
            return redirect(ticket)
    else:
        form = TicketForm()
        detail_form = TicketDetailForm()
    return render_to_response([
        'tickets/%s/new_ticket.html' % repo.name,
        'tickets/new_ticket.html',
    ], {
        'repo': repo,
        'form': form,
        'detail_form': detail_form
    },
                              context_instance=RequestContext(request))
def charge(request, id, up_vote_flag):
    #### Charge the user
    if request.method == 'POST':
        stripe.api_key = settings.STRIPE_SECRET_KEY
        charge = stripe.Charge.create(amount=50,
                                      currency='eur',
                                      description='IssueTrackerCharge',
                                      source=request.POST['stripeToken'])

    #### UP Vote ticket is required.  Other wise we just save the form.
    if up_vote_flag:
        ticket = get_object_or_404(Ticket, pk=id)
        up_vote_ticket(request, ticket)
        messages.success(request, "You're ticket has been saved!")
        return redirect('/')
    else:
        form = TicketForm(request.POST, request.FILES)
        if form.is_valid():
            ticket = get_object_or_404(Ticket, pk=id)
            save_form(request, form, ticket, 'charge')
            messages.success(request, "You're ticket has been saved!")

    return redirect('/')
Example #30
0
def tickets_new_feature(request):
    """ Create a NEW Ticket (Feature) """
    if request.method == "POST":
        ticket_form = TicketForm(request.POST)
        donation_form = DonationForm(request.POST)
        if ticket_form.is_valid() and donation_form.is_valid():
            # amount to pay / donate
            donation_amount = 0
            donation_amount += int(request.POST.get("donation_amount"))
            try:
                # build Stripe payment
                token = request.POST["stripeToken"]
                customer = stripe.Charge.create(
                    amount=int(donation_amount * 100),
                    currency="EUR",
                    description=(request.user.email + " (" +
                                 request.user.get_full_name() + ")"),
                    source=token,
                )
            except stripe.error.CardError:
                # Stripe payment error
                messages.error(request, f"Your card was declined!")
            # authorization is valid - payment successful
            if customer.paid:
                ticket_form.instance.author = request.user
                ticket_form.instance.ticket_type_id = 2
                ticket_form.instance.total_donations = donation_amount
                # update user Profile with additional donation amount
                get_user_donations = Profile.objects.values_list(
                    "total_donated", flat=True).get(user_id=request.user.id)
                new_user_donations = get_user_donations + donation_amount
                Profile.objects.filter(user_id=request.user.id).update(
                    total_donated=new_user_donations)
                # update ticket status to In Progress if €100 goal is achieved
                if donation_amount >= int(100):
                    ticket_form.instance.ticket_status_id = 2
                else:
                    ticket_form.instance.ticket_status_id = 1
                new_ticket = ticket_form.save()
                new_ticket_id = new_ticket.pk
                messages.success(
                    request, f"Thank you for your Feature Request!\
                        €{donation_amount} was charged to your card.")
                return redirect(tickets_view_one, new_ticket_id)
            else:
                messages.error(request, f"Unable to take payment!")
        else:
            messages.error(request, f"There was an error. Please try again.")
    else:
        ticket_form = TicketForm()
        donation_form = DonationForm()
    context = {
        "donation_form": donation_form,
        "ticket_form": ticket_form,
        "publishable": settings.STRIPE_PUBLISHABLE
    }
    return render(request, "tickets_new_feature.html", context)
Example #31
0
    def post(self, request, slug):
        try:
            board = Board.objects.get(slug=slug)
        except Board.DoesNotExist:
            text = 'Oops! The board you are looking for ' \
                'no longer exists..'
            messages.error(request, text)

            return HttpResponseRedirect(reverse('boards'))

        form = TicketForm(request.POST)
        form.save()

        ticket_update_once_form = TicketUpdateOnceForm()

        tickets = TicketTable(
            Ticket.objects.filter(board__slug=slug,
                                  is_active=True).order_by('id'))
        zendesk_ticket_url = settings.ZENDESK_URL + '/agent/tickets/'
        firebase_messaging_sender_id = settings.FIREBASE_MESSAGING_SENDER_ID

        return render(
            request, self.template_name, {
                'board_name': board.name,
                'board_slug': board.slug,
                'form': form,
                'ticket_update_once_form': ticket_update_once_form,
                'tickets': tickets,
                'zendesk_ticket_url': zendesk_ticket_url,
                'firebase_api_key': settings.FIREBASE_API_KEY,
                'firebase_auth_domain': settings.FIREBASE_AUTH_DOMAIN,
                'firebase_database_url': settings.FIREBASE_DATABASE_URL,
                'firebase_project_id': settings.FIREBASE_PROJECT_ID,
                'firebase_storage_bucket': settings.FIREBASE_STORAGE_BUCKET,
                'firebase_messaging_sender_id': firebase_messaging_sender_id
            })
Example #32
0
def create_ticket(request, ticket_type):
    """ Create a view to show all feature tickets """
    if request.method == "POST":
        form = TicketForm(request.POST)
        if form.is_valid():
            form.save()
            messages.success(request, "Ticket added")
            if ticket_type == "FEATURE":
                return redirect(all_features)
            else:
                return redirect(all_bugs)
    else:
        form = TicketForm()
        form.fields["ticket_type"].initial = ticket_type
        return render(request, 'ticketform.html', {'form': form})
Example #33
0
def staging_area(request):
    """
    A view that will return all tickets that needs to be verified before dev work starts
    """
    tickets = Ticket.objects.all().order_by('up_vote', 'created').reverse()
    ticketForm = TicketForm()
    count_bug = Ticket.objects.filter(ticket_type__contains='Bug',
                                      accept__contains="0").count()
    count_feature = Ticket.objects.filter(ticket_type__contains='Feature',
                                          accept__contains="0").count()

    return render(
        request, "staging.html", {
            'tickets': tickets,
            'ticketForm': TicketForm,
            'count_bug': count_bug,
            'count_feature': count_feature
        })
Example #34
0
def tickets_edit(request, pk):
    """ Edit a Single Ticket """
    ticket = get_object_or_404(Ticket, pk=pk)
    if request.method == "POST":
        ticket_form = TicketForm(request.POST, instance=ticket)
        if ticket_form.is_valid():
            ticket_form.instance.date_edited = timezone.now()
            ticket_form.save()
            messages.success(request, f"Ticket successfully updated!")
            return redirect(tickets_view_one, ticket.pk)
    else:
        ticket_form = TicketForm(instance=ticket)
    context = {
        "ticket": ticket,
        "ticket_form": ticket_form,
    }
    return render(request, "tickets_edit.html", context)
def checkout(request):
    if request.method == "POST":
        order_form = OrderForm(request.POST)
        payment_form = MakePaymentForm(request.POST)
        form = TicketForm(request.POST)

        if order_form.is_valid() and payment_form.is_valid():
            order = order_form.save(commit=False)
            order.date = timezone.now()
            order.save()

            total = 30

            try:
                customer = stripe.Charge.create(
                    amount=int(total * 100),
                    currency="usd",
                    description=request.user.email,
                    card=payment_form.cleaned_data['stripe_id'])
            except stripe.error.CardError:
                messages.error(request, "Your card was declined!")

            if customer.paid:
                messages.error(request, "You have successfully paid")
                return redirect(reverse('tickets'))
            else:
                messages.error(request, "Unable to take payment")
        else:
            print(payment_form.errors)
            messages.error(request,
                           "We were unable to take a payment with that card!")
    else:
        payment_form = MakePaymentForm()
        order_form = OrderForm()

    return render(
        request, "checkout.html", {
            "order_form": order_form,
            "payment_form": payment_form,
            "publishable": settings.STRIPE_PUBLISHABLE
        })
Example #36
0
def tickets_new_bug(request):
    """ Create a NEW Ticket (Bug) """
    if request.method == "POST":
        ticket_form = TicketForm(request.POST)
        if ticket_form.is_valid():
            ticket_form.instance.author = request.user
            ticket_form.instance.ticket_type_id = 1
            ticket_form.instance.ticket_status_id = 1
            new_ticket = ticket_form.save()
            new_ticket_id = new_ticket.pk
            messages.success(request, f"Thank you for your Bug Report!")
            return redirect(tickets_view_one, new_ticket_id)
    else:
        ticket_form = TicketForm()
    context = {
        "ticket_form": ticket_form,
    }
    return render(request, "tickets_new_bug.html", context)