Exemple #1
0
def delete_participations():
    """
    Render a delete participation form.
    """

    form = ParticipationsInEventsForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.integrations_infos_dao()
    json = pfactory.integrations_infos_dao().find_one()
    json = dict(json)
    json = dumps(json)
    index = str(form.index.data)

    if form.validate_on_submit():
        dao.find_one_and_update(
            None,
            {'$set': {
                'participationsInEvents.' + index + '.deleted': ""
            }})

        return redirect(
            url_for('crud_participation.delete_participations',
                    participations=json,
                    success_msg='Participação deletada com sucesso'))
    return render_template('admin/delete_participations.html',
                           form=form,
                           participations=json,
                           success_msg=request.args.get('success_msg'))
Exemple #2
0
def delete_covenants():
    """Render covenant deleting form."""

    form = EditInstitutionsWithCovenantsForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.integrations_infos_dao()
    json = pfactory.integrations_infos_dao().find_one()
    json = dict(json)
    json = dumps(json)

    if form.validate_on_submit() and form.create.data:
        index = str(form.index.data)
        dao.find_one_and_update(None, {
            '$set': {'institutionsWithCovenant.' + index + '.deleted' : ""}
        })
        return redirect(
            url_for(
                'admin.delete_covenants',
                integrations=json,
                success_msg='Convênio deletado com sucesso.'
            )
        )

    return render_template(
        'admin/delete_covenants.html',
        form=form,
        integrations=json,
        success_msg=request.args.get('success_msg')
    )
Exemple #3
0
def participations():
    """Render a view for integrations lists."""

    form = ParticipationsInEventsForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.integrations_infos_dao()

    if form.validate_on_submit() and form.create.data:
        new_participation = {
            'title': form.title.data,
            'description': form.description.data,
            'year': form.year.data,
            'international': form.location.data
        }

        dao.find_one_and_update(
            None, {'$push': {
                'participationsInEvents': new_participation
            }})

        return redirect(
            url_for(
                'admin.participations',
                success_msg='Intercâmbio adicionado adicionado com sucesso.'))

    return render_template(
        'admin/participations.html',
        participations=dao.find_one()['participationsInEvents'],
        form=form,
        success_msg=request.args.get('success_msg'))
Exemple #4
0
def view_covenants(initials):
    """Render a view for integrations lists."""

    pfactory = PosGraduationFactory(initials)
    post_graduation = pfactory.post_graduation

    integrations_infos = pfactory.integrations_infos_dao().find_one()

    # renders an own page or redirect to another (external/404)?
    return render_template('public/covenants.html',
                           std=get_std_for_template(post_graduation),
                           integrations_infos=integrations_infos)
def edit_participations():
    """
    Render a edit participation form.
    """

    form = ParticipationsInEventsForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.integrations_infos_dao()
    json = pfactory.integrations_infos_dao().find_one()
    json = dict(json)
    json = dumps(json)
    index = str(form.index.data)

    if form.validate_on_submit() and form.create.data:
        year = int(form.year.data)
        new_participation = {
            'title': form.title.data,
            'description': form.description.data,
            'year': year,
            'international': form.location.data,
            'type_of_participation': form.type_of_participation.data
        }

        dao.find_one_and_update(
            None,
            {'$set': {
                'participationsInEvents.' + index: new_participation
            }})

        return redirect(
            url_for('crud_participation.edit_participations',
                    participations=json,
                    success_msg='Participação editada com sucesso'))
    return render_template('admin/edit_participations.html',
                           form=form,
                           participations=json,
                           success_msg=request.args.get('success_msg'))
def view_covenants(initials):
    """Render a view for integrations lists."""

    pfactory = PosGraduationFactory(initials)
    post_graduation = pfactory.post_graduation

    integrations_infos = pfactory.integrations_infos_dao().find_one()

    # renders an own page or redirect to another (external/404)?
    return render_template(
        'public/covenants.html',
        std=get_std_for_template(post_graduation),
        integrations_infos=integrations_infos
    )
