Esempio n. 1
0
def search_event():
    name = request.form.get('name')
    events_list = EventsFinder.search_by_name(name)

    if len(events_list) == 0:
        error = 'No results found'
        return render_template('admin/events/events_dashboard.html',
                               events=None,
                               error=error,
                               search=name,
                               role=current_user.role.name)

    return render_template('admin/events/events_dashboard.html',
                           events=events_list,
                           error=None,
                           search=name,
                           role=current_user.role.name)
Esempio n. 2
0
def events_dashboard():
    search_parameters = request.args
    name = request.args.get('name')

    # handle search bar requests
    if name is not None:
        search = name
        events_list = EventsFinder.search_by_name(name)

    # handle parameter requests
    elif len(search_parameters) != 0:
        search_parameters = request.args
        search = 'search name'

        events_list = EventsFinder.get_from_parameters(search_parameters)

    # request endpoint with no parameters should return all events
    else:
        search = None
        events_list = EventsFinder.get_all()

    if events_list is None or len(events_list) == 0:
        error = 'No results found'
        return render_template('admin/events/events_dashboard.html',
                               events=None,
                               error=error,
                               search=search,
                               role=current_user.role.name)

    now = datetime.utcnow()
    for event in events_list:
        if event.cvs_access_end:
            try:
                cvs_access_end = datetime.strptime(event.cvs_access_end,
                                                   '%d %b %Y, %a')
            except:
                break
            event.cvs_purgeable = (now > cvs_access_end)
        else:
            event.cvs_purgeable = False

    return render_template('admin/events/events_dashboard.html',
                           events=events_list,
                           error=None,
                           search=search,
                           role=current_user.role.name)