Example #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())
Example #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.')