|
2 | 2 | from flask_rest_jsonapi.exceptions import ObjectNotFound |
3 | 3 |
|
4 | 4 | from app.api.helpers.db import safe_query_kwargs |
5 | | -from app.api.helpers.errors import UnprocessableEntityError |
6 | 5 | from app.api.helpers.permission_manager import has_access |
7 | 6 | from app.api.helpers.permissions import jwt_required |
8 | 7 | from app.api.helpers.utilities import require_relationship |
@@ -69,21 +68,6 @@ def before_patch(args, kwargs, data): |
69 | 68 | {'parameter': 'microlocation'}, |
70 | 69 | "Microlocation: microlocation_id is missing from your request.", |
71 | 70 | ) |
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 | | - ) |
87 | 71 |
|
88 | 72 | schema = StationSchema |
89 | 73 | data_layer = { |
@@ -129,39 +113,11 @@ def before_post(args, kwargs, data): |
129 | 113 | "Microlocation: missing from your request.", |
130 | 114 | ) |
131 | 115 |
|
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 | | - |
159 | 116 | schema = StationSchema |
160 | 117 | methods = [ |
161 | 118 | 'POST', |
162 | 119 | ] |
163 | 120 | data_layer = { |
164 | 121 | 'session': db.session, |
165 | 122 | 'model': Station, |
166 | | - 'methods': {'before_create_object': before_create_object}, |
167 | 123 | } |
0 commit comments