Beispiel #1
0
def index():
    menu = 'societe'
    submenu = 'entreprise'
    context = 'fonction'
    title_page = 'Parametre - Fonctions'

    search = False
    q = request.args.get('q')
    if q:
        search = True
    try:
        page = int(request.args.get('page', 1))
    except ValueError:
        page = 1

    offset = 0
    limit = 10
    if page > 1:
        offset = ((page - 1) * 10)

    count = Fonction.objects().count()
    datas = Fonction.objects().skip(offset).limit(limit)

    pagination = Pagination(css_framework='bootstrap3',
                            page=page,
                            total=count,
                            search=search,
                            record_name='fonctions')

    return render_template('fonction/index.html', **locals())
Beispiel #2
0
def index():
    menu = 'societe'
    submenu = 'entreprise'
    context = 'fonction'
    title_page = 'Parametre - Fonctions'

    search = False
    q = request.args.get('q')
    if q:
        search = True
    try:
        page = int(request.args.get('page', 1))
    except ValueError:
        page = 1

    datas = Fonction.query()
    pagination = Pagination(css_framework='bootstrap3', page=page, total=datas.count(), search=search, record_name='fonctions')

    if datas.count() > 10:
        if page == 1:
            offset = 0
        else:
            page -= 1
            offset = page * 10
        datas = datas.fetch(limit=10, offset=offset)

    return render_template('fonction/index.html', **locals())
Beispiel #3
0
def delete(fonction_id):
    fonctions = Fonction.get_by_id(fonction_id)
    if not fonctions.count():
        fonctions.key.delete()
        flash('Suppression reussie', 'success')
    else:
        flash('Impossible de supprimer', 'danger')
    return redirect(url_for('fonction.index'))
Beispiel #4
0
def edit(fonction_id=None):

    if fonction_id:
        grades = Fonction.get_by_id(fonction_id)
        form = FormFonction(obj=grades)
    else:
        grades = Fonction()
        form = FormFonction()

    success = False
    if form.validate_on_submit():

        grades.libelle = form.libelle.data
        grades.put()

        flash('Enregistement effectue avec succes', 'success')
        success = True

    return render_template('fonction/edit.html', **locals())
Beispiel #5
0
def edit(fonction_id=None):

    if fonction_id:
        grades = Fonction.objects.get(id=fonction_id)
        form = FormFonction(obj=grades)
    else:
        grades = Fonction()
        form = FormFonction()

    success = False
    if form.validate_on_submit():

        grades.libelle = form.libelle.data
        grades.save()

        flash('Enregistement effectue avec succes', 'success')
        success = True

    return render_template('fonction/edit.html', **locals())