Exemple #7
0
def covenants():
    """Render covenant adding form."""

    allowed_extensions = ['jpg', 'png']

    form = InstitutionsWithCovenantsForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.integrations_infos_dao()

    if form.validate_on_submit() and form.create.data:
        if form.logo.data and allowedFile(form.logo.data.filename, allowed_extensions):
            photo = form.logo.data
            path = os.path.normpath("static/assets")
            filename = secure_filename(photo.filename)
            if filename.count('.') > 1:
                return redirect(
                    url_for(
                        'admin.covenants',
                        success_msg='Nome da logo contem mais de um . por favor corrija isso'
                    )
                )
            name, extension = filename.split('.')
            logoFile = 'logo-' + form.initials.data.lower() + '.' + extension
            uploadFiles(photo, path, logoFile)
            new_covenant = {
                'name': form.name.data,
                'initials': form.initials.data.upper(),
                'logoFile': logoFile,
                'objective': form.objective.data,
                'status': form.status.data,
            }

        dao.find_one_and_update(None, {
            '$push': {'institutionsWithCovenant': new_covenant}
        })

        return redirect(
            url_for(
                'admin.covenants',
                success_msg='Convênio adicionado adicionado com sucesso.'
            )
        )


    return render_template(
        'admin/covenants.html',
        form=form,
        success_msg=request.args.get('success_msg')
    )
Exemple #8
0
def home(initials):
    """
    Render a post-graduation program page.

    Try to find which program has been requested.

    If it's here: signed in Minerva, show its main page,
    otherwise the user is redirected to that programs external web site.

    If couldn't find which program has been requested, show a 404 page error.
    """

    pfactory = PosGraduationFactory(initials)
    post_graduation = pfactory.post_graduation

    # renders an own page or redirect to another (external/404)?
    if post_graduation is None:
        return page_not_found()

    if not post_graduation['isSignedIn']:
        return redirect(post_graduation['oldURL'])

    # query google maps api
    google_maps_api_dict = keyring.get(keyring.GOOGLE_MAPS)

    google_maps_api_key = 'none'
    if google_maps_api_dict is not None:
        google_maps_api_key = google_maps_api_dict['key']

    # search for home data
    final_reports = pfactory.final_reports_dao().find_one()['scheduledReports']
    weekly_schedules = pfactory.weekly_schedules_dao().find()
    integrations_infos = pfactory.integrations_infos_dao().find_one()
    attendance = pfactory.attendances_dao().find_one()

    # ready... fire!
    return render_template(
        'public/home.html',
        std=get_std_for_template(post_graduation),
        google_maps_api_key=google_maps_api_key,
        final_reports=final_reports,
        weekly_schedules=weekly_schedules,
        attendance=attendance,
        institutionsWithCovenant=integrations_infos['institutionsWithCovenant']
    )
def home(initials):
    """
    Render a post-graduation program page.

    Try to find which program has been requested.

    If it's here: signed in Minerva, show its main page,
    otherwise the user is redirected to that programs external web site.

    If couldn't find which program has been requested, show a 404 page error.
    """

    pfactory = PosGraduationFactory(initials)
    post_graduation = pfactory.post_graduation

    # renders an own page or redirect to another (external/404)?
    if post_graduation is None:
        return page_not_found()

    if not post_graduation['isSignedIn']:
        return redirect(post_graduation['oldURL'])

    # query google maps api
    google_maps_api_dict = keyring.get(keyring.GOOGLE_MAPS)

    google_maps_api_key = 'none'
    if google_maps_api_dict is not None:
        google_maps_api_key = google_maps_api_dict['key']

    # search for home data
    final_reports = pfactory.final_reports_dao().find_one()
    calendar = pfactory.calendar_dao().find_one()['events']
    selections = []
    events = []
    for event in range(len(calendar)):
        if "deleted" not in calendar[event]:
            if "Seleção" in calendar[event]['title']:
                selections.append(calendar[event])
            else:
                events.append(calendar[event])
    final_reports = final_reports['scheduledReports']
    news = pfactory.news_dao().find_one()['news']
    classes = pfactory.classes_database_dao().find_one()['firstClasses']
    integrations_infos = pfactory.integrations_infos_dao().find_one()
    if integrations_infos is None:
        integrations_infos = {
            'name': "",
            'initials': "",
            'logoFile': "",
        }
        institutions_with_covenant = integrations_infos
    else:
        institutions_with_covenant = integrations_infos['institutionsWithCovenant']
    attendance = pfactory.attendances_dao().find_one()
    if attendance is None:
        attendance = {
            'location' : {
                'building' : '',
                'floor' : '',
                'room' : '',
                'opening' : ''
                },
            'email' : '',
            'phones' : {
                'type' : '',
                'number' : ''
                }
        }

    # ready... fire!
    return render_template(
        'public/home.html',
        std=get_std_for_template(post_graduation),
        google_maps_api_key=google_maps_api_key,
        final_reports=final_reports,
        events=events,
        selections=selections,
        classes=classes,
        news=news,
        institutions_with_covenant=institutions_with_covenant,
        attendance=attendance,
    )
