コード例 #1
0
def edit_attendance():

    form = AttendanceForm()

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

    if form.validate_on_submit() and form.create.data:
        new_attendance = {
            'location' : {
                'building' : form.building.data,
                'floor' : form.floor.data,
                'room' : form.room.data,
                'opening' : form.opening.data
            },
            'email': form.email.data,
            'calendar': form.calendar.data,
            'phones' : {
                '0' : {
                    'type' : form.type1.data,
                    'number': form.phone1.data
                },
                '1' : {
                    'type': form.type2.data,
                    'number': form.phone2.data
                },
                '2' : {
                    'type': form.type3.data,
                    'number': form.phone3.data
                }
            }
        }

        dao.find_one_and_update({'_id' : ObjectId(form.attendance_id.data)}, {
            '$set': new_attendance
        })

        return redirect(
            url_for(
                'crud_attendances.edit_attendance',
                success_msg='Contato editado com sucesso.'))

    return render_template(
        'admin/edit_attendance.html',
        attendance=json,
        form=form,
        success_msg=request.args.get('success_msg')
    )
コード例 #2
0
def edit_attendance():

    form = AttendanceForm()

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

    if form.validate_on_submit() and form.create.data:
        new_attendance = {
            'location': {
                'building': form.building.data,
                'floor': form.floor.data,
                'room': form.room.data,
                'opening': form.opening.data
            },
            'email': form.email.data,
            'calendar': form.calendar.data,
            'phones': {
                '0': {
                    'type': form.type1.data,
                    'number': form.phone1.data
                },
                '1': {
                    'type': form.type2.data,
                    'number': form.phone2.data
                },
                '2': {
                    'type': form.type3.data,
                    'number': form.phone3.data
                }
            }
        }

        dao.find_one_and_update({'_id': ObjectId(form.attendance_id.data)},
                                {'$set': new_attendance})

        return redirect(
            url_for('crud_attendances.edit_attendance',
                    success_msg='Contato editado com sucesso.'))

    return render_template('admin/edit_attendance.html',
                           attendance=json,
                           form=form,
                           success_msg=request.args.get('success_msg'))
コード例 #3
0
ファイル: public.py プロジェクト: yuriscosta/PosGraduacao
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']
    )
コード例 #4
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,
    )
コード例 #5
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,
    )