We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Use identifier instead of id to send order receipts
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
Currently, the endpoint to send order receipts uses order ids, but purchasers do not know about order ids, instead they know of order identifiers. Thus, it's more appropriate to use order identifiers instead of ids in that endpoint.

**Describe the solution you'd like**
Use order identifiers instead of order endpoints.

--- 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/attendees.py`
Content:
```
1 from flask import Blueprint, request, jsonify, abort, make_response
2 from flask_jwt import current_identity, jwt_required
3 from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship
4 from flask_rest_jsonapi.exceptions import ObjectNotFound
5 from sqlalchemy.orm.exc import NoResultFound
6 
7 from app.api.bootstrap import api
8 from app.api.helpers.db import safe_query, get_count
9 from app.api.helpers.exceptions import (
10     ConflictException,
11     ForbiddenException,
12     UnprocessableEntity,
13 )
14 from app.api.helpers.mail import send_email_to_attendees
15 from app.api.helpers.permission_manager import has_access
16 from app.api.helpers.permissions import jwt_required
17 from app.api.helpers.query import event_query
18 from app.api.helpers.utilities import require_relationship
19 from app.api.schema.attendees import AttendeeSchema
20 from app.models import db
21 from app.models.order import Order
22 from app.models.ticket import Ticket
23 from app.models.ticket_holder import TicketHolder
24 from app.models.user import User
25 
26 attendee_misc_routes = Blueprint('attendee_misc', __name__, url_prefix='/v1')
27 
28 class AttendeeListPost(ResourceList):
29     """
30        List and create Attendees through direct URL
31     """
32 
33     def before_post(self, args, kwargs, data):
34         """
35         Before post method to check for required relationship and proper permissions
36         :param args:
37         :param kwargs:
38         :param data:
39         :return:
40         """
41         require_relationship(['ticket', 'event'], data)
42 
43         ticket = db.session.query(Ticket).filter_by(
44             id=int(data['ticket']), deleted_at=None
45             ).first()
46         if ticket is None:
47             raise UnprocessableEntity(
48                 {'pointer': '/data/relationships/ticket'}, "Invalid Ticket"
49                 )
50         if ticket.event_id != int(data['event']):
51             raise UnprocessableEntity(
52                 {'pointer': '/data/relationships/ticket'},
53                 "Ticket belongs to a different Event"
54             )
55         # Check if the ticket is already sold out or not.
56         if get_count(db.session.query(TicketHolder.id).
57                      filter_by(ticket_id=int(data['ticket']), deleted_at=None)) >= ticket.quantity:
58             raise ConflictException(
59                 {'pointer': '/data/attributes/ticket_id'},
60                 "Ticket already sold out"
61             )
62 
63     decorators = (jwt_required,)
64     methods = ['POST']
65     schema = AttendeeSchema
66     data_layer = {'session': db.session,
67                   'model': TicketHolder}
68 
69 
70 class AttendeeList(ResourceList):
71     """
72     List Attendees
73     """
74     def query(self, view_kwargs):
75         """
76         query method for Attendees List
77         :param view_kwargs:
78         :return:
79         """
80         query_ = self.session.query(TicketHolder)
81 
82         if view_kwargs.get('order_identifier'):
83             order = safe_query(self, Order, 'identifier', view_kwargs['order_identifier'], 'order_identifier')
84             if not has_access('is_registrar', event_id=order.event_id) and not has_access('is_user_itself',
85                                                                                          user_id=order.user_id):
86                 raise ForbiddenException({'source': ''}, 'Access Forbidden')
87             query_ = query_.join(Order).filter(Order.id == order.id)
88 
89         if view_kwargs.get('ticket_id'):
90             ticket = safe_query(self, Ticket, 'id', view_kwargs['ticket_id'], 'ticket_id')
91             if not has_access('is_registrar', event_id=ticket.event_id):
92                 raise ForbiddenException({'source': ''}, 'Access Forbidden')
93             query_ = query_.join(Ticket).filter(Ticket.id == ticket.id)
94 
95         if view_kwargs.get('user_id'):
96             user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')
97             if not has_access('is_user_itself', user_id=user.id):
98                 raise ForbiddenException({'source': ''}, 'Access Forbidden')
99             query_ = query_.join(User, User.email == TicketHolder.email).filter(User.id == user.id)
100 
101         query_ = event_query(self, query_, view_kwargs, permission='is_registrar')
102         return query_
103 
104     view_kwargs = True
105     methods = ['GET', ]
106     schema = AttendeeSchema
107     data_layer = {'session': db.session,
108                   'model': TicketHolder,
109                   'methods': {
110                       'query': query
111                   }}
112 
113 
114 class AttendeeDetail(ResourceDetail):
115     """
116     Attendee detail by id
117     """
118     def before_get_object(self, view_kwargs):
119         """
120         before get object method for attendee detail
121         :param view_kwargs:
122         :return:
123         """
124         attendee = safe_query(self, TicketHolder, 'id', view_kwargs['id'], 'attendee_id')
125         if not has_access('is_registrar_or_user_itself', user_id=current_identity.id, event_id=attendee.event_id):
126             raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')
127 
128     def before_delete_object(self, obj, kwargs):
129         """
130         before delete object method for attendee detail
131         :param obj:
132         :param kwargs:
133         :return:
134         """
135         if not has_access('is_registrar', event_id=obj.event_id):
136             raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')
137 
138     def before_update_object(self, obj, data, kwargs):
139         """
140         before update object method for attendee detail
141         :param obj:
142         :param data:
143         :param kwargs:
144         :return:
145         """
146         if not has_access('is_registrar', event_id=obj.event_id):
147             raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')
148 
149         if 'is_checked_in' in data and data['is_checked_in']:
150             if 'checkin_times' not in data:
151                 raise UnprocessableEntity({'pointer': '/data/attributes/checkin_times'},
152                                           "Check in time missing while trying to check in attendee")
153             else:
154                 if obj.checkin_times and data['checkin_times'] not in obj.checkin_times.split(","):
155                     data['checkin_times'] = '{},{}'.format(obj.checkin_times, data['checkin_times'])
156 
157         if 'attendee_notes' in data:
158             if obj.attendee_notes and data['attendee_notes'] not in obj.attendee_notes.split(","):
159                 data['attendee_notes'] = '{},{}'.format(obj.attendee_notes, data['attendee_notes'])
160 
161     decorators = (jwt_required,)
162     schema = AttendeeSchema
163     data_layer = {'session': db.session,
164                   'model': TicketHolder,
165                   'methods': {
166                       'before_get_object': before_get_object,
167                       'before_update_object': before_update_object,
168                       'before_delete_object': before_delete_object
169                   }}
170 
171 
172 class AttendeeRelationshipRequired(ResourceRelationship):
173     """
174     Attendee Relationship (Required)
175     """
176     decorators = (jwt_required,)
177     methods = ['GET', 'PATCH']
178     schema = AttendeeSchema
179     data_layer = {'session': db.session,
180                   'model': TicketHolder}
181 
182 
183 class AttendeeRelationshipOptional(ResourceRelationship):
184     """
185     Attendee Relationship(Optional)
186     """
187     decorators = (api.has_permission('is_user_itself', fetch="user_id", fetch_as="id", model=TicketHolder),)
188     schema = AttendeeSchema
189     data_layer = {'session': db.session,
190                   'model': TicketHolder}
191 
192 
193 @attendee_misc_routes.route('/attendees/send-receipt', methods=['POST'])
194 @jwt_required
195 def send_receipt():
196     order_id = request.json.get('order-id')
197     if order_id:
198         try:
199             order = db.session.query(Order).filter_by(id=int(order_id)).one()
200         except NoResultFound:
201             raise ObjectNotFound({'parameter': '{id}'}, "Order not found")
202 
203         if order.user_id != current_identity.id:
204             abort(
205                 make_response(jsonify(error="You cannot send reciept for an order not created by you"), 403)
206             )
207         elif order.status != 'completed':
208             abort(
209                 make_response(jsonify(error="Cannot send receipt for an incomplete order"), 409)
210             )
211         else:
212             send_email_to_attendees(order, current_identity.id)
213             return jsonify(message="receipt sent to attendees")
214     else:
215         abort(
216             make_response(jsonify(error="Order id missing"), 422)
217         )
218
```
--- 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/attendees.py b/app/api/attendees.py
--- a/app/api/attendees.py
+++ b/app/api/attendees.py
@@ -193,12 +193,14 @@
 @attendee_misc_routes.route('/attendees/send-receipt', methods=['POST'])
 @jwt_required
 def send_receipt():
-    order_id = request.json.get('order-id')
-    if order_id:
+    # Function to send receipts to attendees related to the provided order.
+
+    order_identifier = request.json.get('order-identifier')
+    if order_identifier:
         try:
-            order = db.session.query(Order).filter_by(id=int(order_id)).one()
+            order = db.session.query(Order).filter_by(identifier=order_identifier).one()
         except NoResultFound:
-            raise ObjectNotFound({'parameter': '{id}'}, "Order not found")
+            raise ObjectNotFound({'parameter': '{identifier}'}, "Order not found")
 
         if order.user_id != current_identity.id:
             abort(
@@ -213,5 +215,5 @@
             return jsonify(message="receipt sent to attendees")
     else:
         abort(
-            make_response(jsonify(error="Order id missing"), 422)
+            make_response(jsonify(error="Order identifier missing"), 422)
         )

{"golden_diff": "diff --git a/app/api/attendees.py b/app/api/attendees.py\n--- a/app/api/attendees.py\n+++ b/app/api/attendees.py\n@@ -193,12 +193,14 @@\n @attendee_misc_routes.route('/attendees/send-receipt', methods=['POST'])\n @jwt_required\n def send_receipt():\n-    order_id = request.json.get('order-id')\n-    if order_id:\n+    # Function to send receipts to attendees related to the provided order.\n+\n+    order_identifier = request.json.get('order-identifier')\n+    if order_identifier:\n         try:\n-            order = db.session.query(Order).filter_by(id=int(order_id)).one()\n+            order = db.session.query(Order).filter_by(identifier=order_identifier).one()\n         except NoResultFound:\n-            raise ObjectNotFound({'parameter': '{id}'}, \"Order not found\")\n+            raise ObjectNotFound({'parameter': '{identifier}'}, \"Order not found\")\n \n         if order.user_id != current_identity.id:\n             abort(\n@@ -213,5 +215,5 @@\n             return jsonify(message=\"receipt sent to attendees\")\n     else:\n         abort(\n-            make_response(jsonify(error=\"Order id missing\"), 422)\n+            make_response(jsonify(error=\"Order identifier missing\"), 422)\n         )\n", "issue": "Use identifier instead of id to send order receipts\n**Is your feature request related to a problem? Please describe.**\r\n<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->\r\nCurrently, the endpoint to send order receipts uses order ids, but purchasers do not know about order ids, instead they know of order identifiers. Thus, it's more appropriate to use order identifiers instead of ids in that endpoint.\r\n\r\n**Describe the solution you'd like**\r\nUse order identifiers instead of order endpoints.\n", "before_files": [{"content": "from flask import Blueprint, request, jsonify, abort, make_response\nfrom flask_jwt import current_identity, jwt_required\nfrom flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship\nfrom flask_rest_jsonapi.exceptions import ObjectNotFound\nfrom sqlalchemy.orm.exc import NoResultFound\n\nfrom app.api.bootstrap import api\nfrom app.api.helpers.db import safe_query, get_count\nfrom app.api.helpers.exceptions import (\n    ConflictException,\n    ForbiddenException,\n    UnprocessableEntity,\n)\nfrom app.api.helpers.mail import send_email_to_attendees\nfrom app.api.helpers.permission_manager import has_access\nfrom app.api.helpers.permissions import jwt_required\nfrom app.api.helpers.query import event_query\nfrom app.api.helpers.utilities import require_relationship\nfrom app.api.schema.attendees import AttendeeSchema\nfrom app.models import db\nfrom app.models.order import Order\nfrom app.models.ticket import Ticket\nfrom app.models.ticket_holder import TicketHolder\nfrom app.models.user import User\n\nattendee_misc_routes = Blueprint('attendee_misc', __name__, url_prefix='/v1')\n\nclass AttendeeListPost(ResourceList):\n    \"\"\"\n       List and create Attendees through direct URL\n    \"\"\"\n\n    def before_post(self, args, kwargs, data):\n        \"\"\"\n        Before post method to check for required relationship and proper permissions\n        :param args:\n        :param kwargs:\n        :param data:\n        :return:\n        \"\"\"\n        require_relationship(['ticket', 'event'], data)\n\n        ticket = db.session.query(Ticket).filter_by(\n            id=int(data['ticket']), deleted_at=None\n            ).first()\n        if ticket is None:\n            raise UnprocessableEntity(\n                {'pointer': '/data/relationships/ticket'}, \"Invalid Ticket\"\n                )\n        if ticket.event_id != int(data['event']):\n            raise UnprocessableEntity(\n                {'pointer': '/data/relationships/ticket'},\n                \"Ticket belongs to a different Event\"\n            )\n        # Check if the ticket is already sold out or not.\n        if get_count(db.session.query(TicketHolder.id).\n                     filter_by(ticket_id=int(data['ticket']), deleted_at=None)) >= ticket.quantity:\n            raise ConflictException(\n                {'pointer': '/data/attributes/ticket_id'},\n                \"Ticket already sold out\"\n            )\n\n    decorators = (jwt_required,)\n    methods = ['POST']\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder}\n\n\nclass AttendeeList(ResourceList):\n    \"\"\"\n    List Attendees\n    \"\"\"\n    def query(self, view_kwargs):\n        \"\"\"\n        query method for Attendees List\n        :param view_kwargs:\n        :return:\n        \"\"\"\n        query_ = self.session.query(TicketHolder)\n\n        if view_kwargs.get('order_identifier'):\n            order = safe_query(self, Order, 'identifier', view_kwargs['order_identifier'], 'order_identifier')\n            if not has_access('is_registrar', event_id=order.event_id) and not has_access('is_user_itself',\n                                                                                         user_id=order.user_id):\n                raise ForbiddenException({'source': ''}, 'Access Forbidden')\n            query_ = query_.join(Order).filter(Order.id == order.id)\n\n        if view_kwargs.get('ticket_id'):\n            ticket = safe_query(self, Ticket, 'id', view_kwargs['ticket_id'], 'ticket_id')\n            if not has_access('is_registrar', event_id=ticket.event_id):\n                raise ForbiddenException({'source': ''}, 'Access Forbidden')\n            query_ = query_.join(Ticket).filter(Ticket.id == ticket.id)\n\n        if view_kwargs.get('user_id'):\n            user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')\n            if not has_access('is_user_itself', user_id=user.id):\n                raise ForbiddenException({'source': ''}, 'Access Forbidden')\n            query_ = query_.join(User, User.email == TicketHolder.email).filter(User.id == user.id)\n\n        query_ = event_query(self, query_, view_kwargs, permission='is_registrar')\n        return query_\n\n    view_kwargs = True\n    methods = ['GET', ]\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder,\n                  'methods': {\n                      'query': query\n                  }}\n\n\nclass AttendeeDetail(ResourceDetail):\n    \"\"\"\n    Attendee detail by id\n    \"\"\"\n    def before_get_object(self, view_kwargs):\n        \"\"\"\n        before get object method for attendee detail\n        :param view_kwargs:\n        :return:\n        \"\"\"\n        attendee = safe_query(self, TicketHolder, 'id', view_kwargs['id'], 'attendee_id')\n        if not has_access('is_registrar_or_user_itself', user_id=current_identity.id, event_id=attendee.event_id):\n            raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')\n\n    def before_delete_object(self, obj, kwargs):\n        \"\"\"\n        before delete object method for attendee detail\n        :param obj:\n        :param kwargs:\n        :return:\n        \"\"\"\n        if not has_access('is_registrar', event_id=obj.event_id):\n            raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')\n\n    def before_update_object(self, obj, data, kwargs):\n        \"\"\"\n        before update object method for attendee detail\n        :param obj:\n        :param data:\n        :param kwargs:\n        :return:\n        \"\"\"\n        if not has_access('is_registrar', event_id=obj.event_id):\n            raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')\n\n        if 'is_checked_in' in data and data['is_checked_in']:\n            if 'checkin_times' not in data:\n                raise UnprocessableEntity({'pointer': '/data/attributes/checkin_times'},\n                                          \"Check in time missing while trying to check in attendee\")\n            else:\n                if obj.checkin_times and data['checkin_times'] not in obj.checkin_times.split(\",\"):\n                    data['checkin_times'] = '{},{}'.format(obj.checkin_times, data['checkin_times'])\n\n        if 'attendee_notes' in data:\n            if obj.attendee_notes and data['attendee_notes'] not in obj.attendee_notes.split(\",\"):\n                data['attendee_notes'] = '{},{}'.format(obj.attendee_notes, data['attendee_notes'])\n\n    decorators = (jwt_required,)\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder,\n                  'methods': {\n                      'before_get_object': before_get_object,\n                      'before_update_object': before_update_object,\n                      'before_delete_object': before_delete_object\n                  }}\n\n\nclass AttendeeRelationshipRequired(ResourceRelationship):\n    \"\"\"\n    Attendee Relationship (Required)\n    \"\"\"\n    decorators = (jwt_required,)\n    methods = ['GET', 'PATCH']\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder}\n\n\nclass AttendeeRelationshipOptional(ResourceRelationship):\n    \"\"\"\n    Attendee Relationship(Optional)\n    \"\"\"\n    decorators = (api.has_permission('is_user_itself', fetch=\"user_id\", fetch_as=\"id\", model=TicketHolder),)\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder}\n\n\n@attendee_misc_routes.route('/attendees/send-receipt', methods=['POST'])\n@jwt_required\ndef send_receipt():\n    order_id = request.json.get('order-id')\n    if order_id:\n        try:\n            order = db.session.query(Order).filter_by(id=int(order_id)).one()\n        except NoResultFound:\n            raise ObjectNotFound({'parameter': '{id}'}, \"Order not found\")\n\n        if order.user_id != current_identity.id:\n            abort(\n                make_response(jsonify(error=\"You cannot send reciept for an order not created by you\"), 403)\n            )\n        elif order.status != 'completed':\n            abort(\n                make_response(jsonify(error=\"Cannot send receipt for an incomplete order\"), 409)\n            )\n        else:\n            send_email_to_attendees(order, current_identity.id)\n            return jsonify(message=\"receipt sent to attendees\")\n    else:\n        abort(\n            make_response(jsonify(error=\"Order id missing\"), 422)\n        )\n", "path": "app/api/attendees.py"}], "after_files": [{"content": "from flask import Blueprint, request, jsonify, abort, make_response\nfrom flask_jwt import current_identity, jwt_required\nfrom flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship\nfrom flask_rest_jsonapi.exceptions import ObjectNotFound\nfrom sqlalchemy.orm.exc import NoResultFound\n\nfrom app.api.bootstrap import api\nfrom app.api.helpers.db import safe_query, get_count\nfrom app.api.helpers.exceptions import (\n    ConflictException,\n    ForbiddenException,\n    UnprocessableEntity,\n)\nfrom app.api.helpers.mail import send_email_to_attendees\nfrom app.api.helpers.permission_manager import has_access\nfrom app.api.helpers.permissions import jwt_required\nfrom app.api.helpers.query import event_query\nfrom app.api.helpers.utilities import require_relationship\nfrom app.api.schema.attendees import AttendeeSchema\nfrom app.models import db\nfrom app.models.order import Order\nfrom app.models.ticket import Ticket\nfrom app.models.ticket_holder import TicketHolder\nfrom app.models.user import User\n\nattendee_misc_routes = Blueprint('attendee_misc', __name__, url_prefix='/v1')\n\nclass AttendeeListPost(ResourceList):\n    \"\"\"\n       List and create Attendees through direct URL\n    \"\"\"\n\n    def before_post(self, args, kwargs, data):\n        \"\"\"\n        Before post method to check for required relationship and proper permissions\n        :param args:\n        :param kwargs:\n        :param data:\n        :return:\n        \"\"\"\n        require_relationship(['ticket', 'event'], data)\n\n        ticket = db.session.query(Ticket).filter_by(\n            id=int(data['ticket']), deleted_at=None\n            ).first()\n        if ticket is None:\n            raise UnprocessableEntity(\n                {'pointer': '/data/relationships/ticket'}, \"Invalid Ticket\"\n                )\n        if ticket.event_id != int(data['event']):\n            raise UnprocessableEntity(\n                {'pointer': '/data/relationships/ticket'},\n                \"Ticket belongs to a different Event\"\n            )\n        # Check if the ticket is already sold out or not.\n        if get_count(db.session.query(TicketHolder.id).\n                     filter_by(ticket_id=int(data['ticket']), deleted_at=None)) >= ticket.quantity:\n            raise ConflictException(\n                {'pointer': '/data/attributes/ticket_id'},\n                \"Ticket already sold out\"\n            )\n\n    decorators = (jwt_required,)\n    methods = ['POST']\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder}\n\n\nclass AttendeeList(ResourceList):\n    \"\"\"\n    List Attendees\n    \"\"\"\n    def query(self, view_kwargs):\n        \"\"\"\n        query method for Attendees List\n        :param view_kwargs:\n        :return:\n        \"\"\"\n        query_ = self.session.query(TicketHolder)\n\n        if view_kwargs.get('order_identifier'):\n            order = safe_query(self, Order, 'identifier', view_kwargs['order_identifier'], 'order_identifier')\n            if not has_access('is_registrar', event_id=order.event_id) and not has_access('is_user_itself',\n                                                                                         user_id=order.user_id):\n                raise ForbiddenException({'source': ''}, 'Access Forbidden')\n            query_ = query_.join(Order).filter(Order.id == order.id)\n\n        if view_kwargs.get('ticket_id'):\n            ticket = safe_query(self, Ticket, 'id', view_kwargs['ticket_id'], 'ticket_id')\n            if not has_access('is_registrar', event_id=ticket.event_id):\n                raise ForbiddenException({'source': ''}, 'Access Forbidden')\n            query_ = query_.join(Ticket).filter(Ticket.id == ticket.id)\n\n        if view_kwargs.get('user_id'):\n            user = safe_query(self, User, 'id', view_kwargs['user_id'], 'user_id')\n            if not has_access('is_user_itself', user_id=user.id):\n                raise ForbiddenException({'source': ''}, 'Access Forbidden')\n            query_ = query_.join(User, User.email == TicketHolder.email).filter(User.id == user.id)\n\n        query_ = event_query(self, query_, view_kwargs, permission='is_registrar')\n        return query_\n\n    view_kwargs = True\n    methods = ['GET', ]\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder,\n                  'methods': {\n                      'query': query\n                  }}\n\n\nclass AttendeeDetail(ResourceDetail):\n    \"\"\"\n    Attendee detail by id\n    \"\"\"\n    def before_get_object(self, view_kwargs):\n        \"\"\"\n        before get object method for attendee detail\n        :param view_kwargs:\n        :return:\n        \"\"\"\n        attendee = safe_query(self, TicketHolder, 'id', view_kwargs['id'], 'attendee_id')\n        if not has_access('is_registrar_or_user_itself', user_id=current_identity.id, event_id=attendee.event_id):\n            raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')\n\n    def before_delete_object(self, obj, kwargs):\n        \"\"\"\n        before delete object method for attendee detail\n        :param obj:\n        :param kwargs:\n        :return:\n        \"\"\"\n        if not has_access('is_registrar', event_id=obj.event_id):\n            raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')\n\n    def before_update_object(self, obj, data, kwargs):\n        \"\"\"\n        before update object method for attendee detail\n        :param obj:\n        :param data:\n        :param kwargs:\n        :return:\n        \"\"\"\n        if not has_access('is_registrar', event_id=obj.event_id):\n            raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')\n\n        if 'is_checked_in' in data and data['is_checked_in']:\n            if 'checkin_times' not in data:\n                raise UnprocessableEntity({'pointer': '/data/attributes/checkin_times'},\n                                          \"Check in time missing while trying to check in attendee\")\n            else:\n                if obj.checkin_times and data['checkin_times'] not in obj.checkin_times.split(\",\"):\n                    data['checkin_times'] = '{},{}'.format(obj.checkin_times, data['checkin_times'])\n\n        if 'attendee_notes' in data:\n            if obj.attendee_notes and data['attendee_notes'] not in obj.attendee_notes.split(\",\"):\n                data['attendee_notes'] = '{},{}'.format(obj.attendee_notes, data['attendee_notes'])\n\n    decorators = (jwt_required,)\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder,\n                  'methods': {\n                      'before_get_object': before_get_object,\n                      'before_update_object': before_update_object,\n                      'before_delete_object': before_delete_object\n                  }}\n\n\nclass AttendeeRelationshipRequired(ResourceRelationship):\n    \"\"\"\n    Attendee Relationship (Required)\n    \"\"\"\n    decorators = (jwt_required,)\n    methods = ['GET', 'PATCH']\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder}\n\n\nclass AttendeeRelationshipOptional(ResourceRelationship):\n    \"\"\"\n    Attendee Relationship(Optional)\n    \"\"\"\n    decorators = (api.has_permission('is_user_itself', fetch=\"user_id\", fetch_as=\"id\", model=TicketHolder),)\n    schema = AttendeeSchema\n    data_layer = {'session': db.session,\n                  'model': TicketHolder}\n\n\n@attendee_misc_routes.route('/attendees/send-receipt', methods=['POST'])\n@jwt_required\ndef send_receipt():\n    # Function to send receipts to attendees related to the provided order.\n\n    order_identifier = request.json.get('order-identifier')\n    if order_identifier:\n        try:\n            order = db.session.query(Order).filter_by(identifier=order_identifier).one()\n        except NoResultFound:\n            raise ObjectNotFound({'parameter': '{identifier}'}, \"Order not found\")\n\n        if order.user_id != current_identity.id:\n            abort(\n                make_response(jsonify(error=\"You cannot send reciept for an order not created by you\"), 403)\n            )\n        elif order.status != 'completed':\n            abort(\n                make_response(jsonify(error=\"Cannot send receipt for an incomplete order\"), 409)\n            )\n        else:\n            send_email_to_attendees(order, current_identity.id)\n            return jsonify(message=\"receipt sent to attendees\")\n    else:\n        abort(\n            make_response(jsonify(error=\"Order identifier missing\"), 422)\n        )\n", "path": "app/api/attendees.py"}]}