|
1 | 1 | from faker import Faker |
| 2 | +from flask import request |
2 | 3 | from flask_restplus import Namespace, Resource, fields |
3 | 4 | from flask_restplus._http import HTTPStatus |
4 | 5 |
|
5 | | -from time_tracker_api.api import common_fields, UUID_REGEX |
| 6 | +from time_tracker_api.api import common_fields, create_attributes_filter |
6 | 7 | from time_tracker_api.project_types.project_types_model import create_dao |
| 8 | +from time_tracker_api.security import UUID_REGEX |
7 | 9 |
|
8 | 10 | faker = Faker() |
9 | 11 |
|
|
16 | 18 | required=True, |
17 | 19 | max_length=50, |
18 | 20 | description='Name of the project type', |
19 | | - example=faker.random_element(["Customer","Training","Internal"]), |
| 21 | + example=faker.random_element(["Customer", "Training", "Internal"]), |
20 | 22 | ), |
21 | 23 | 'description': fields.String( |
22 | 24 | title='Description', |
|
53 | 55 |
|
54 | 56 | project_type_dao = create_dao() |
55 | 57 |
|
| 58 | +attributes_filter = create_attributes_filter(ns, project_type, [ |
| 59 | + "customer_id", |
| 60 | + "parent_id", |
| 61 | +]) |
| 62 | + |
56 | 63 |
|
57 | 64 | @ns.route('') |
58 | 65 | class ProjectTypes(Resource): |
59 | 66 | @ns.doc('list_project_types') |
| 67 | + @ns.expect(attributes_filter) |
60 | 68 | @ns.marshal_list_with(project_type) |
61 | 69 | def get(self): |
62 | 70 | """List all project types""" |
63 | | - return project_type_dao.get_all() |
| 71 | + conditions = attributes_filter.parse_args() |
| 72 | + return project_type_dao.get_all(conditions=conditions) |
64 | 73 |
|
65 | 74 | @ns.doc('create_project_type') |
66 | 75 | @ns.response(HTTPStatus.CONFLICT, 'This project type already exists') |
|
0 commit comments