Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: TT-430 added status string to number for update
  • Loading branch information
mandres2015 committed Nov 30, 2021
commit 457ba25aa5354674d5db0ae24b71006d718d424f
2 changes: 1 addition & 1 deletion V2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"offline": "serverless offline",
"offline": "serverless offline -a '--cors *'",
"deploy": "serverless deploy"
},
"author": "",
Expand Down
22 changes: 20 additions & 2 deletions V2/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ functions:
- GET
route: activities/{id:?}
authLevel: anonymous
cors: true

delete_activity:
handler: time_tracker/activities/interface.delete_activity
Expand All @@ -61,6 +62,7 @@ functions:
- DELETE
route: activities/{id}
authLevel: anonymous
cors: true

update_activity:
handler: time_tracker/activities/interface.update_activity
Expand All @@ -71,6 +73,7 @@ functions:
- PUT
route: activities/{id}
authLevel: anonymous
cors: true

create_activity:
handler: time_tracker/activities/interface.create_activity
Expand All @@ -81,6 +84,7 @@ functions:
- POST
route: activities/
authLevel: anonymous
cors: true

#endregion End Functions Activities

Expand All @@ -95,6 +99,7 @@ functions:
- POST
route: time-entries/
authLevel: anonymous
cors: true

get_time_entries:
handler: time_tracker/time_entries/interface.get_time_entries
Expand All @@ -105,6 +110,7 @@ functions:
- GET
route: time-entries/{id:?}
authLevel: anonymous
cors: true

delete_time_entry:
handler: time_tracker/time_entries/interface.delete_time_entry
Expand All @@ -115,6 +121,7 @@ functions:
- DELETE
route: time-entries/{id}
authLevel: anonymous
cors: true

update_time_entry:
handler: time_tracker/time_entries/interface.update_time_entry
Expand All @@ -124,7 +131,8 @@ functions:
methods:
- PUT
route: time-entries/{id}
authLevel: anonymous
authLevel: anonymous
cors: true

get_latest_time_entry:
handler: time_tracker/time_entries/interface.get_latest_entries
Expand All @@ -135,6 +143,7 @@ functions:
- GET
route: time-entries/latest/
authLevel: anonymous
cors: true

#endregion End Functions Time-Entries

Expand All @@ -149,6 +158,7 @@ functions:
- POST
route: customers/
authLevel: anonymous
cors: true

get_customers:
handler: time_tracker/customers/interface.get_customers
Expand All @@ -159,6 +169,7 @@ functions:
- GET
route: customers/{id:?}
authLevel: anonymous
cors: true

update_customer:
handler: time_tracker/customers/interface.update_customer
Expand All @@ -169,6 +180,7 @@ functions:
- PUT
route: customers/{id}
authLevel: anonymous
cors: true

delete_customer:
handler: time_tracker/customers/interface.delete_customer
Expand All @@ -179,6 +191,7 @@ functions:
- DELETE
route: customers/{id}
authLevel: anonymous
cors: true

#endregion End Functions Customers

Expand All @@ -193,6 +206,7 @@ functions:
- GET
route: projects/{id:?}
authLevel: anonymous
cors: true

delete_project:
handler: time_tracker/projects/interface.delete_project
Expand All @@ -203,6 +217,7 @@ functions:
- DELETE
route: projects/{id}
authLevel: anonymous
cors: true

update_project:
handler: time_tracker/projects/interface.update_project
Expand All @@ -212,7 +227,8 @@ functions:
methods:
- PUT
route: projects/{id}
authLevel: anonymous
authLevel: anonymous
cors: true

create_project:
handler: time_tracker/projects/interface.create_project
Expand All @@ -224,6 +240,7 @@ functions:
route: projects/

authLevel: anonymous
cors: true

get_latest_projects:
handler: time_tracker/projects/interface.get_latest_projects
Expand All @@ -234,6 +251,7 @@ functions:
- GET
route: projects/latest
authLevel: anonymous
cors: true

#endregion End Functions Projects

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ... import _infrastructure
from time_tracker._infrastructure import DB
from .utils import parse_status_to_string_for_ui as parse_status
from .utils import parse_status_to_number


def update_activity(req: func.HttpRequest) -> func.HttpResponse:
Expand Down Expand Up @@ -43,7 +44,7 @@ def _update(activity_id: int, activity_data: dict) -> str:
activity = activity_use_case.update_activity(
activity_id, activity_data.get("name"),
activity_data.get("description"),
activity_data.get("status"),
parse_status_to_number(activity_data.get("status")),
activity_data.get("deleted")
)
return json.dumps(parse_status(activity.__dict__)) if activity else b'Not Found'
Expand Down
4 changes: 4 additions & 0 deletions V2/time_tracker/activities/_application/_activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
def parse_status_to_string_for_ui(activity: dict) -> dict:
activity['status'] = StatusEnums(activity['status']).name
return activity


def parse_status_to_number(status: str) -> int:
return StatusEnums[status].value