Esempio n. 1
0
def new_observatory():
    form = ObservatoryForm()
    if form.validate_on_submit():
        observatory = Observatory()
        form.populate_obj(observatory)
        observatory.altitude = services.get_elevation(observatory.latitude,
                                                      observatory.longitude)
        observatory.timezone = services.get_timezone(observatory.latitude,
                                                     observatory.longitude)
        db.session.add(observatory)
        if observatory.selected:
            Observatory.query.filter(Observatory.id != observatory.id).update(
                {Observatory.selected: False})
        db.session.commit()
        flash(u'Observatoire sauvegardé avec succès', 'success')
        return redirect(url_for('observatories'))
    return render_template('edit_observatory.html',
                           form=form,
                           title='Nouvel observatoire',
                           breadcrumb=[
                               (url_for('index'), 'Accueil'),
                               (url_for('observatories'), 'Observatoires'),
                               (url_for('new_observatory'),
                                'Nouvel observatoire'),
                           ])
Esempio n. 2
0
def edit_observatory(observatory_id):
    observatory = Observatory.query.get_or_404(observatory_id)
    form = ObservatoryForm(obj=observatory)
    if form.validate_on_submit():
        form.populate_obj(observatory)
        observatory.altitude = services.get_elevation(observatory.latitude,
                                                      observatory.longitude)
        observatory.timezone = services.get_timezone(observatory.latitude,
                                                     observatory.longitude)
        db.session.merge(observatory)
        if observatory.selected:
            Observatory.query.filter(Observatory.id != observatory.id).update(
                {Observatory.selected: False})
        db.session.commit()
        flash(u'Observatoire sauvegardé avec succès', 'success')
        return redirect(url_for('observatories'))
    return render_template('edit_observatory.html',
                           form=form,
                           title='Observatoire - %s' % observatory.name,
                           breadcrumb=[(url_for('index'), 'Accueil'),
                                       (url_for('observatories'),
                                        'Observatoires'),
                                       (url_for('show_observatory',
                                                observatory_id=observatory_id),
                                        observatory.name), (None, u'Édition')])
Esempio n. 3
0
def new_observatory():
    form = ObservatoryForm()
    if form.validate_on_submit():
        observatory = Observatory()
        form.populate_obj(observatory)
        observatory.altitude = services.get_elevation(observatory.latitude, observatory.longitude)
        observatory.timezone = services.get_timezone(observatory.latitude, observatory.longitude)
        db.session.add(observatory)
        if observatory.selected:
            Observatory.query.filter(Observatory.id != observatory.id).update({Observatory.selected: False})
        db.session.commit()
        flash(u'Observatoire sauvegardé avec succès', 'success')
        return redirect(url_for('observatories'))
    return render_template(
        'edit_observatory.html',
        form=form,
        title='Nouvel observatoire',
        breadcrumb=[
            (url_for('index'), 'Accueil'),
            (url_for('observatories'), 'Observatoires'),
            (url_for('new_observatory'), 'Nouvel observatoire'),
        ]
    )
Esempio n. 4
0
def edit_observatory(observatory_id):
    observatory = Observatory.query.get_or_404(observatory_id)
    form = ObservatoryForm(obj=observatory)
    if form.validate_on_submit():
        form.populate_obj(observatory)
        observatory.altitude = services.get_elevation(observatory.latitude, observatory.longitude)
        observatory.timezone = services.get_timezone(observatory.latitude, observatory.longitude)
        db.session.merge(observatory)
        if observatory.selected:
            Observatory.query.filter(Observatory.id != observatory.id).update({Observatory.selected: False})
        db.session.commit()
        flash(u'Observatoire sauvegardé avec succès', 'success')
        return redirect(url_for('observatories'))
    return render_template(
        'edit_observatory.html',
        form=form,
        title='Observatoire - %s' % observatory.name,
        breadcrumb=[
            (url_for('index'), 'Accueil'),
            (url_for('observatories'), 'Observatoires'),
            (url_for('show_observatory', observatory_id=observatory_id), observatory.name),
            (None, u'Édition')
        ]
    )
Esempio n. 5
0
def api_elevation():
    return services.get_elevation(request.args.get('latitude', ''),
                                  request.args.get('longitude', ''))
Esempio n. 6
0
File: api.py Progetto: skitoo/arzo
def api_elevation():
    return services.get_elevation(request.args.get('latitude', ''), request.args.get('longitude', ''))