Exemple #1
0
def get_speakers():
    search_parameters = request.args.to_dict()
    search_parameters.pop('event', None)
    if 'spotlight' in search_parameters:
        if search_parameters['spotlight'] == 'True':
            search_parameters['spotlight'] = True
        elif search_parameters['spotlight'] == 'False':
            search_parameters['spotlight'] = False

    event_name = request.args.get('event')
    if event_name is None:
        event = EventsFinder.get_default_event()
    else:
        event = EventsFinder.get_from_name(event_name)

    if event is None:
        return APIErrorValue("Event not found!").json(404)

    speakers_list = SpeakersFinder.get_website_speakers(
        event, search_parameters)

    if speakers_list is None:
        return APIErrorValue('No results found').json(400)

    return SpeakersValue(speakers_list).json(200)
Exemple #2
0
def resumes_dashboard(company_user):
    if company_user.company.cvs_access:
        event = EventsFinder.get_default_event()
        today = datetime.now()
        cvs_access_start = datetime.strptime(event.cvs_access_start,
                                             '%d %b %Y, %a')
        cvs_access_end = datetime.strptime(event.cvs_access_end,
                                           '%d %b %Y, %a')

        if today < cvs_access_start or today > cvs_access_end:
            return render_template('companies/resumes/resumes_dashboard.html',
                                   cv_students=None,
                                   interested_students=None,
                                   error="Out of access date")
    else:
        return render_template('companies/resumes/resumes_dashboard.html',
                               cv_students=None,
                               interested_students=None,
                               error="Not authorized")

    company_students = StudentsFinder.get_company_students(
        company_user.company)

    return render_template('companies/resumes/resumes_dashboard.html',
                           company_students=company_students,
                           error=None)
Exemple #3
0
def dashboard(company_user):
    if not company_user.user.accepted_terms:
        return render_template('companies/terms_conditions.html', user=company_user.user)

    if company_user.company.cvs_access:
        event = EventsFinder.get_default_event()
        today = datetime.now()
        cvs_access_start = datetime.strptime(event.cvs_access_start, '%d %b %Y, %a')
        cvs_access_end = datetime.strptime(event.cvs_access_end, '%d %b %Y, %a')
        if today < cvs_access_start or today > cvs_access_end:
            cvs_enabled = False
        else:
            cvs_enabled = True
    else:
        cvs_enabled = False

    company_auctions = CompaniesFinder.get_company_auctions(company_user.company)

    company_logo = CompaniesHandler.find_image(company_user.company.name)

    job_fair = False
    activity_types = []
    for activity in ActivitiesFinder.get_current_company_activities(company_user.company):
        if (activity.activity_type not in activity_types) and (activity.activity_type.name not in ['Job Fair','Job Fair Booth']):
            activity_types.append(activity.activity_type)

        if (activity.activity_type.name in ['Job Fair','Job Fair Booth']):
            job_fair = True

    return render_template('companies/dashboard.html', auctions=company_auctions, job_fair=job_fair, company_logo=company_logo, activity_types=activity_types, user=company_user, cvs_enabled=cvs_enabled)
Exemple #4
0
def squad_rewards_dashboard():
    squad_rewards = RewardsFinder.get_all_squad_rewards()
    rewards = RewardsFinder.get_all_rewards()
    event = EventsFinder.get_default_event()
    if (event is None or event.start_date is None or event.end_date is None):
        return render_template(
            'admin/students_app/rewards/rewards_dashboard.html',
            search=None,
            error='Please select a default event and its date',
            rewards=rewards,
            current_user=current_user)

    event_dates = EventsHandler.get_event_dates(event)

    for squad_reward in squad_rewards:
        if (squad_reward.date not in event_dates):
            RewardsHandler.delete_squad_reward(squad_reward)

    rewards_dates = [squad_reward.date for squad_reward in squad_rewards]

    for date in event_dates:
        if (not date in rewards_dates):
            RewardsHandler.create_squad_reward(reward_id=None, date=date)

    rewards = RewardsFinder.get_all_rewards()
    squad_rewards = RewardsFinder.get_all_squad_rewards()

    return render_template(
        'admin/students_app/rewards/squad_rewards_dashboard.html',
        error=None,
        squad_rewards=squad_rewards,
        rewards=rewards,
        current_user=current_user)
    def get_all_from_type_and_event(cls, activity_type, event=None):
        if (event is None):
            event = EventsFinder.get_default_event()

        return Activities.query.filter_by(activity_type=activity_type,
                                          event_id=event.id).order_by(
                                              Activities.day,
                                              Activities.time).all()
