Exemple #1
0
 def index(self):
     db = cherrypy.request.db
     active_events = Event.active_events(db)
     future_events = Event.future_events(db)
     past_events = Event.past_events(db)
         
     return {'active_events': active_events, 'future_events': future_events, 'past_events': past_events,}
Exemple #2
0
 def delete(self, **kwargs):
     db = cherrypy.request.db
     event = Event.get_by_id(db, kwargs['uid'])
     if event is not None:
         db.delete(event)
         
     raise cherrypy.HTTPRedirect("/admin/events/")
Exemple #3
0
 def manage(self, event_id = None,**kwargs):
     if event_id is None:
         raise cherrypy.HTTPRedirect("/admin/events/")
         
     db = cherrypy.request.db
     event = Event.get_by_id(db,event_id)
     
     plugins = tourney.PLUGIN_MANAGER.get_plugins("Game system")
     
     return {'selected_event': event, 'game_systems': plugins}
Exemple #4
0
 def create(self, **kwargs):
     
     new_event = Event()
     new_event.name = kwargs['event_name']
     new_event.start_date = datetime.datetime.strptime(kwargs['start_date'],"%d/%m/%Y").date()
     
     if kwargs['uid'] != "":
         new_event.id = kwargs['uid']
         
     if kwargs['end_date'] != "":
         new_event.end_date = datetime.datetime.strptime(kwargs['end_date'],"%d/%m/%Y").date()
     else:
         new_event.end_date = new_event.start_date
     
     db = cherrypy.request.db
     db.add(new_event)
     
     raise cherrypy.HTTPRedirect("/admin/events/")
Exemple #5
0
def log_event(config: Config, token: Token, etype, ctx: dict):
    log = Logger()
    if type(token) is str:
        token = token.encode('utf-8')
        log.debug('token: ' + token.decode('utf-8'))
    t = Token.query.filter_by(token=token.decode("utf-8")).first()
    if t is None:
        log = Logger()
        log.error('Unable to find %s token' % token.decode("utf-8"))
        return

    e = Event(type=etype,
              token_id=t.id,
              token=t,
              timestamp=datetime.utcnow(),
              context=json.dumps(ctx))
    db.add(e)
    db.commit()

    message = f"""
DNS Checkin
Date: {e.timestamp} UTC
Token: {t.token}
Tags: {t.context}
Context: {json.dumps(ctx)}
"""
    print(config.notifications)
    for n in config.notifications:
        if not n.isEnabled():
            continue
        try:
            res = n.notify(message)
            print(res)
            print(res.request)
        except:
            log.error('error executing notify class %s' % n)