Esempio n. 1
0
def index():
    menu = 'societe'
    submenu = 'entreprise'
    context = 'domaine'
    title_page = 'Parametre - Domaines'

    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 = Domaine.objects().count()
    datas = Domaine.objects().skip(offset).limit(limit)
    pagination = Pagination(css_framework='bootstrap3',
                            page=page,
                            total=count,
                            search=search,
                            record_name='domaines')

    return render_template('domaine/index.html', **locals())
Esempio n. 2
0
def unique_code_validator(form, field):
    code_unique = Domaine.objects(code=field.data)
    if len(code_unique):
        if not form.id.data:
            raise wtf.ValidationError(
                'Ce code est deja utilise dans le domaine.')
        else:
            code = Domaine.get_by_id(int(form.id.data))
            if code.code != field.data:
                raise wtf.ValidationError(
                    'Ce code est deja utilise dans le domaine.')
Esempio n. 3
0
def unique_code_validator(form, field):
    code_unique = Domaine.query(
        Domaine.code == field.data
    ).count()
    if code_unique:
        if not form.id.data:
            raise wtf.ValidationError('Ce code est deja utilise dans le domaine.')
        else:
            code = Domaine.get_by_id(int(form.id.data))
            if code.code != field.data:
                raise wtf.ValidationError('Ce code est deja utilise dans le domaine.')
Esempio n. 4
0
def domaine_service(domaine_id):

    domaines = Domaine.get_by_id(domaine_id)
    data_service = Service.query(
        Service.domaine == domaines.key
    )
    return render_template('domaine/index_ligne.html', **locals())
Esempio n. 5
0
def index():
    menu = 'societe'
    submenu = 'entreprise'
    context = 'domaine'
    title_page = 'Parametre - Domaines'

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

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

    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('domaine/index.html', **locals())
Esempio n. 6
0
def delete(domaine_id):
    from ..projet.models_projet import Projet
    domaines = Domaine.get_by_id(domaine_id)

    dom_projet = Projet.query(
        Projet.domaine_id == domaines.key
    ).count()

    if dom_projet:
        flash('Impossible de supprimer cet element', 'danger')
    else:
        domaines.key.delete()
        flash('Suppression reussie', 'success')
    return redirect(url_for('domaine.index'))
Esempio n. 7
0
def domaine_service_edit(domaine_id, service_id=None):

    domaines = Domaine.get_by_id(domaine_id)

    if service_id:
        services = Service.get_by_id(service_id)
        form = FormService(obj=services)
        form.id.data = service_id
    else:
        services = Service()
        form = FormService()

    if form.validate_on_submit():

        services.libelle = form.libelle.data
        services.code = form.code.data
        services.domaine = domaines.key
        services.put()

        flash('Enregistement effectue avec succes', 'success')
        return redirect(url_for('domaine.domaine_service', domaine_id=domaine_id))

    return render_template('domaine/edit_ligne.html', **locals())
Esempio n. 8
0
def edit(domaine_id=None):

    if domaine_id:
        domaines = Domaine.objects.get(id=domaine_id)
        form = FormDomaine(obj=domaines)
        form.id.data = domaine_id
    else:
        domaines = Domaine()
        form = FormDomaine()

    success = False
    if form.validate_on_submit():

        domaines.libelle = form.libelle.data
        domaines.code = form.code.data
        domaines.save()

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

    return render_template('domaine/edit.html', **locals())
Esempio n. 9
0
def edit(domaine_id=None):

    if domaine_id:
        domaines = Domaine.get_by_id(domaine_id)
        form = FormDomaine(obj=domaines)
        form.id.data = domaine_id
    else:
        domaines = Domaine()
        form = FormDomaine()

    success = False
    if form.validate_on_submit():

        domaines.libelle = form.libelle.data
        domaines.code = form.code.data
        domaines.put()

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

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