Exemple #10
0
def home(initials):
    """
    Render a post-graduation program page.

    Try to find which program has been requested.

    If it's here: signed in Minerva, show its main page,
    otherwise the user is redirected to that programs external web site.

    If couldn't find which program has been requested, show a 404 page error.
    """

    pfactory = PosGraduationFactory(initials)
    post_graduation = pfactory.post_graduation

    # renders an own page or redirect to another (external/404)?
    if post_graduation is None:
        return page_not_found()

    if not post_graduation['isSignedIn']:
        return redirect(post_graduation['oldURL'])

    # query google maps api
    google_maps_api_dict = keyring.get(keyring.GOOGLE_MAPS)

    google_maps_api_key = 'none'
    if google_maps_api_dict is not None:
        google_maps_api_key = google_maps_api_dict['key']

    # search for home data
    final_reports = pfactory.final_reports_dao().find_one()
    calendar = pfactory.calendar_dao().find_one()['events']
    selections = []
    events = []
    for event in range(len(calendar)):
        if "deleted" not in calendar[event]:
            if "Seleção" in calendar[event]['title']:
                selections.append(calendar[event])
            else:
                events.append(calendar[event])
    final_reports = final_reports['scheduledReports']
    news = pfactory.news_dao().find_one()['news']
    classes = pfactory.classes_database_dao().find_one()['firstClasses']
    integrations_infos = pfactory.integrations_infos_dao().find_one()
    if integrations_infos is None:
        integrations_infos = {
            'name': "",
            'initials': "",
            'logoFile': "",
        }
        institutions_with_covenant = integrations_infos
    else:
        institutions_with_covenant = integrations_infos[
            'institutionsWithCovenant']
    attendance = pfactory.attendances_dao().find_one()
    if attendance is None:
        attendance = {
            'location': {
                'building': '',
                'floor': '',
                'room': '',
                'opening': ''
            },
            'email': '',
            'phones': {
                'type': '',
                'number': ''
            }
        }

    # ready... fire!
    return render_template(
        'public/home.html',
        std=get_std_for_template(post_graduation),
        google_maps_api_key=google_maps_api_key,
        final_reports=final_reports,
        events=events,
        selections=selections,
        classes=classes,
        news=news,
        institutions_with_covenant=institutions_with_covenant,
        attendance=attendance,
    )
Exemple #11
0
def edit_covenants():
    """Render covenant editing form."""

    allowed_extensions = ['jpg', 'png']

    form = EditInstitutionsWithCovenantsForm()

    pfactory = PosGraduationFactory(current_user.pg_initials)
    dao = pfactory.integrations_infos_dao()
    json = pfactory.integrations_infos_dao().find_one()
    json = dict(json)
    json = dumps(json)

    if form.validate_on_submit() and form.create.data:
        index = str(form.index.data)
        if form.logo.data and allowedFile(form.logo.data.filename,
                                          allowed_extensions):
            photo = form.logo.data
            path = os.path.normpath("static/assets")
            filename = secure_filename(photo.filename)
            if filename.count('.') > 1:
                return redirect(
                    url_for(
                        'admin.edit_covenants',
                        integrations=json,
                        success_msg=
                        'Nome da logo contem mais de um . por favor corrija isso'
                    ))
            name, extension = filename.split('.')
            logoFile = 'logo-' + form.initials.data.lower() + '.' + extension
            logo = uploadFiles(photo, path, logoFile)
            new_covenant = {
                'name': form.name.data,
                'initials': form.initials.data.upper(),
                'logoFile': logo
            }

            dao.find_one_and_update(
                None,
                {'$set': {
                    'institutionsWithCovenant.' + index: new_covenant
                }})
        else:
            dao.find_one_and_update(
                None, {
                    '$set': {
                        'institutionsWithCovenant.' + index + '.initials':
                        form.initials.data.upper()
                    }
                })
            dao.find_one_and_update(
                None, {
                    '$set': {
                        'institutionsWithCovenant.' + index + '.name':
                        form.name.data
                    }
                })

        return redirect(
            url_for('admin.edit_covenants',
                    integrations=json,
                    success_msg='Convênio editado com sucesso.'))

    return render_template('admin/edit_covenants.html',
                           form=form,
                           integrations=json,
                           success_msg=request.args.get('success_msg'))