Exemple #6
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)
    def search_by_name_and_event(cls, name, event=None):
        search = "%{}%".format(name)

        if (event is None):
            event = EventsFinder.get_default_event()

        return Activities.query.filter(
            Activities.name.ilike(search)
            & (Activities.event_id == event.id)).order_by(
                Activities.day, Activities.time,
                Activities.activity_type_id).all()
Exemple #8
0
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)
Exemple #9
0
def get_companies():
    search_parameters = request.args.to_dict()
    search_parameters.pop('event', None)
    event_name = request.args.get('event', None)

    if event_name is None:
        event = EventsFinder.get_default_event()
    else:
        event = EventsFinder.get_from_name(event_name)

    if event is None:
        return APIErrorValue("Event not found!").json(404)

    companies_list = CompaniesFinder.get_website_companies(
        event, search_parameters)

    if companies_list is None:
        return APIErrorValue('No results found').json(404)

    return CompaniesValue(companies_list, True).json(200)
Exemple #10
0
def get_activities(student):
    event = EventsFinder.get_default_event()
    date = request.args.get('date', None)
    if date is None:
        activities = event.activities
    else:
        activities = ActivitiesFinder.get_from_parameters({
            "event_id": event.id,
            "day": date
        })

    return StudentActivitiesValue(activities, student).json(200)
Exemple #11
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)
Exemple #12
0
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)
Exemple #13
0
def get_activity(activity_external_id):
    activity = ActivitiesFinder.get_from_external_id(activity_external_id)
    companies = CompaniesFinder.get_all()
    speakers = SpeakersFinder.get_all()
    tags = TagsFinder.get_all()
    rewards = RewardsFinder.get_all_rewards()

    event = EventsFinder.get_from_parameters({"default": True})
    if event is None or len(event) == 0:
        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)

    activity_types = event[0].activity_types
    company_activities = ActivitiesFinder.get_company_activities_from_activity_id(
        activity_external_id)
    speaker_activities = ActivitiesFinder.get_speaker_activities_from_activity_id(
        activity_external_id)
    activity_tags = TagsFinder.get_activity_tags_from_activity_id(
        activity_external_id)

    try:
        minDate = datetime.strptime(event[0].start_date,
                                    '%d %b %Y, %a').strftime("%Y,%m,%d")
        maxDate = datetime.strptime(event[0].end_date,
                                    '%d %b %Y, %a').strftime("%Y,%m,%d")
    except:
        minDate = None
        maxDate = None

    companies_zoom_url = {}
    for company in company_activities:
        companies_zoom_url[company.company_id] = company.zoom_link

    return render_template('admin/activities/update_activity.html', \
        activity=activity, \
        activity_types=activity_types, \
        companies=companies, \
        speakers=speakers, \
        tags=tags, \
        rewards=rewards, \
        company_activities=[company.company_id for company in company_activities], \
        speaker_activities=[speaker.speaker_id for speaker in speaker_activities], \
        companies_zoom_url=companies_zoom_url, \
        activity_tags=[tag.tag_id for tag in activity_tags], \
        minDate=minDate, \
        maxDate=maxDate, \
        error=None)
Exemple #14
0
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)
Exemple #15
0
def today_login(student):
    now = datetime.utcnow()
    date = now.strftime('%d %b %Y, %a')
    event = EventsFinder.get_default_event()
    dates = EventsHandler.get_event_dates(event)

    if date in dates:
        student_login = StudentsFinder.get_student_login(student, date)
        if student_login is None:
            StudentsHandler.add_student_login(student, date)
            StudentsHandler.add_points(student, int(Config.REWARD_LOGIN))
        else:
            return APIErrorValue("Already loggedin today").json(409)
    else:
        return APIErrorValue("Date out of event").json(409)

    return StudentsValue(student, details=True).json(200)
