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,))
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)
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)
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)
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,))
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)
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)
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)
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))
def accountants_desk(request): """ This view lets accountants view applications and set their status: has their payment arrived? """ #print("who is it? %s" % request.user.login) _number_of_datasets = Speedfundings.get_number() #print("request.matchdict['number']: %s" % request.matchdict['number']) try: # check if # a page number was supplied with the URL _page_to_show = int(request.matchdict['number']) #print("page to show: %s" % _page_to_show) except: _page_to_show = 0 # is it a number? yes, cast above #if not isinstance(_page_to_show, type(1)): # _page_to_show = 0 #print("_page_to_show: %s" % _page_to_show) # check for input from "find dataset by confirm code" form if 'code_to_show' in request.POST: #print("found code_to_show in POST") try: _code = request.POST['code_to_show'] #print(_code) _entry = Speedfundings.get_by_code(_code) #print(_entry) return HTTPFound( location=request.route_url( 'detail', speed_id=_entry.id) ) except: # choose default #print("barf!") pass # how many to display on one page? """ num_display determines how many items are to be shown on one page """ #print request.POST if 'num_to_show' in request.POST: #print("found it in POST") try: _num = int(request.POST['num_to_show']) if isinstance(_num, type(1)): num_display = _num except: # choose default num_display = 20 elif 'num_display' in request.cookies: #print("found it in cookie") num_display = int(request.cookies['num_display']) else: #print("setting default") num_display = request.registry.settings[ 'speedfunding.dashboard_number'] #print("num_display: %s " % num_display) """ base_offset helps us to minimize impact on the database when querying for results. we can choose just those results we need for the page to show """ #try: base_offset = int(_page_to_show) * int(num_display) #print("base offset: %s" % base_offset) #except: # base_offset = 0 # if 'base_offset' in request.session: # base_offset = request.session['base_offset'] # else: # base_offset = request.registry.settings['speedfunding.offset'] # get data sets from DB _speedfundings = Speedfundings.speed_listing( Speedfundings.id.desc(), how_many=num_display, offset=base_offset) # calculate next-previous-navi next_page = (int(_page_to_show) + 1) if (int(_page_to_show) > 0): previous_page = int(_page_to_show) - 1 else: previous_page = int(_page_to_show) # store info about current page in cookie request.response.set_cookie('on_page', value=str(_page_to_show)) #print("num_display: %s" % num_display) request.response.set_cookie('num_display', value=str(num_display)) return {'_number_of_datasets': _number_of_datasets, 'speedfundings': _speedfundings, 'num_display': num_display, 'next': next_page, 'previous': previous_page, }