|
1 | 1 | from datetime import timedelta |
2 | 2 |
|
3 | 3 | from faker import Faker |
4 | | -from flask_restplus import fields, Resource, Namespace |
| 4 | +from flask_restplus import fields, Resource |
5 | 5 | from flask_restplus._http import HTTPStatus |
6 | 6 |
|
7 | 7 | from commons.data_access_layer.cosmos_db import current_datetime, datetime_str, current_datetime_str |
8 | 8 | from commons.data_access_layer.database import COMMENTS_MAX_LENGTH |
9 | | -from time_tracker_api.api import common_fields, create_attributes_filter |
10 | | -from time_tracker_api.security import UUID_REGEX |
| 9 | +from time_tracker_api.api import common_fields, create_attributes_filter, api, UUID |
11 | 10 | from time_tracker_api.time_entries.time_entries_model import create_dao |
12 | 11 |
|
13 | 12 | faker = Faker() |
14 | 13 |
|
15 | | -ns = Namespace('time-entries', description='API for time entries') |
| 14 | +ns = api.namespace('time-entries', description='Namespace of the API for time entries') |
16 | 15 |
|
17 | 16 | # TimeEntry Model |
18 | 17 | time_entry_input = ns.model('TimeEntryInput', { |
19 | | - 'project_id': fields.String( |
| 18 | + 'project_id': UUID( |
20 | 19 | title='Project', |
21 | 20 | required=True, |
22 | 21 | description='The id of the selected project', |
23 | | - pattern=UUID_REGEX, |
24 | 22 | example=faker.uuid4(), |
25 | 23 | ), |
26 | 24 | 'start_date': fields.DateTime( |
|
30 | 28 | description='When the user started doing this activity', |
31 | 29 | example=datetime_str(current_datetime() - timedelta(days=1)), |
32 | 30 | ), |
33 | | - 'activity_id': fields.String( |
| 31 | + 'activity_id': UUID( |
34 | 32 | title='Activity', |
35 | 33 | required=False, |
36 | 34 | description='The id of the selected activity', |
37 | | - pattern=UUID_REGEX, |
38 | 35 | example=faker.uuid4(), |
39 | 36 | ), |
40 | 37 | 'description': fields.String( |
|
86 | 83 | description='Whether this time entry is currently running or not', |
87 | 84 | example=faker.boolean(), |
88 | 85 | ), |
89 | | - 'owner_id': fields.String( |
| 86 | + 'owner_id': UUID( |
90 | 87 | required=True, |
91 | 88 | readOnly=True, |
92 | 89 | title='Owner of time entry', |
|
0 commit comments