コード例 #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'),
                           ])
コード例 #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')])
コード例 #3
0
ファイル: observatory.py プロジェクト: skitoo/arzo
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'),
        ]
    )
コード例 #4
0
ファイル: observatory.py プロジェクト: skitoo/arzo
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')
        ]
    )