We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Store check in kiosk id to mark association
Allow organiser to create station name for each event

- station name
- location (based on the locations available for the venue) - if registration is selected, location can be empty
- type (registration / daily / check in / check out )

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/api/station.py`
Content:
```
1 from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship
2 from flask_rest_jsonapi.exceptions import ObjectNotFound
3 
4 from app.api.helpers.db import safe_query_kwargs
5 from app.api.helpers.errors import UnprocessableEntityError
6 from app.api.helpers.permission_manager import has_access
7 from app.api.helpers.permissions import jwt_required
8 from app.api.helpers.utilities import require_relationship
9 from app.api.schema.station import StationSchema
10 from app.models import db
11 from app.models.event import Event
12 from app.models.microlocation import Microlocation
13 from app.models.station import Station
14 
15 
16 class StationList(ResourceList):
17     """Create and List Station"""
18 
19     def query(self, view_kwargs):
20         """
21         query method for different view_kwargs
22         :param view_kwargs:
23         :return:
24         """
25         query_ = self.session.query(Station)
26         if view_kwargs.get('event_id'):
27             event = safe_query_kwargs(Event, view_kwargs, 'event_id')
28             query_ = query_.filter_by(event_id=event.id)
29 
30         elif view_kwargs.get('microlocation_id'):
31             event = safe_query_kwargs(Microlocation, view_kwargs, 'microlocation_id')
32             query_ = query_.filter_by(microlocation_id=event.id)
33 
34         return query_
35 
36     view_kwargs = True
37     schema = StationSchema
38     data_layer = {
39         'session': db.session,
40         'model': Station,
41         'methods': {'query': query},
42     }
43 
44 
45 class StationDetail(ResourceDetail):
46     """Station detail by id"""
47 
48     @staticmethod
49     def before_patch(args, kwargs, data):
50         """
51         before patch method
52         :param args:
53         :param kwargs:
54         :param data:
55         :return:
56         """
57         require_relationship(['event'], data)
58         if not has_access('is_coorganizer', event_id=data['event']):
59             raise ObjectNotFound(
60                 {'parameter': 'event'},
61                 f"Event: {data['event']} not found {args} {kwargs}",
62             )
63 
64         if data.get('microlocation'):
65             require_relationship(['microlocation'], data)
66         else:
67             if data['station_type'] in ('check in', 'check out', 'daily'):
68                 raise ObjectNotFound(
69                     {'parameter': 'microlocation'},
70                     "Microlocation: microlocation_id is missing from your request.",
71                 )
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 
88     schema = StationSchema
89     data_layer = {
90         'session': db.session,
91         'model': Station,
92     }
93 
94 
95 class StationRelationship(ResourceRelationship):
96     """Station Relationship (Required)"""
97 
98     decorators = (jwt_required,)
99     methods = ['GET', 'PATCH']
100     schema = StationSchema
101     data_layer = {'session': db.session, 'model': Station}
102 
103 
104 class StationListPost(ResourceList):
105     """Create and List Station"""
106 
107     @staticmethod
108     def before_post(args, kwargs, data):
109         """
110         method to check for required relationship with event and microlocation
111         :param data:
112         :param args:
113         :param kwargs:
114         :return:
115         """
116         require_relationship(['event'], data)
117         if not has_access('is_coorganizer', event_id=data['event']):
118             raise ObjectNotFound(
119                 {'parameter': 'event'},
120                 f"Event: {data['event']} not found {args} {kwargs}",
121             )
122 
123         if data.get('microlocation'):
124             require_relationship(['microlocation'], data)
125         else:
126             if data['station_type'] in ('check in', 'check out', 'daily'):
127                 raise ObjectNotFound(
128                     {'parameter': 'microlocation'},
129                     "Microlocation: missing from your request.",
130                 )
131 
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     schema = StationSchema
160     methods = [
161         'POST',
162     ]
163     data_layer = {
164         'session': db.session,
165         'model': Station,
166         'methods': {'before_create_object': before_create_object},
167     }
168
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/app/api/station.py b/app/api/station.py
--- a/app/api/station.py
+++ b/app/api/station.py
@@ -2,7 +2,6 @@
 from flask_rest_jsonapi.exceptions import ObjectNotFound
 
 from app.api.helpers.db import safe_query_kwargs
-from app.api.helpers.errors import UnprocessableEntityError
 from app.api.helpers.permission_manager import has_access
 from app.api.helpers.permissions import jwt_required
 from app.api.helpers.utilities import require_relationship