Exemple #16
0
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'))
Exemple #17
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)
Exemple #18
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)
Exemple #19
0
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)
Exemple #20
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'))
Exemple #21
0
def get_event_info(student):
    event = EventsFinder.get_default_event()

    return StudentEventInfoValue(event).json(200)
Exemple #22
0
def statistics_dashboard(company_user):
    event = EventsFinder.get_default_event()
    company_user = UsersFinder.get_company_user_from_user(current_user)
    interested_students = StudentsFinder.get_company_students(
        company_user.company)
    company_activities = ActivitiesFinder.get_activities_from_company_and_event(
        company_user.company, event)
    company = company_user.company

    interactions = db_session.query(Logs) \
                     .join(Activities, Logs.entrypoint.contains(Activities.name)) \
                     .join(Users, Users.username == Logs.user_id) \
                     .join(Students, Users.id == Students.user_id) \
                     .with_entities(Activities.name, Students.course, Students.entry_year, func.count(Activities.name)) \
                     .filter((Events.id == event.id) & (Events.id == Activities.event_id) & (CompanyActivities.activity_id == Activities.id) & (CompanyActivities.company_id == company.id)) \
                     .group_by(Activities.name, Students.course, Students.entry_year) \
                     .all()

    total_interactions = 0
    total_interactions_by_activity = {}
    total_interactions_by_course = {}
    total_interactions_by_year = {}
    interactions_by_course = {}
    interactions_by_year = {}
    for interaction_type in interactions:
        total_interactions += interaction_type[3]

        if "Job Fair" in interaction_type[0]:
            interaction_type = list(interaction_type)
            interaction_type[0] = interaction_type[0].rsplit(" ", 1)[0]

        if interaction_type[0] not in total_interactions_by_activity:
            total_interactions_by_activity[
                interaction_type[0]] = interaction_type[3]

            interactions_by_course[interaction_type[0]] = {}
            interactions_by_course[interaction_type[0]][
                interaction_type[1]] = interaction_type[3]

            interactions_by_year[interaction_type[0]] = {}
            interactions_by_year[interaction_type[0]][
                interaction_type[2]] = interaction_type[3]
        else:
            total_interactions_by_activity[
                interaction_type[0]] += interaction_type[3]

            if interaction_type[1] not in interactions_by_course[
                    interaction_type[0]]:
                interactions_by_course[interaction_type[0]][
                    interaction_type[1]] = interaction_type[3]
            else:
                interactions_by_course[interaction_type[0]][
                    interaction_type[1]] += interaction_type[3]

            if interaction_type[2] not in interactions_by_year[
                    interaction_type[0]]:
                interactions_by_year[interaction_type[0]][
                    interaction_type[2]] = interaction_type[3]
            else:
                interactions_by_year[interaction_type[0]][
                    interaction_type[2]] += interaction_type[3]

        if interaction_type[1] not in total_interactions_by_course:
            total_interactions_by_course[
                interaction_type[1]] = interaction_type[3]
        else:
            total_interactions_by_course[
                interaction_type[1]] += interaction_type[3]

        if interaction_type[2] not in total_interactions_by_year:
            total_interactions_by_year[
                interaction_type[2]] = interaction_type[3]
        else:
            total_interactions_by_year[
                interaction_type[2]] += interaction_type[3]

    participations = StudentActivities \
        .query \
        .join(Activities, StudentActivities.activity_id == Activities.id) \
        .join(Students, StudentActivities.student_id == Students.id) \
        .with_entities(Activities.name, Students.course, Students.entry_year, func.count(Activities.name), Activities.day) \
        .filter((Events.id == event.id) & (Events.id == Activities.event_id) & (CompanyActivities.activity_id == Activities.id) & (CompanyActivities.company_id == company.id)) \
        .group_by(Activities.name, Students.course, Students.entry_year, Activities.day) \
        .all()

    total_participations = 0
    total_participations_by_activity = {}
    total_participations_by_course = {}
    total_participations_by_year = {}
    participations_by_course = {}
    participations_by_year = {}
    for participation_type in participations:
        total_participations += participation_type[3]

        if "Booth" in participation_type[0]:
            week_day = participation_type[4][-3:]
            participation_type = list(participation_type)
            if week_day == "Mon":
                participation_type[0] = "Job Fair Monday"
            elif week_day == "Tue":
                participation_type[0] = "Job Fair Tuesday"
            elif week_day == "Wed":
                participation_type[0] = "Job Fair Wednesday"
            elif week_day == "Thu":
                participation_type[0] = "Job Fair Thursday"
            elif week_day == "Fri":
                participation_type[0] = "Job Fair Friday"

        if participation_type[0] not in total_participations_by_activity:
            total_participations_by_activity[
                participation_type[0]] = participation_type[3]

            participations_by_course[participation_type[0]] = {}
            participations_by_course[participation_type[0]][
                participation_type[1]] = participation_type[3]

            participations_by_year[participation_type[0]] = {}
            participations_by_year[participation_type[0]][
                participation_type[2]] = participation_type[3]
        else:
            total_participations_by_activity[
                participation_type[0]] += participation_type[3]

            if participation_type[1] not in participations_by_course[
                    participation_type[0]]:
                participations_by_course[participation_type[0]][
                    participation_type[1]] = participation_type[3]
            else:
                participations_by_course[participation_type[0]][
                    participation_type[1]] += participation_type[3]

            if participation_type[2] not in participations_by_year[
                    participation_type[0]]:
                participations_by_year[participation_type[0]][
                    participation_type[2]] = participation_type[3]
            else:
                participations_by_year[participation_type[0]][
                    participation_type[2]] += participation_type[3]

        if participation_type[1] not in total_participations_by_course:
            total_participations_by_course[
                participation_type[1]] = participation_type[3]
        else:
            total_participations_by_course[
                participation_type[1]] += participation_type[3]

        if participation_type[2] not in total_participations_by_year:
            total_participations_by_year[
                participation_type[2]] = participation_type[3]
        else:
            total_participations_by_year[
                participation_type[2]] += participation_type[3]

    interactions_by_course["Total"] = total_interactions_by_course
    interactions_by_year["Total"] = total_interactions_by_year

    participations_by_course["Total"] = total_participations_by_course
    participations_by_year["Total"] = total_participations_by_year

    return render_template('companies/statistics/statistics_dashboard.html', \
                           participations_by_course=participations_by_course, \
                           participations_by_year=participations_by_year, \
                           interactions_by_course=interactions_by_course, \
                           interactions_by_year=interactions_by_year, \
                           total_participations_by_year=total_participations_by_year,\
                           total_participations=total_participations,\
                           total_participations_by_activity=total_participations_by_activity,\
                           total_participations_by_course=total_participations_by_course,\
                           total_interactions_by_year=total_interactions_by_year,\
                           total_interactions=total_interactions,\
                           total_interactions_by_course=total_interactions_by_course,\
                           total_interactions_by_activity=total_interactions_by_activity,\
                           activity="Total",\
                           company_activities=company_activities,\
                           interactions=interactions,\
                           participations=participations,\
                           error=None)
