def switch_pay(request):
    """
    This view lets accountants switch member signature info
    has their signature arrived?
    """
    speed_id = request.matchdict['ticket_id']
    dashboard_page = request.cookies['on_page']
    _entry = PartyTicket.get_by_id(speed_id)

    if _entry.payment_received is True:  # change to NOT SET
        _entry.payment_received = False
        _entry.payment_received_date = datetime(1970, 1, 1)
    elif _entry.payment_received is False:  # set to NOW
        _entry.payment_received = True
        _entry.payment_received_date = datetime.now()

#    log.info(
#        "payment info of speedfunding.id %s changed by %s to %s" % (
#            _entry.id,
#            request.user.login,
#            _entry.payment_received
#        )
#    )
    return HTTPFound(
        request.route_url('dashboard',
                          number=dashboard_page,))
Esempio n. 2
0
 def test_generate_qr_code(self):
     """
     Test QR-Code generation
     """
     from c3spartyticketing.utils import make_qr_code_pdf
     _ticket = PartyTicket.get_by_id(1)
     result = make_qr_code_pdf(
         _ticket,
         "http://192.168.2.128:6544/ci/p1402/ABCDEFGBAR")
     result
def delete_entry(request):
    """
    This view lets accountants delete entries (doublettes)
    """
    _id = request.matchdict['ticket_id']
    dashboard_page = request.cookies['on_page']
    _entry = PartyTicket.get_by_id(_id)

    PartyTicket.delete_by_id(_entry.id)
    log.info(
        "entry.id %s was deleted by %s" % (_entry.id,
                                           request.user.login,)
    )
    return HTTPFound(
        request.route_url('dashboard',
                          number=dashboard_page,))
def ticket_detail(request):
    """
    This view lets accountants view ticket order details
    how about the payment?
    """
    # check if staffer wanted to look at specific ticket id
    tid = request.matchdict['ticket_id']
    #log.info("the id: %s" % tid)

    _ticket = PartyTicket.get_by_id(tid)

    #print(_speedfunding)
    if _ticket is None:  # that speed_id did not produce good results
        return HTTPFound(  # back to base
            request.route_url('dashboard',
                              number=0,))

    class ChangeDetails(colander.MappingSchema):
        """
        colander schema (form) to change details of speedfunding
        """
        payment_received = colander.SchemaNode(
            colander.Bool(),
            title=_(u"Zahlungseingang melden?")
        )

    schema = ChangeDetails()
    form = deform.Form(
        schema,
        buttons=[
            deform.Button('submit', _(u'Submit')),
            deform.Button('reset', _(u'Reset'))
        ],
        #use_ajax=True,
        #renderer=zpt_renderer
    )

    # if the form has been used and SUBMITTED, check contents
    if 'submit' in request.POST:
        controls = request.POST.items()
        try:
            appstruct = form.validate(controls)
        except ValidationFailure, e:  # pragma: no cover
            log.info(e)
            #print("the appstruct from the form: %s \n") % appstruct
            #for thing in appstruct:
            #    print("the thing: %s") % thing
            #    print("type: %s") % type(thing)
            print(e)
            #message.append(
            request.session.flash(
                _(u"Please note: There were errors, "
                  "please check the form below."),
                'message_above_form',
                allow_duplicate=False)
            return{'form': e.render()}

        # change info about speedfunding in database ?
        same = (  # changed value through form (different from db)?
            appstruct['payment_received'] == _ticket.payment_received)
        if not same:
            log.info(
                "info about payment of %s changed by %s to %s" % (
                    _ticket.id,
                    request.user.login,
                    appstruct['payment_received']))
            _ticket.payment_received = appstruct['payment_received']
            if _ticket.payment_received is True:
                _ticket.payment_received_date = datetime.now()
            else:
                _ticket.payment_received_date = datetime(
                    1970, 1, 1)
        # store appstruct in session
        request.session['appstruct'] = appstruct

        # show the updated details
        HTTPFound(route_url('detail', request, ticket_id=_ticket.id))
def send_ticket_mail_view(request):
    """
    this view sends a mail to the user with ticket links
    """
    _id = request.matchdict['ticket_id']
    _ticket = PartyTicket.get_by_id(_id)
    if isinstance(_ticket, NoneType):
        return HTTPFound(
            request.route_url(
                'dashboard',
                number=request.cookies['on_page'],
                order=request.cookies['order'],
                orderby=request.cookies['orderby'],
            )
        )

    mailer = get_mailer(request)
    body_lines = (  # a list of lines
        u'''Hallo ''', _ticket.firstname, ' ', _ticket.lastname, u''' !

Wir haben Deine Überweisung erhalten. Dankeschön!

Es gibt mehrere Möglichkeiten, das Ticket mitzubringen:

1) Lade jetzt dein Ticket herunter und drucke es aus.
   Wir scannen dann am Eingang den QR-Code und du bist drin.

   ''', request.route_url('get_ticket',
                          email=_ticket.email,
                          code=_ticket.email_confirm_code), u'''

2) Lade die mobile version für dein Smartphone (oder Tablet).

   ''', request.route_url('get_ticket_mobile',
                          email=_ticket.email,
                          code=_ticket.email_confirm_code), u'''

3) Bringe einfach diesen Code mit: ''' + _ticket.email_confirm_code + u'''

Damit können wir dich am Eingang wiedererkennen. Falls Du ein Ticket für
*mehrere Personen* bestellt hast, kannst Du diesen Code an diese Personen
weiterreichen. Aber Vorsicht! Wir zählen mit! ;-)

Bis bald!

Dein C3S-Team''',
    )
    the_mail_body = ''.join([line for line in body_lines])
    the_mail = Message(
        subject=_(u"C3S Party-Ticket: bitte herunterladen!"),
        sender="*****@*****.**",
        recipients=[_ticket.email],
        body=the_mail_body
    )
    from smtplib import SMTPRecipientsRefused
    try:
        #mailer.send(the_mail)
        mailer.send_immediately(the_mail, fail_silently=False)
        #print(the_mail.body)
        _ticket.ticketmail_sent = True
        _ticket.ticketmail_sent_date = datetime.now()

    except SMTPRecipientsRefused:  # folks with newly bought tickets (no mail)
        print('SMTPRecipientsRefused')
        return HTTPFound(
            request.route_url('dashboard', number=request.cookies['on_page'],))

    # 'else': send user to the form
    return HTTPFound(request.route_url('dashboard',
                                       number=request.cookies['on_page'],
                                       #order=request.cookies['order'],
                                       #orderby=request.cookies['orderby'],
                                       )
                     )