2222
2323@login_required
2424@blueprint .route ('' , methods = ['GET' ])
25- def list_all ():
25+ def list_all_one_on_one ():
2626 return one_on_one_schema .jsonify (OneOnOne .get_by_user (current_user ), many = True )
2727
2828
2929@login_required
3030@blueprint .route ('' , methods = ['PUT' ])
31- def create ():
31+ def create_one_on_one ():
3232 if not request .is_json :
3333 return bad_request ()
3434
@@ -47,7 +47,7 @@ def create():
4747
4848@login_required
4949@blueprint .route ('/<_id>' , methods = ['GET' ])
50- def get (_id : int ):
50+ def get_one_on_one (_id : int ):
5151 one_on_one = OneOnOne .get (_id )
5252
5353 if not one_on_one :
@@ -60,44 +60,25 @@ def get(_id: int):
6060
6161
6262@login_required
63- @blueprint .route ('/<one_on_one_id>/action_items' , methods = ['GET' ])
64- def get_action_items (one_on_one_id : int ):
65- one_on_one = OneOnOne .get (one_on_one_id )
66-
67- if not one_on_one :
68- return not_found ()
69-
70- if not acl .can_view_one_on_one (one_on_one ):
71- return unauthorized ()
72-
73- return one_on_one_action_item_schema .jsonify (one_on_one .action_items , many = True )
74-
75-
76- @login_required
77- @blueprint .route ('/<one_on_one_id>/action_items/<action_item_id>' , methods = ['GET' ])
78- def get_action_item (one_on_one_id : int , action_item_id : int ):
79- one_on_one = OneOnOne .get (one_on_one_id )
63+ @blueprint .route ('/<_id>' , methods = ['DELETE' ])
64+ def delete_one_on_one (_id : int ):
65+ one_on_one = OneOnOne .get (_id )
8066
8167 if not one_on_one :
8268 return not_found ()
8369
84- if not acl .can_view_one_on_one (one_on_one ):
70+ if not acl .can_delete_one_on_one (one_on_one ):
8571 return unauthorized ()
8672
87- action_item = OneOnOneActionItem .get (action_item_id )
88-
89- if not action_item :
90- return not_found ()
91-
92- if not action_item .one_on_one_id == one_on_one .id :
93- return not_found ()
73+ with transaction ():
74+ db .session .remove (one_on_one )
9475
95- return one_on_one_action_item_schema . jsonify ( action_item )
76+ return no_content ( )
9677
9778
9879@login_required
99- @blueprint .route ('/<one_on_one_id>/action_items/<action_item_id> ' , methods = ['DELETE ' ])
100- def delete_action_item (one_on_one_id : int , action_item_id : int ):
80+ @blueprint .route ('/<one_on_one_id>/action_items' , methods = ['GET ' ])
81+ def list_action_items (one_on_one_id : int ):
10182 one_on_one = OneOnOne .get (one_on_one_id )
10283
10384 if not one_on_one :
@@ -106,18 +87,7 @@ def delete_action_item(one_on_one_id: int, action_item_id: int):
10687 if not acl .can_view_one_on_one (one_on_one ):
10788 return unauthorized ()
10889
109- action_item = OneOnOneActionItem .get (action_item_id )
110-
111- if not action_item :
112- return not_found ()
113-
114- if not action_item .one_on_one_id == one_on_one .id :
115- return not_found ()
116-
117- with transaction ():
118- db .session .remove (one_on_one )
119-
120- return no_content ()
90+ return one_on_one_action_item_schema .jsonify (one_on_one .action_items , many = True )
12191
12292
12393@login_required
@@ -148,6 +118,28 @@ def create_action_item(one_on_one_id: int):
148118 return validation_error (e .messages )
149119
150120
121+ @login_required
122+ @blueprint .route ('/<one_on_one_id>/action_items/<action_item_id>' , methods = ['GET' ])
123+ def get_action_item (one_on_one_id : int , action_item_id : int ):
124+ one_on_one = OneOnOne .get (one_on_one_id )
125+
126+ if not one_on_one :
127+ return not_found ()
128+
129+ if not acl .can_view_one_on_one (one_on_one ):
130+ return unauthorized ()
131+
132+ action_item = OneOnOneActionItem .get (action_item_id )
133+
134+ if not action_item :
135+ return not_found ()
136+
137+ if not action_item .one_on_one_id == one_on_one .id :
138+ return not_found ()
139+
140+ return one_on_one_action_item_schema .jsonify (action_item )
141+
142+
151143@login_required
152144@blueprint .route ('/<one_on_one_id>/action_items/<action_item_id>' , methods = ['PATCH' ])
153145def edit_action_item (one_on_one_id : int , action_item_id : int ):
@@ -176,16 +168,24 @@ def edit_action_item(one_on_one_id: int, action_item_id: int):
176168
177169
178170@login_required
179- @blueprint .route ('/<_id >' , methods = ['DELETE' ])
180- def delete_one_on_one ( _id : int ):
181- one_on_one = OneOnOne .get (_id )
171+ @blueprint .route ('/<one_on_one_id>/action_items/<action_item_id >' , methods = ['DELETE' ])
172+ def delete_action_item ( one_on_one_id : int , action_item_id : int ):
173+ one_on_one = OneOnOne .get (one_on_one_id )
182174
183175 if not one_on_one :
184176 return not_found ()
185177
186- if not acl .can_delete_one_on_one (one_on_one ):
178+ if not acl .can_view_one_on_one (one_on_one ):
187179 return unauthorized ()
188180
181+ action_item = OneOnOneActionItem .get (action_item_id )
182+
183+ if not action_item :
184+ return not_found ()
185+
186+ if not action_item .one_on_one_id == one_on_one .id :
187+ return not_found ()
188+
189189 with transaction ():
190190 db .session .remove (one_on_one )
191191
0 commit comments