Exemple #23
0
def get_event():
    event = EventsFinder.get_default_event()

    return EventsValue(event).json(200)
Exemple #24
0
def get_activities():
    search_parameters = request.args
    name = request.args.get('name')
    speaker = request.args.get('speaker')
    company = request.args.get('company')

    event = request.args.get('event')
    if event is None:
        event = EventsFinder.get_default_event()
    else:
        event = EventsFinder.get_from_name(event)

    if event is None:
        return APIErrorValue("Event no found!").json(404)

    activities_list = []

    # handle search bar requests
    if name is not None:
        search = name
        activities_list = ActivitiesFinder.search_by_name_and_event(
            search, event)

    # handle parameter requests
    elif speaker is not None:
        search = speaker
        speaker = SpeakersFinder.get_from_name(search)

        if speaker:
            activities_list = ActivitiesFinder.get_activities_from_speaker_and_event(
                speaker, event)

    elif company is not None:
        search = company
        company = CompaniesFinder.get_from_name(search)

        if company:
            activities_list = ActivitiesFinder.get_activities_from_company_and_event(
                company, event)

    elif len(search_parameters) != 0:
        search = 'search name'

        try:
            search_parameters = request.args.to_dict()
            search_parameters['type'] = ActivityTypesFinder.get_from_name(
                search_parameters['type']).id
            search_parameters['activity_type_id'] = search_parameters.pop(
                'type')
        except:
            pass

        activities_list = ActivitiesFinder.get_from_parameters(
            search_parameters)

    # request endpoint with no parameters should return all activities
    else:
        search = None
        activities_list = ActivitiesFinder.get_activities_from_event(event)

    if activities_list is None:
        return APIErrorValue('No results found').json(400)

    return ActivitiesValue(activities_list).json(200)
