Example #1
0
def index():
    menu = 'societe'
    submenu = 'entreprise'
    context = 'site'
    title_page = 'Parametre - Sites'

    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 = Site.objects().count()
    datas = Site.objects().skip(offset).limit(limit)

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

    return render_template('site/index.html', **locals())
Example #2
0
def index():
    menu = "societe"
    submenu = "entreprise"
    context = "site"
    title_page = "Parametre - Sites"

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

    datas = Site.query()
    pagination = Pagination(
        css_framework="bootstrap3", page=page, total=datas.count(), search=search, record_name="sites"
    )

    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("site/index.html", **locals())
Example #3
0
def delete(site_id):
    sites = Site.get_by_id(site_id)
    if not sites.count_user():
        sites.key.delete()
        flash("Suppression reussie", "success")
    else:
        flash("Impossible de supprimer", "danger")
    return redirect(url_for("site.index"))
Example #4
0
def edit(site_id=None):

    if site_id:
        sites = Site.objects().get(id=site_id)
        form = FormSite(obj=sites)
    else:
        sites = Site()
        form = FormSite()

    success = False
    if form.validate_on_submit():

        entreprise = Societe.objects().first()

        sites.libelle = form.libelle.data
        sites.societe = entreprise
        sites.save()

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

    return render_template('site/edit.html', **locals())
Example #5
0
def edit(site_id=None):

    if site_id:
        sites = Site.get_by_id(site_id)
        form = FormSite(obj=sites)
    else:
        sites = Site()
        form = FormSite()

    success = False
    if form.validate_on_submit():
        entreprise = Societe.query().get()

        sites.libelle = form.libelle.data
        sites.societe = entreprise.key
        sites.put()

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

    return render_template("site/edit.html", **locals())