def add_activity_type_dashboard(): event_id = request.args.get('_event', None) event = EventsFinder.get_from_external_id(event_id) if event is None: return APIErrorValue( 'No event found! Please set an event in the menu "Events"').json( 500) return render_template('admin/activities/add_activity_type.html', event=event, error=None)
def create_activity_type(): name = request.form.get('name') description = request.form.get('description') price = request.form.get('price') show_in_home = request.form.get('show_in_home') show_in_schedule = request.form.get('show_in_schedule') show_in_app = request.form.get('show_in_app') if show_in_home == 'True': show_in_home = True else: show_in_home = False if show_in_schedule == 'True': show_in_schedule = True else: show_in_schedule = False if show_in_app == 'True': show_in_app = True else: show_in_app = False event_id = request.form.get('event_id') event = EventsFinder.get_from_external_id(event_id) if event is None: return APIErrorValue( 'No event found! Please set an event in the menu "Events"').json( 500) activity_type = ActivityTypesHandler.create_activity_type( event=event, name=name, description=description, price=price, show_in_home=show_in_home, show_in_schedule=show_in_schedule, show_in_app=show_in_app) if activity_type is None: return render_template( 'admin/activities/add_activity_type.html', event=event, error="Failed to create activity type! Maybe it already exists :)") return redirect(url_for('admin_api.activity_types_dashboard'))
def get_event(event_external_id): event = EventsFinder.get_from_external_id(event_external_id) if event is None: return render_template(url_for('admin_api.add_event_dashboard')) logo = EventsHandler.find_image(image_name=str(event.external_id)) mobile_image_name = f'{event.external_id}_mobile' logo_mobile = EventsHandler.find_image(image_name=mobile_image_name) schedule_name = f'{event.external_id}_schedule' schedule = EventsHandler.find_image(image_name=schedule_name) blueprint_name = f'{event.external_id}_blueprint' blueprint = EventsHandler.find_image(image_name=blueprint_name) return render_template('admin/events/update_event.html', event=event, logo=logo, logo_mobile=logo_mobile, schedule=schedule, blueprint=blueprint, error=None)
def activity_types_dashboard(): events = EventsFinder.get_all() event_id = request.args.get('event', None) if (event_id is None): event = EventsFinder.get_default_event() else: event = EventsFinder.get_from_external_id(event_id) if event is None: error = 'No default event found! Please set a default event in the menu "Events"' return render_template('admin/activities/activities_dashboard.html', event=None, events=events, error=error, role=current_user.role.name) return render_template('admin/activities/activity_types_dashboard.html', event=event, events=events, error=None, role=current_user.role.name)
def add_activity_dashboard(): companies = CompaniesFinder.get_all() speakers = SpeakersFinder.get_all() tags = TagsFinder.get_all() rewards = RewardsFinder.get_all_rewards() event_id = request.args.get('event', None) if (event_id is None): event = EventsFinder.get_default_event() else: event = EventsFinder.get_from_external_id(event_id) if event is None: error = 'No default event found! Please set a default event in the menu "Events"' return render_template('admin/activities/activities_dashboard.html', event=None, error=error, role=current_user.role.name) try: minDate = datetime.strptime(event.start_date, '%d %b %Y, %a').strftime("%Y,%m,%d") maxDate = datetime.strptime(event.end_date, '%d %b %Y, %a').strftime("%Y,%m,%d") except: minDate = None maxDate = None return render_template('admin/activities/add_activity.html', \ companies=companies, \ speakers=speakers, \ tags=tags, \ minDate=minDate, \ maxDate=maxDate, \ event=event, \ rewards=rewards, \ error=None)
def purge_cvs(event_external_id): event = EventsFinder.get_from_external_id(event_external_id) if event is None: return APIErrorValue('Couldnt find event').json(500)
def update_event(event_external_id): event = EventsFinder.get_from_external_id(event_external_id) if event is None: return APIErrorValue('Couldnt find event').json(500) name = request.form.get('name') start_date = request.form.get('start_date') end_date = request.form.get('end_date') cvs_submission_start = request.form.get('cvs_submission_start') cvs_submission_end = request.form.get('cvs_submission_end') cvs_access_start = request.form.get('cvs_access_start') cvs_access_end = request.form.get('cvs_access_end') default = request.form.get('default') email = request.form.get('email') location = request.form.get('location') facebook_event_link = request.form.get('facebook_event_link') facebook_link = request.form.get('facebook_link') youtube_link = request.form.get('youtube_link') instagram_link = request.form.get('instagram_link') show_schedule = request.form.get('show_schedule') show_registrations = request.form.get('show_registrations') if default == 'True': default = True else: default = False if show_schedule == 'True': show_schedule = True else: show_schedule = False if show_registrations == 'True': show_registrations = True else: show_registrations = False updated_event = EventsHandler.update_event( event=event, name=name, start_date=start_date, end_date=end_date, default=default, email=email, location=location, facebook_link=facebook_link, facebook_event_link=facebook_event_link, youtube_link=youtube_link, instagram_link=instagram_link, show_schedule=show_schedule, show_registrations=show_registrations, cvs_submission_start=cvs_submission_start, cvs_submission_end=cvs_submission_end, cvs_access_start=cvs_access_start, cvs_access_end=cvs_access_end) logo = EventsHandler.find_image(image_name=str(event.external_id)) mobile_image_name = f'{event.external_id}_mobile' logo_mobile = EventsHandler.find_image(image_name=mobile_image_name) schedule_name = f'{event.external_id}_schedule' schedule = EventsHandler.find_image(image_name=schedule_name) blueprint_name = f'{event.external_id}_blueprint' blueprint = EventsHandler.find_image(image_name=blueprint_name) if updated_event is None: return render_template('admin/events/update_event.html', event=event, logo=logo, logo_mobile=logo_mobile, schedule=schedule, blueprint=blueprint, error=msg) # there can only be one default if default: default_events = EventsFinder.get_from_parameters({"default": True}) for default_event in default_events: if default_event is not updated_event: EventsHandler.update_event(event=default_event, default=False) current_app.logger.error(request.files) if request.files: image_file = request.files.get('event_image', None) mobile_image_file = request.files.get('event_mobile_image', None) blueprint_file = request.files.get('event_blueprint', None) schedule_file = request.files.get('event_schedule', None) if image_file: result, msg = EventsHandler.upload_image( image_file, str(updated_event.external_id)) if result == False: return render_template('admin/events/update_event.html', event=event, logo=logo, logo_mobile=logo_mobile, schedule=schedule, blueprint=blueprint, error=msg) if mobile_image_file: image_name = f'{updated_event.external_id}_mobile' result, msg = EventsHandler.upload_image(mobile_image_file, image_name) if result == False: return render_template('admin/events/update_event.html', event=event, logo=logo, logo_mobile=logo_mobile, schedule=schedule, blueprint=blueprint, error=msg) if blueprint_file: image_name = f'{updated_event.external_id}_blueprint' result, msg = EventsHandler.upload_image(blueprint_file, image_name) if result == False: return render_template('admin/events/update_event.html', event=event, logo=logo, logo_mobile=logo_mobile, schedule=schedule, blueprint=blueprint, error=msg) if schedule_file: image_name = f'{updated_event.external_id}_schedule' result, msg = EventsHandler.upload_image(schedule_file, image_name) if result == False: return render_template('admin/events/update_event.html', event=event, logo=logo, logo_mobile=logo_mobile, schedule=schedule, blueprint=blueprint, error=msg) return redirect(url_for('admin_api.events_dashboard'))
def activities_dashboard(): search_parameters = request.args name = request.args.get('name') # get event event_id = request.args.get('event', None) if (event_id is None): event = EventsFinder.get_default_event() else: event = EventsFinder.get_from_external_id(event_id) events = EventsFinder.get_all() if event is None: error = 'No default event found! Please set a default event in the menu "Events"' return render_template('admin/activities/activities_dashboard.html', event=None, events=events, activities=None, error=error, search=None, role=current_user.role.name) # handle search bar requests if name is not None: search = name activities_list = ActivitiesFinder.search_by_name_and_event( name, event) # handle parameter requests elif len(search_parameters) != 0: search_parameters = request.args search = 'search name' if 'type' in search_parameters: type_external_id = search_parameters['type'] activity_type = ActivityTypesFinder.get_from_external_id( uuid.UUID(type_external_id)) activities_list = ActivitiesFinder.get_all_from_type_and_event( activity_type) else: activities_list = event.activities # request endpoint with no parameters should return all activities else: search = None activities_list = event.activities if not activities_list: error = 'No results found' return render_template('admin/activities/activities_dashboard.html', event=event, events=events, activities=None, error=error, search=search, role=current_user.role.name) return render_template('admin/activities/activities_dashboard.html', event=event, events=events, activities=activities_list, error=None, search=search, role=current_user.role.name)