コード例 #1
0
def certificates_series(current_user):
    if request.method == 'GET':
        return force_pagination(refbooks.CounterModel.query)

    if request.json['action'] == Action.updated:
        return crud(request.method, request.json, refbooks.CounterModel,
                    current_user)
コード例 #2
0
ファイル: views.py プロジェクト: maxef23/demography
def organisation_get(current_user):
    query = refbooks.OrganisationModel.query
    if request.values.get('org_name', None) is not None:
        query = query.filter(
            refbooks.OrganisationModel.name.like('%{}%'.format(
                request.values['org_name'])))
    if request.values.get('org_id', None) is not None:
        query = query.filter(
            refbooks.OrganisationModel.id == request.values['org_id'])

    return force_pagination(query)
コード例 #3
0
ファイル: views.py プロジェクト: maxef23/demography
def document_type(current_user):
    if request.method == 'GET':
        query = refbooks.DocumentTypeModel.query

        code = request.args.get('code', '')
        if code:
            query = query.filter_by(code=code)

        return force_pagination(query)

    return crud(request.method, None, refbooks.DocumentTypeModel, current_user)
コード例 #4
0
def speciality(current_user):
    if request.method == 'GET':
        model = refbooks.SpecialityModel
        query = model.query

        if request.values.get('name', None) is not None:
            query = query.filter(model.name.like('%{}%'.format(request.values['name'])))
        if request.values.get('code', None) is not None:
            query = query.filter(model.name.like('%{}%'.format(request.values['code'])))
        if request.values.get('id', None) is not None:
            query = query.filter(model.id == request.values['id'])

        return force_pagination(query)
    return crud(request.method,
                None if request.method == 'GET' else request.json,
                refbooks.SpecialityModel,
                current_user)
コード例 #5
0
def user(current_user):
    if request.method == 'GET':
        if 'admin' in get_user_rights(current_user):
            query = other.UserModel.query
        else:
            query = other.UserModel.query.filter_by(
                organisationId=current_user.organisationId)

        if request.values.get('user_name', None) is not None:
            query = query.filter(
                other.UserModel.login.like('%s%%' %
                                           request.values['user_name']))
        if request.values.get('user_id', None) is not None:
            query = query.filter(
                other.UserModel.id == request.values['user_id'])

        return force_pagination(query)
    return crud(request.method, request.json, other.UserModel, current_user)
コード例 #6
0
def group(current_user: other.UserModel):
    if request.method == 'GET':
        query = other.GroupModel.query
        if not has_any_right(current_user, ['admin']):
            query = query.filter(other.GroupModel.level <= current_user.level)
        if not has_any_right(current_user, ['admin', 'Groups']):
            query = query.filter(
                other.GroupModel.id.in_([g.id
                                         for g in current_user.groupList]))

        if request.values.get('group_name', None) is not None:
            query = query.filter(
                other.GroupModel.name.like('%s%%' %
                                           request.values['group_name']))
        if request.values.get('group_id', None) is not None:
            query = query.filter(
                other.GroupModel.id == request.values['group_id'])

        return force_pagination(query)
    return crud(request.method, request.json, other.GroupModel, current_user)
コード例 #7
0
def log(current_user):
    query = (other.LoggerModel.query.outerjoin(
        other.LoggerModel.user).outerjoin(OrganisationModel))
    return force_pagination(query)