Skip to content

Commit ebd51f1

Browse files
authored
allow mutiple station for same location (#9030)
1 parent 2cb4977 commit ebd51f1

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

app/api/station.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from flask_rest_jsonapi.exceptions import ObjectNotFound
33

44
from app.api.helpers.db import safe_query_kwargs
5-
from app.api.helpers.errors import UnprocessableEntityError
65
from app.api.helpers.permission_manager import has_access
76
from app.api.helpers.permissions import jwt_required
87
from app.api.helpers.utilities import require_relationship
@@ -69,21 +68,6 @@ def before_patch(args, kwargs, data):
6968
{'parameter': 'microlocation'},
7069
"Microlocation: microlocation_id is missing from your request.",
7170
)
72-
station = Station.query.filter_by(
73-
station_type=data.get('station_type'),
74-
microlocation_id=data.get('microlocation'),
75-
event_id=data.get('event'),
76-
).first()
77-
if station:
78-
raise UnprocessableEntityError(
79-
{
80-
'station_type': data.get('station_type'),
81-
'microlocation_id': data.get('microlocation'),
82-
'event_id': data.get('event'),
83-
},
84-
"A Station already exists for the provided Event ID"
85-
", Microlocation ID and Station type",
86-
)
8771

8872
schema = StationSchema
8973
data_layer = {
@@ -129,39 +113,11 @@ def before_post(args, kwargs, data):
129113
"Microlocation: missing from your request.",
130114
)
131115

132-
def before_create_object(self, data, view_kwargs):
133-
"""
134-
function to check if station already exist
135-
@param data:
136-
@param view_kwargs:
137-
"""
138-
station = (
139-
self.session.query(Station)
140-
.filter_by(
141-
station_type=data.get('station_type'),
142-
microlocation_id=data.get('microlocation'),
143-
event_id=data.get('event'),
144-
)
145-
.first()
146-
)
147-
if station:
148-
raise UnprocessableEntityError(
149-
{
150-
'station_type': data.get('station_type'),
151-
'microlocation_id': data.get('microlocation'),
152-
'event_id': data.get('event'),
153-
'view_kwargs': view_kwargs,
154-
},
155-
"A Station already exists for the provided Event ID"
156-
", Microlocation ID and Station type",
157-
)
158-
159116
schema = StationSchema
160117
methods = [
161118
'POST',
162119
]
163120
data_layer = {
164121
'session': db.session,
165122
'model': Station,
166-
'methods': {'before_create_object': before_create_object},
167123
}

0 commit comments

Comments
 (0)