예제 #1
0
def index():
    menu = 'societe'
    submenu = 'roles'
    context = 'profil'
    title_page = 'Gestion des profils'

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

    pagination = Pagination(css_framework='bootstrap3',
                            page=page,
                            total=count,
                            search=search,
                            record_name='Profils')
    return render_template('profil/index.html', **locals())
예제 #2
0
def index():
    title_parent = 'Configuration'
    title_page = 'Profils'

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

    pagination = Pagination(css_framework='uikit',
                            page=page,
                            total=count,
                            search=search,
                            record_name='Profils')

    return render_template('profil/index.html', **locals())
예제 #3
0
def unique_code_validator(form, field):
    code_unique = Profil.objects(name=field.data).count()
    if code_unique:
        if not form.id.data:
            raise wtf.ValidationError(
                'Ce nom est deja utilise dans les profils.')
        else:
            code = Profil.objects.get(id=form.id.data)
            if code.name != field.data:
                raise wtf.ValidationError(
                    'Ce nom est deja utilise dans les profils.')