@@ -69,21 +68,6 @@
                     {'parameter': 'microlocation'},
                     "Microlocation: microlocation_id is missing from your request.",
                 )
-        station = Station.query.filter_by(
-            station_type=data.get('station_type'),
-            microlocation_id=data.get('microlocation'),
-            event_id=data.get('event'),
-        ).first()
-        if station:
-            raise UnprocessableEntityError(
-                {
-                    'station_type': data.get('station_type'),
-                    'microlocation_id': data.get('microlocation'),
-                    'event_id': data.get('event'),
-                },
-                "A Station already exists for the provided Event ID"
-                ", Microlocation ID and Station type",
-            )
 
     schema = StationSchema
     data_layer = {
@@ -129,33 +113,6 @@
                     "Microlocation: missing from your request.",
                 )
 
-    def before_create_object(self, data, view_kwargs):
-        """
-        function to check if station already exist
-        @param data:
-        @param view_kwargs:
-        """
-        station = (
-            self.session.query(Station)
-            .filter_by(
-                station_type=data.get('station_type'),
-                microlocation_id=data.get('microlocation'),
-                event_id=data.get('event'),
-            )
-            .first()
-        )
-        if station:
-            raise UnprocessableEntityError(
-                {
-                    'station_type': data.get('station_type'),
-                    'microlocation_id': data.get('microlocation'),
-                    'event_id': data.get('event'),
-                    'view_kwargs': view_kwargs,
-                },
-                "A Station already exists for the provided Event ID"
-                ", Microlocation ID and Station type",
-            )
-
     schema = StationSchema
     methods = [
         'POST',
@@ -163,5 +120,4 @@
     data_layer = {
         'session': db.session,
         'model': Station,
-        'methods': {'before_create_object': before_create_object},
     }

{"golden_diff": "diff --git a/app/api/station.py b/app/api/station.py\n--- a/app/api/station.py\n+++ b/app/api/station.py\n@@ -2,7 +2,6 @@\n from flask_rest_jsonapi.exceptions import ObjectNotFound\n \n from app.api.helpers.db import safe_query_kwargs\n-from app.api.helpers.errors import UnprocessableEntityError\n from app.api.helpers.permission_manager import has_access\n from app.api.helpers.permissions import jwt_required\n from app.api.helpers.utilities import require_relationship\n@@ -69,21 +68,6 @@\n                     {'parameter': 'microlocation'},\n                     \"Microlocation: microlocation_id is missing from your request.\",\n                 )\n-        station = Station.query.filter_by(\n-            station_type=data.get('station_type'),\n-            microlocation_id=data.get('microlocation'),\n-            event_id=data.get('event'),\n-        ).first()\n-        if station:\n-            raise UnprocessableEntityError(\n-                {\n-                    'station_type': data.get('station_type'),\n-                    'microlocation_id': data.get('microlocation'),\n-                    'event_id': data.get('event'),\n-                },\n-                \"A Station already exists for the provided Event ID\"\n-                \", Microlocation ID and Station type\",\n-            )\n \n     schema = StationSchema\n     data_layer = {\n@@ -129,33 +113,6 @@\n                     \"Microlocation: missing from your request.\",\n                 )\n \n-    def before_create_object(self, data, view_kwargs):\n-        \"\"\"\n-        function to check if station already exist\n-        @param data:\n-        @param view_kwargs:\n-        \"\"\"\n-        station = (\n-            self.session.query(Station)\n-            .filter_by(\n-                station_type=data.get('station_type'),\n-                microlocation_id=data.get('microlocation'),\n-                event_id=data.get('event'),\n-            )\n-            .first()\n-        )\n-        if station:\n-            raise UnprocessableEntityError(\n-                {\n-                    'station_type': data.get('station_type'),\n-                    'microlocation_id': data.get('microlocation'),\n-                    'event_id': data.get('event'),\n-                    'view_kwargs': view_kwargs,\n-                },\n-                \"A Station already exists for the provided Event ID\"\n-                \", Microlocation ID and Station type\",\n-            )\n-\n     schema = StationSchema\n     methods = [\n         'POST',\n@@ -163,5 +120,4 @@\n     data_layer = {\n         'session': db.session,\n         'model': Station,\n-        'methods': {'before_create_object': before_create_object},\n     }\n", "issue": "Store check in kiosk id to mark association\nAllow organiser to create station name for each event\r\n\r\n- station name\r\n- location (based on the locations available for the venue) - if registration is selected, location can be empty\r\n- type (registration / daily / check in / check out )\n", "before_files": [{"content": "from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship\nfrom flask_rest_jsonapi.exceptions import ObjectNotFound\n\nfrom app.api.helpers.db import safe_query_kwargs\nfrom app.api.helpers.errors import UnprocessableEntityError\nfrom app.api.helpers.permission_manager import has_access\nfrom app.api.helpers.permissions import jwt_required\nfrom app.api.helpers.utilities import require_relationship\nfrom app.api.schema.station import StationSchema\nfrom app.models import db\nfrom app.models.event import Event\nfrom app.models.microlocation import Microlocation\nfrom app.models.station import Station\n\n\nclass StationList(ResourceList):\n    \"\"\"Create and List Station\"\"\"\n\n    def query(self, view_kwargs):\n        \"\"\"\n        query method for different view_kwargs\n        :param view_kwargs:\n        :return:\n        \"\"\"\n        query_ = self.session.query(Station)\n        if view_kwargs.get('event_id'):\n            event = safe_query_kwargs(Event, view_kwargs, 'event_id')\n            query_ = query_.filter_by(event_id=event.id)\n\n        elif view_kwargs.get('microlocation_id'):\n            event = safe_query_kwargs(Microlocation, view_kwargs, 'microlocation_id')\n            query_ = query_.filter_by(microlocation_id=event.id)\n\n        return query_\n\n    view_kwargs = True\n    schema = StationSchema\n    data_layer = {\n        'session': db.session,\n        'model': Station,\n        'methods': {'query': query},\n    }\n\n\nclass StationDetail(ResourceDetail):\n    \"\"\"Station detail by id\"\"\"\n\n    @staticmethod\n    def before_patch(args, kwargs, data):\n        \"\"\"\n        before patch method\n        :param args:\n        :param kwargs:\n        :param data:\n        :return:\n        \"\"\"\n        require_relationship(['event'], data)\n        if not has_access('is_coorganizer', event_id=data['event']):\n            raise ObjectNotFound(\n                {'parameter': 'event'},\n                f\"Event: {data['event']} not found {args} {kwargs}\",\n            )\n\n        if data.get('microlocation'):\n            require_relationship(['microlocation'], data)\n        else:\n            if data['station_type'] in ('check in', 'check out', 'daily'):\n                raise ObjectNotFound(\n                    {'parameter': 'microlocation'},\n                    \"Microlocation: microlocation_id is missing from your request.\",\n                )\n        station = Station.query.filter_by(\n            station_type=data.get('station_type'),\n            microlocation_id=data.get('microlocation'),\n            event_id=data.get('event'),\n        ).first()\n        if station:\n            raise UnprocessableEntityError(\n                {\n                    'station_type': data.get('station_type'),\n                    'microlocation_id': data.get('microlocation'),\n                    'event_id': data.get('event'),\n                },\n                \"A Station already exists for the provided Event ID\"\n                \", Microlocation ID and Station type\",\n            )\n\n    schema = StationSchema\n    data_layer = {\n        'session': db.session,\n        'model': Station,\n    }\n\n\nclass StationRelationship(ResourceRelationship):\n    \"\"\"Station Relationship (Required)\"\"\"\n\n    decorators = (jwt_required,)\n    methods = ['GET', 'PATCH']\n    schema = StationSchema\n    data_layer = {'session': db.session, 'model': Station}\n\n\nclass StationListPost(ResourceList):\n    \"\"\"Create and List Station\"\"\"\n\n    @staticmethod\n    def before_post(args, kwargs, data):\n        \"\"\"\n        method to check for required relationship with event and microlocation\n        :param data:\n        :param args:\n        :param kwargs:\n        :return:\n        \"\"\"\n        require_relationship(['event'], data)\n        if not has_access('is_coorganizer', event_id=data['event']):\n            raise ObjectNotFound(\n                {'parameter': 'event'},\n                f\"Event: {data['event']} not found {args} {kwargs}\",\n            )\n\n        if data.get('microlocation'):\n            require_relationship(['microlocation'], data)\n        else:\n            if data['station_type'] in ('check in', 'check out', 'daily'):\n                raise ObjectNotFound(\n                    {'parameter': 'microlocation'},\n                    \"Microlocation: missing from your request.\",\n                )\n\n    def before_create_object(self, data, view_kwargs):\n        \"\"\"\n        function to check if station already exist\n        @param data:\n        @param view_kwargs:\n        \"\"\"\n        station = (\n            self.session.query(Station)\n            .filter_by(\n                station_type=data.get('station_type'),\n                microlocation_id=data.get('microlocation'),\n                event_id=data.get('event'),\n            )\n            .first()\n        )\n        if station:\n            raise UnprocessableEntityError(\n                {\n                    'station_type': data.get('station_type'),\n                    'microlocation_id': data.get('microlocation'),\n                    'event_id': data.get('event'),\n                    'view_kwargs': view_kwargs,\n                },\n                \"A Station already exists for the provided Event ID\"\n                \", Microlocation ID and Station type\",\n            )\n\n    schema = StationSchema\n    methods = [\n        'POST',\n    ]\n    data_layer = {\n        'session': db.session,\n        'model': Station,\n        'methods': {'before_create_object': before_create_object},\n    }\n", "path": "app/api/station.py"}], "after_files": [{"content": "from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship\nfrom flask_rest_jsonapi.exceptions import ObjectNotFound\n\nfrom app.api.helpers.db import safe_query_kwargs\nfrom app.api.helpers.permission_manager import has_access\nfrom app.api.helpers.permissions import jwt_required\nfrom app.api.helpers.utilities import require_relationship\nfrom app.api.schema.station import StationSchema\nfrom app.models import db\nfrom app.models.event import Event\nfrom app.models.microlocation import Microlocation\nfrom app.models.station import Station\n\n\nclass StationList(ResourceList):\n    \"\"\"Create and List Station\"\"\"\n\n    def query(self, view_kwargs):\n        \"\"\"\n        query method for different view_kwargs\n        :param view_kwargs:\n        :return:\n        \"\"\"\n        query_ = self.session.query(Station)\n        if view_kwargs.get('event_id'):\n            event = safe_query_kwargs(Event, view_kwargs, 'event_id')\n            query_ = query_.filter_by(event_id=event.id)\n\n        elif view_kwargs.get('microlocation_id'):\n            event = safe_query_kwargs(Microlocation, view_kwargs, 'microlocation_id')\n            query_ = query_.filter_by(microlocation_id=event.id)\n\n        return query_\n\n    view_kwargs = True\n    schema = StationSchema\n    data_layer = {\n        'session': db.session,\n        'model': Station,\n        'methods': {'query': query},\n    }\n\n\nclass StationDetail(ResourceDetail):\n    \"\"\"Station detail by id\"\"\"\n\n    @staticmethod\n    def before_patch(args, kwargs, data):\n        \"\"\"\n        before patch method\n        :param args:\n        :param kwargs:\n        :param data:\n        :return:\n        \"\"\"\n        require_relationship(['event'], data)\n        if not has_access('is_coorganizer', event_id=data['event']):\n            raise ObjectNotFound(\n                {'parameter': 'event'},\n                f\"Event: {data['event']} not found {args} {kwargs}\",\n            )\n\n        if data.get('microlocation'):\n            require_relationship(['microlocation'], data)\n        else:\n            if data['station_type'] in ('check in', 'check out', 'daily'):\n                raise ObjectNotFound(\n                    {'parameter': 'microlocation'},\n                    \"Microlocation: microlocation_id is missing from your request.\",\n                )\n\n    schema = StationSchema\n    data_layer = {\n        'session': db.session,\n        'model': Station,\n    }\n\n\nclass StationRelationship(ResourceRelationship):\n    \"\"\"Station Relationship (Required)\"\"\"\n\n    decorators = (jwt_required,)\n    methods = ['GET', 'PATCH']\n    schema = StationSchema\n    data_layer = {'session': db.session, 'model': Station}\n\n\nclass StationListPost(ResourceList):\n    \"\"\"Create and List Station\"\"\"\n\n    @staticmethod\n    def before_post(args, kwargs, data):\n        \"\"\"\n        method to check for required relationship with event and microlocation\n        :param data:\n        :param args:\n        :param kwargs:\n        :return:\n        \"\"\"\n        require_relationship(['event'], data)\n        if not has_access('is_coorganizer', event_id=data['event']):\n            raise ObjectNotFound(\n                {'parameter': 'event'},\n                f\"Event: {data['event']} not found {args} {kwargs}\",\n            )\n\n        if data.get('microlocation'):\n            require_relationship(['microlocation'], data)\n        else:\n            if data['station_type'] in ('check in', 'check out', 'daily'):\n                raise ObjectNotFound(\n                    {'parameter': 'microlocation'},\n                    \"Microlocation: missing from your request.\",\n                )\n\n    schema = StationSchema\n    methods = [\n        'POST',\n    ]\n    data_layer = {\n        'session': db.session,\n        'model': Station,\n    }\n", "path": "app/api/station.py"}]}