示例#1
0
    def __init__(self, events):
        super(EventsValue, self).initialize({})

        if (not isinstance(events, list)):
            events = [events]

        events_array = []
        for event in events:

            event_value = {
                "name":
                event.name,
                "start_date":
                event.start_date,
                "end_date":
                event.end_date,
                "email":
                event.email,
                "location":
                event.location,
                "facebook_link":
                event.facebook_link,
                "facebook_event_link":
                event.facebook_event_link,
                "youtube_link":
                event.youtube_link,
                "instagram_link":
                event.instagram_link,
                "logo":
                EventsHandler.find_image(str(event.external_id)),
                "mobile_logo":
                EventsHandler.find_image(f'{event.external_id}_mobile'),
                "schedule":
                EventsHandler.find_image(f'{event.external_id}_schedule'),
                "blueprint":
                EventsHandler.find_image(f'{event.external_id}_blueprint'),
                "activity_types":
                ActivityTypesValue(
                    ActivityTypesFinder.get_from_parameters({
                        'event_id':
                        event.id,
                        'show_in_schedule':
                        True
                    })).to_dict(),
                "dates":
                EventsHandler.get_event_dates(event),
                "show_schedule":
                event.show_schedule,
                "show_registrations":
                event.show_registrations
            }
            events_array.append(event_value)
        self.serialize_with(data=events_array)

        if (len(events_array) == 1):
            self.serialize_with(data=events_array[0])
        else:
            self.serialize_with(data=events_array)
示例#2
0
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)
示例#3
0
def dashboard():
    event = EventsFinder.get_default_event()
    if (event is None):
        return render_template('admin/dashboard.html',
                               event=None,
                               logo=None,
                               user=current_user)

    logo = EventsHandler.find_image(image_name=str(event.external_id))
    return render_template('admin/dashboard.html',
                           event=event,
                           logo=logo,
                           user=current_user)
示例#4
0
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'))