Beispiel #1
0
    def test_make_shirt_confirmation_email_en(self):
        from speedfunding.utils import make_shirt_confirmation_emailbody
        _item = Speedfundings.get_by_id(1)

        result = make_shirt_confirmation_emailbody(_item)
        self.assertTrue('shirt' in result)
        self.assertTrue('You have chosen a t-shirt' in result)
Beispiel #2
0
    def test_make_donation_confirmation_emailbody_en(self):
        from speedfunding.utils import make_donation_confirmation_emailbody
        _item = Speedfundings.get_by_id(1)

        result = make_donation_confirmation_emailbody(_item)
        self.assertTrue('your pledge' in result)
        self.assertTrue('appreciate your donation' in result)
Beispiel #3
0
def switch_pay(request):
    """
    This view lets accountants switch member signature info
    has their signature arrived?
    """
    speed_id = request.matchdict['speed_id']
    dashboard_page = request.cookies['on_page']
    _entry = Speedfundings.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,))
Beispiel #4
0
 def test_make_mail_body(self):
     """
     test the mail body preparation function used for mail to accountants
     """
     from speedfunding.utils import make_mail_body
     _item = Speedfundings.get_by_id(1)
     result = make_mail_body(_item)
     self.assertTrue(u'we got some funding through the form' in result)
Beispiel #5
0
 def test__accountant_mail(self):
     """
     test the preparation function used for mail to accountants
     """
     from speedfunding.utils import accountant_mail
     _item = Speedfundings.get_by_id(1)
     result = accountant_mail(_item)
     self.assertIsNotNone(_item)
     self.assertIsInstance(result, Message)
     self.assertTrue(u'BEGIN' in result.body)
     print(result)
Beispiel #6
0
def delete_entry(request):
    """
    This view lets accountants delete entries (doublettes)
    """
    _id = request.matchdict['speed_id']
    dashboard_page = request.cookies['on_page']
    _entry = Speedfundings.get_by_id(_id)

    Speedfundings.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,))
Beispiel #7
0
 def test_make_shirt_confirmation_email_de(self):
     from speedfunding.utils import make_shirt_confirmation_emailbody
     _item = Speedfundings.get_by_id(2)
     result = make_shirt_confirmation_emailbody(_item)
     self.assertTrue(u'Du hast ein T-Shirt gewählt' in result)
Beispiel #8
0
 def test_make_donation_confirmation_emailbody_de(self):
     from speedfunding.utils import make_donation_confirmation_emailbody
     _item = Speedfundings.get_by_id(2)
     self.assertIsNotNone(_item)
     result = make_donation_confirmation_emailbody(_item)
     self.assertTrue('Deine Spende' in result)
Beispiel #9
0
def speedfunding_detail(request):
    """
    This view lets accountants view speedfunding details
    has their signature arrived? how about the payment?
    """
    #logged_in = authenticated_userid(request)
    #log.info("detail view.................................................")
    #print("---- authenticated_userid: " + str(logged_in))

    speedfundingid = request.matchdict['speed_id']
    #log.info("the id: %s" % speedfundingid)

    _speedfunding = Speedfundings.get_by_id(speedfundingid)

    #print(_speedfunding)
    if _speedfunding 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"Have we received payment for the funding item??")
        )

    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'] == _speedfunding.payment_received)
        if not same:
            log.info(
                "info about payment of %s changed by %s to %s" % (
                    _speedfunding.id,
                    request.user.login,
                    appstruct['payment_received']))
            _speedfunding.payment_received = appstruct['payment_received']
            if _speedfunding.payment_received is True:
                _speedfunding.payment_received_date = datetime.now()
            else:
                _speedfunding.payment_received_date = datetime(
                    1970, 1, 1)
        # store appstruct in session
        request.session['appstruct'] = appstruct

        # show the updated details
        HTTPFound(route_url('detail', request, speed_id=_speedfunding.id))