Exemple #25
0
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)
Exemple #26
0
def get_activity_dates(student):
    event = EventsFinder.get_default_event()
    dates = EventsHandler.get_event_dates(event)

    return jsonify(dates)
Exemple #27
0
def create_event():
    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')
    email = request.form.get('email')
    location = request.form.get('location')
    default = request.form.get('default')
    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

    event = EventsHandler.create_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)

    if event is None:
        return render_template('admin/events/add_event.html',
                               error="Failed to create event!")

    # 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 event:
                EventsHandler.update_event(event=default_event, default=False)

    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(event.external_id))

            if result == False:
                EventsHandler.delete_event(event)
                return render_template('admin/events/add_event.html',
                                       error=msg)

        if mobile_image_file:
            image_name = f'{event.external_id}_mobile'
            result, msg = EventsHandler.upload_image(mobile_image_file,
                                                     image_name)

            if result == False:
                EventsHandler.delete_event(event)
                return render_template('admin/events/add_event.html',
                                       error=msg)

        if blueprint_file:
            image_name = f'{event.external_id}_blueprint'
            result, msg = EventsHandler.upload_image(blueprint_file,
                                                     image_name)

            if result == False:
                EventsHandler.delete_event(event)
                return render_template('admin/events/add_event.html',
                                       error=msg)

        if schedule_file:
            image_name = f'{event.external_id}_schedule'
            result, msg = EventsHandler.upload_image(blueprint_file,
                                                     image_name)

            if result == False:
                EventsHandler.delete_event(event)
                return render_template('admin/events/add_event.html',
                                       error=msg)

    return redirect(url_for('admin_api.events_dashboard'))
