Ejemplo n.º 1
0
            if event.state.state == STATE_CANCELED: continue

            # send event to client
            eventobject = {
                'id'    : event.id,
                'title' : event.race.race,
                'state' : event.state.state,
                'start' : event.date + 'T' + time24(event.mainStartTime),
            }
            eventobjects.append( eventobject )

        # and back to caller
        return jsonify( eventobjects )

#----------------------------------------------------------------------
add_url_rules(bp, EventsCalendarApi)
#----------------------------------------------------------------------

#######################################################################
class EventsExceptionsApi(MethodView):
#######################################################################
    url_rules = {
                'eventexceptionsapi': ['/eventexceptionsapi',('GET',)],
                }

    #----------------------------------------------------------------------
    def get(self):
    #----------------------------------------------------------------------
        # get start and end dates from arguments
        start = request.args.get( 'start' ) # yyyy-mm-dd
        end   = request.args.get( 'end' )   # yyyy-mm-dd
Ejemplo n.º 2
0
                }

    #----------------------------------------------------------------------
    def get(self):
    #----------------------------------------------------------------------
        try:
            # commit database updates and close transaction
            db.session.commit()
            return render_template('sysinfo.jinja2',pagename='About',version=thisversion)
        
        except:
            # roll back database updates and close transaction
            db.session.rollback()
            raise
#----------------------------------------------------------------------
add_url_rules(bp, ViewSysinfo)
# sysinfo_view = roles_accepted(ROLE_SUPER_ADMIN, 'event-admin')(ViewSysinfo.as_view('sysinfo'))
# current_app.add_url_rule('/sysinfo',view_func=sysinfo_view,methods=['GET'])
#----------------------------------------------------------------------

#######################################################################
class ViewDebug(MethodView):
#######################################################################
    decorators = [lambda f: roles_accepted(ROLE_SUPER_ADMIN)(f)]
    url_rules = {
                'debug': ['/_debuginfo',('GET',)],
                }
    #----------------------------------------------------------------------
    def get(self):
    #----------------------------------------------------------------------
        try:
Ejemplo n.º 3
0
                'id': event.id,
                'title': event.race.race,
                'state': event.state.state,
                'start': event.date + 'T' + time24(event.mainStartTime),
                'blocked': blocked,
                'className': className,
                'data': event_dte.get_response_data(event),
            }
            eventobjects.append(eventobject)

        # and back to caller
        return jsonify(eventobjects)


#----------------------------------------------------------------------
add_url_rules(bp, EventsCalendarApi)

#----------------------------------------------------------------------


#######################################################################
class EventsExceptionsApi(MethodView):
    #######################################################################
    url_rules = {
        'eventexceptionsapi': ['/eventexceptionsapi', ('GET', )],
    }
    decorators = [roles_accepted('super-admin', 'event-admin')]

    #----------------------------------------------------------------------
    def get(self):
        #----------------------------------------------------------------------
Ejemplo n.º 4
0
#   Copyright 2018 Lou King.  All rights reserved
###########################################################################################
'''
frontend - views for contracts database
=======================================================================
'''

# pypi
from flask import render_template
from flask.views import MethodView

# home grown
from . import bp
from loutilities.flask_helpers.blueprints import add_url_rules


#######################################################################
class Index(MethodView):
    #######################################################################
    url_rules = {
        'index': ['/', ('GET', )],
    }

    def get(self):
        return render_template('index.jinja2')


#----------------------------------------------------------------------
add_url_rules(bp, Index)
#----------------------------------------------------------------------
Ejemplo n.º 5
0
        mergefields['downloadcontracturl'] = pdfurl

        # send agreement accepted email
        template = Template(templatestr)
        html = template.render(mergefields)
        tolist = mergefields['client'].contactEmail
        cclist = current_app.config['CONTRACTS_TREAS_CC']
        fromlist = current_app.config['CONTRACTS_CONTACT']
        print(('mergefields={}'.format(mergefields)))
        # different subject line if contract had been accepted before. This must match eventscontract.EventsContract.editor_method_posthook
        annotation = ''
        if thisevent.isContractUpdated:
            annotation = '(updated) '

        subject = '{}ACCEPTED - FSRC Race Support Agreement: {} - {}'.format(
            annotation, mergefields['event'], mergefields['date'])
        sendmail(subject, fromlist, tolist, html, ccaddr=cclist)

        # update for web view
        mergefields['webview'] = True

        if debug:
            current_app.logger.debug(
                'AcceptAgreement.post(): mergefields={}'.format(mergefields))
        return render_template_string(templatestr, **mergefields)


#----------------------------------------------------------------------
add_url_rules(bp, AcceptAgreement)
#----------------------------------------------------------------------
Ejemplo n.º 6
0
            rdemail = race.email


            # log this request, won't be committed until after sendmail
            log = SponsorQueryLog(**{k:form[k]['text'] for k in form['_keyorder']})
            log.time = dt.dt2asc(datetime.now())
            db.session.add(log)

            # turn form into email
            html = render_template( 'sponsorship-email.jinja2', formdata=form)

            subject = 'Thanks for sponsoring {}!'.format(race.race)

            # TODO: these could be in database
            tolist = '{} <{}>'.format(form['name']['text'], form['email']['text'])
            cclist = [rdemail] + current_app.config['SPONSORSHIPQUERY_CC']
            fromlist = '{} <{}>'.format(race.race, current_app.config['SPONSORSHIPQUERY_CONTACT'])
            sendmail( subject, fromlist, tolist, html, ccaddr=cclist )

            # everything seemed to work ok, so committing
            db.session.commit()

            return 'OK'

        except:
            return "<br/>{}".format(format_exc())

#----------------------------------------------------------------------
add_url_rules(bp, SponsorshipQuery)
#----------------------------------------------------------------------