Exemple #28
0
def update_activity(activity_external_id):
    activity = ActivitiesFinder.get_from_external_id(activity_external_id)
    company_activities = ActivitiesFinder.get_company_activities_from_activity_id(
        activity_external_id)
    speaker_activities = ActivitiesFinder.get_speaker_activities_from_activity_id(
        activity_external_id)
    activity_tags = TagsFinder.get_activity_tags_from_activity_id(
        activity_external_id)

    if activity is None:
        return APIErrorValue('Couldnt find activity').json(500)

    name = request.form.get('name')
    description = request.form.get('description')
    location = request.form.get('location')
    day = request.form.get('day')
    time = request.form.get('time')
    end_time = request.form.get('end_time')
    registration_link = request.form.get('registration_link')
    registration_open = request.form.get('registration_open')
    points = request.form.get('points') or None
    quest = request.form.get('quest')
    chat = request.form.get('chat')
    zoom_link = request.form.get('zoom_url')
    reward_id = request.form.get('reward') or None
    moderator = request.form.get('moderator') or None

    if time > end_time is None:
        return APIErrorValue('Activity starting time after ending time').json(
            500)

    if registration_open == 'True':
        registration_open = True
    else:
        registration_open = False

    if quest == 'True':
        quest = True
    else:
        quest = False

    chat_type = ActivityChatEnum[chat] if chat else None

    activity_type_external_id = request.form.get('type')
    activity_type = ActivityTypesFinder.get_from_external_id(
        uuid.UUID(activity_type_external_id))

    updated_activity = ActivitiesHandler.update_activity(
        activity=activity,
        activity_type=activity_type,
        name=name,
        description=description,
        location=location,
        day=day,
        time=time,
        end_time=end_time,
        registration_link=registration_link,
        registration_open=registration_open,
        points=points,
        quest=quest,
        zoom_link=zoom_link,
        chat_type=chat_type,
        chat=(chat == 'general'),
        reward_id=reward_id)

    if company_activities:
        for company_activity in company_activities:
            ActivitiesHandler.delete_company_activities(company_activity)

    if speaker_activities:
        for speaker_activity in speaker_activities:
            ActivitiesHandler.delete_speaker_activities(speaker_activity)

    if activity_tags:
        for activity_tag in activity_tags:
            TagsHandler.delete_activity_tag(activity_tag)

    # extract company names and speaker names from parameters
    companies = request.form.getlist('company')
    zoom_urls = request.form.getlist('url')
    speakers = request.form.getlist('speaker')
    tags = request.form.getlist('tag')

    # if company names where provided
    if companies:
        for index, name in enumerate(companies):
            company = CompaniesFinder.get_from_name(name)
            if company is None:
                return APIErrorValue('Couldnt find company').json(500)

            company_activity = ActivitiesHandler.add_company_activity(
                company, activity, zoom_urls[index])
            if company_activity is None:
                return APIErrorValue('Failed to create company activity').json(
                    500)

            if activity_type.name == 'Job Fair':
                job_fair_booth = ActivityTypesFinder.get_from_name(
                    'Job Fair Booth')
                if not ActivitiesFinder.get_from_parameters(
                    {
                        'name': company.name + " Booth",
                        'day': day
                    }):
                    job_fair_booth_activity = ActivitiesHandler.create_activity(
                        name=company.name + " Booth",
                        description="Visit " + company.name +
                        " booth to earn extra points",
                        activity_type=job_fair_booth,
                        event=activity.event,
                        location="Job Fair",
                        day=day,
                        time='10:30',
                        end_time='16:30',
                        points=40,
                        quest=False)
                    ActivitiesHandler.add_company_activity(
                        company, job_fair_booth_activity)

    if speakers:
        for name in speakers:
            speaker = SpeakersFinder.get_from_name(name)
            if speaker is None:
                return APIErrorValue('Couldnt find speaker').json(500)

            speaker_activity = ActivitiesHandler.add_speaker_activity(
                speaker, activity)
            if speaker_activity is None:
                return APIErrorValue('Failed to create speaker activity').json(
                    500)

        if (moderator and moderator in speakers):
            moderator = SpeakersFinder.get_from_name(moderator)
            if moderator is None:
                return APIErrorValue('Couldnt find moderator').json(500)

            ActivitiesHandler.update_activity(activity,
                                              activity_type,
                                              moderator_id=moderator.id)

        elif (not moderator):
            ActivitiesHandler.update_activity(activity,
                                              activity_type,
                                              moderator_id=None)

    if tags:
        for name in tags:
            tag = TagsFinder.get_by_name(name)
            if tag is None:
                return APIErrorValue('Couldnt find tag').json(500)

            activity_tag = TagsHandler.add_activity_tag(activity, tag)
            if activity_tag is None:
                return APIErrorValue('Failed to create activity tag').json(500)

    if updated_activity is None:
        event = EventsFinder.get_from_parameters({"default": True})

        if event is None or len(event) == 0:
            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)

        activity_types = event[0].activity_types

        try:
            minDate = datetime.strptime(event[0].start_date,
                                        '%d %b %Y, %a').strftime("%Y,%m,%d")
            maxDate = datetime.strptime(event[0].end_date,
                                        '%d %b %Y, %a').strftime("%Y,%m,%d")
        except:
            minDate = None
            maxDate = None

        return render_template('admin/activities/update_activity.html', \
            activity=activity, \
            types=activity_types, \
            companies=CompaniesFinder.get_all(), \
            speakers=SpeakersFinder.get_all(), \
            tags=TagsFinder.get_all(), \
            rewards=RewardsFinder.get_all_rewards(), \
            minDate=minDate, \
            maxDate=maxDate, \
            error="Failed to update activity!")

    return redirect(url_for('admin_api.activities_dashboard'))