prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Microlocations : GET requests return ERROR 500
  **I'm submitting a ...**  (check one with "x")
  - [x] bug report
  - [ ] feature request
  - [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-orga-server
  
  Endpoint 
  ```
  GET v1/events/<event_id>/microlocations 
  ```
  
  Response
  ```
  {
     "errors":[
        {
           "detail":"Unknown error",
           "source":{
              "pointer":""
           },
           "status":500,
           "title":"Unknown error"
        }
     ],
     "jsonapi":{
        "version":"1.0"
     }
  }
  ```
  
  Example URL
  ```
  https://open-event-api.herokuapp.com/v1/events/173/microlocations
  ```
  
  
  </issue>
  <code>
  [start of app/api/microlocations.py]
  1 from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship
  2 from marshmallow_jsonapi.flask import Schema, Relationship
  3 from marshmallow_jsonapi import fields
  4 
  5 from app.api.bootstrap import api
  6 from app.api.helpers.utilities import dasherize
  7 from app.models import db
  8 from app.models.microlocation import Microlocation
  9 from app.models.session import Session
  10 from app.api.helpers.db import safe_query
  11 from app.api.helpers.utilities import require_relationship
  12 from app.api.helpers.permission_manager import has_access
  13 from app.api.helpers.exceptions import ForbiddenException
  14 from app.api.helpers.query import event_query
  15 
  16 
  17 class MicrolocationSchema(Schema):
  18     """
  19     Api schema for Microlocation Model
  20     """
  21 
  22     class Meta:
  23         """
  24         Meta class for Microlocation Api Schema
  25         """
  26         type_ = 'microlocation'
  27         self_view = 'v1.microlocation_detail'
  28         self_view_kwargs = {'id': '<id>'}
  29         self_view_many = 'v1.session_list'
  30         inflect = dasherize
  31 
  32     id = fields.Str(dump_only=True)
  33     name = fields.Str(required=True)
  34     latitude = fields.Float(validate=lambda n: -90 <= n <= 90, allow_none=True)
  35     longitude = fields.Float(validate=lambda n: -180 <= n <= 180, allow_none=True)
  36     floor = fields.Integer(allow_none=True)
  37     room = fields.Str(allow_none=True)
  38     sessions = Relationship(attribute='session',
  39                             self_view='v1.microlocation_session',
  40                             self_view_kwargs={'id': '<id>'},
  41                             related_view='v1.session_list',
  42                             related_view_kwargs={'microlocation_id': '<id>'},
  43                             schema='SessionSchema',
  44                             type_='session')
  45     event = Relationship(attribute='event',
  46                          self_view='v1.microlocation_event',
  47                          self_view_kwargs={'id': '<id>'},
  48                          related_view='v1.event_detail',
  49                          related_view_kwargs={'microlocation_id': '<id>'},
  50                          schema='EventSchema',
  51                          type_='event')
  52 
  53 
  54 class MicrolocationListPost(ResourceList):
  55     """
  56     List and create microlocations
  57     """
  58     def before_post(self, args, kwargs, data):
  59         require_relationship(['event'], data)
  60         if not has_access('is_coorganizer', event_id=data['event']):
  61             raise ForbiddenException({'source': ''}, 'Co-organizer access is required.')
  62 
  63     methods = ['POST', ]
  64     schema = MicrolocationSchema
  65     data_layer = {'session': db.session,
  66                   'model': Microlocation}
  67 
  68 
  69 class MicrolocationList(ResourceList):
  70     """
  71     List Microlocations
  72     """
  73     def query(self, view_kwargs):
  74         query_ = self.session.query(Microlocation)
  75         query_ = event_query(self, query_, view_kwargs)
  76         if view_kwargs.get('session_id'):
  77             session = safe_query(self, Session, 'id', view_kwargs['session_id'], 'session_id')
  78             query_ = query_.join(Session).filter(Session.id == session.id)
  79         return query_
  80 
  81     view_kwargs = True
  82     methods = ['GET']
  83     schema = MicrolocationSchema
  84     data_layer = {'session': db.session,
  85                   'model': Microlocation,
  86                   'methods': {
  87                       'query': query
  88                   }}
  89 
  90 
  91 class MicrolocationDetail(ResourceDetail):
  92     """
  93     Microlocation detail by id
  94     """
  95 
  96     def before_get_object(self, view_kwargs):
  97 
  98         if view_kwargs.get('session_id') is not None:
  99             sessions = safe_query(self, Session, 'id', view_kwargs['session_id'], 'session_id')
  100             if sessions.event_id is not None:
  101                 view_kwargs['id'] = sessions.event_id
  102             else:
  103                 view_kwargs['id'] = None
  104 
  105     decorators = (api.has_permission('is_coorganizer', methods="PATCH,DELETE", fetch="event_id", fetch_as="event_id",
  106                                      model=Microlocation),)
  107     schema = MicrolocationSchema
  108     data_layer = {'session': db.session,
  109                   'model': Microlocation,
  110                   'methods': {'before_get_object': before_get_object}}
  111 
  112 
  113 class MicrolocationRelationshipRequired(ResourceRelationship):
  114     """
  115     Microlocation Relationship for required entities
  116     """
  117     decorators = (api.has_permission('is_coorganizer', methods="PATCH", fetch="event_id", fetch_as="event_id",
  118                                      model=Microlocation),)
  119     methods = ['GET', 'PATCH']
  120     schema = MicrolocationSchema
  121     data_layer = {'session': db.session,
  122                   'model': Microlocation}
  123 
  124 
  125 class MicrolocationRelationshipOptional(ResourceRelationship):
  126     """
  127     Microlocation Relationship
  128     """
  129     decorators = (api.has_permission('is_coorganizer', methods="PATCH,DELETE", fetch="event_id", fetch_as="event_id",
  130                                      model=Microlocation),)
  131     schema = MicrolocationSchema
  132     data_layer = {'session': db.session,
  133                   'model': Microlocation}
  134
  [end of app/api/microlocations.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/app/api/microlocations.py b/app/api/microlocations.py
  --- a/app/api/microlocations.py
  +++ b/app/api/microlocations.py
  @@ -26,7 +26,7 @@
           type_ = 'microlocation'
           self_view = 'v1.microlocation_detail'
           self_view_kwargs = {'id': '<id>'}
  -        self_view_many = 'v1.session_list'
  +        self_view_many = 'v1.microlocation_list_post'
           inflect = dasherize
   
       id = fields.Str(dump_only=True)
  @@ -36,6 +36,7 @@
       floor = fields.Integer(allow_none=True)
       room = fields.Str(allow_none=True)
       sessions = Relationship(attribute='session',
  +                            many=True,
                               self_view='v1.microlocation_session',
                               self_view_kwargs={'id': '<id>'},
                               related_view='v1.session_list',
  
verification_info: {"golden_diff": "diff --git a/app/api/microlocations.py b/app/api/microlocations.py\n--- a/app/api/microlocations.py\n+++ b/app/api/microlocations.py\n@@ -26,7 +26,7 @@\n         type_ = 'microlocation'\n         self_view = 'v1.microlocation_detail'\n         self_view_kwargs = {'id': '<id>'}\n-        self_view_many = 'v1.session_list'\n+        self_view_many = 'v1.microlocation_list_post'\n         inflect = dasherize\n \n     id = fields.Str(dump_only=True)\n@@ -36,6 +36,7 @@\n     floor = fields.Integer(allow_none=True)\n     room = fields.Str(allow_none=True)\n     sessions = Relationship(attribute='session',\n+                            many=True,\n                             self_view='v1.microlocation_session',\n                             self_view_kwargs={'id': '<id>'},\n                             related_view='v1.session_list',\n", "issue": "Microlocations : GET requests return ERROR 500\n**I'm submitting a ...**  (check one with \"x\")\r\n- [x] bug report\r\n- [ ] feature request\r\n- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-orga-server\r\n\r\nEndpoint \r\n```\r\nGET v1/events/<event_id>/microlocations \r\n```\r\n\r\nResponse\r\n```\r\n{\r\n   \"errors\":[\r\n      {\r\n         \"detail\":\"Unknown error\",\r\n         \"source\":{\r\n            \"pointer\":\"\"\r\n         },\r\n         \"status\":500,\r\n         \"title\":\"Unknown error\"\r\n      }\r\n   ],\r\n   \"jsonapi\":{\r\n      \"version\":\"1.0\"\r\n   }\r\n}\r\n```\r\n\r\nExample URL\r\n```\r\nhttps://open-event-api.herokuapp.com/v1/events/173/microlocations\r\n```\r\n\n", "before_files": [{"content": "from flask_rest_jsonapi import ResourceDetail, ResourceList, ResourceRelationship\nfrom marshmallow_jsonapi.flask import Schema, Relationship\nfrom marshmallow_jsonapi import fields\n\nfrom app.api.bootstrap import api\nfrom app.api.helpers.utilities import dasherize\nfrom app.models import db\nfrom app.models.microlocation import Microlocation\nfrom app.models.session import Session\nfrom app.api.helpers.db import safe_query\nfrom app.api.helpers.utilities import require_relationship\nfrom app.api.helpers.permission_manager import has_access\nfrom app.api.helpers.exceptions import ForbiddenException\nfrom app.api.helpers.query import event_query\n\n\nclass MicrolocationSchema(Schema):\n    \"\"\"\n    Api schema for Microlocation Model\n    \"\"\"\n\n    class Meta:\n        \"\"\"\n        Meta class for Microlocation Api Schema\n        \"\"\"\n        type_ = 'microlocation'\n        self_view = 'v1.microlocation_detail'\n        self_view_kwargs = {'id': '<id>'}\n        self_view_many = 'v1.session_list'\n        inflect = dasherize\n\n    id = fields.Str(dump_only=True)\n    name = fields.Str(required=True)\n    latitude = fields.Float(validate=lambda n: -90 <= n <= 90, allow_none=True)\n    longitude = fields.Float(validate=lambda n: -180 <= n <= 180, allow_none=True)\n    floor = fields.Integer(allow_none=True)\n    room = fields.Str(allow_none=True)\n    sessions = Relationship(attribute='session',\n                            self_view='v1.microlocation_session',\n                            self_view_kwargs={'id': '<id>'},\n                            related_view='v1.session_list',\n                            related_view_kwargs={'microlocation_id': '<id>'},\n                            schema='SessionSchema',\n                            type_='session')\n    event = Relationship(attribute='event',\n                         self_view='v1.microlocation_event',\n                         self_view_kwargs={'id': '<id>'},\n                         related_view='v1.event_detail',\n                         related_view_kwargs={'microlocation_id': '<id>'},\n                         schema='EventSchema',\n                         type_='event')\n\n\nclass MicrolocationListPost(ResourceList):\n    \"\"\"\n    List and create microlocations\n    \"\"\"\n    def before_post(self, args, kwargs, data):\n        require_relationship(['event'], data)\n        if not has_access('is_coorganizer', event_id=data['event']):\n            raise ForbiddenException({'source': ''}, 'Co-organizer access is required.')\n\n    methods = ['POST', ]\n    schema = MicrolocationSchema\n    data_layer = {'session': db.session,\n                  'model': Microlocation}\n\n\nclass MicrolocationList(ResourceList):\n    \"\"\"\n    List Microlocations\n    \"\"\"\n    def query(self, view_kwargs):\n        query_ = self.session.query(Microlocation)\n        query_ = event_query(self, query_, view_kwargs)\n        if view_kwargs.get('session_id'):\n            session = safe_query(self, Session, 'id', view_kwargs['session_id'], 'session_id')\n            query_ = query_.join(Session).filter(Session.id == session.id)\n        return query_\n\n    view_kwargs = True\n    methods = ['GET']\n    schema = MicrolocationSchema\n    data_layer = {'session': db.session,\n                  'model': Microlocation,\n                  'methods': {\n                      'query': query\n                  }}\n\n\nclass MicrolocationDetail(ResourceDetail):\n    \"\"\"\n    Microlocation detail by id\n    \"\"\"\n\n    def before_get_object(self, view_kwargs):\n\n        if view_kwargs.get('session_id') is not None:\n            sessions = safe_query(self, Session, 'id', view_kwargs['session_id'], 'session_id')\n            if sessions.event_id is not None:\n                view_kwargs['id'] = sessions.event_id\n            else:\n                view_kwargs['id'] = None\n\n    decorators = (api.has_permission('is_coorganizer', methods=\"PATCH,DELETE\", fetch=\"event_id\", fetch_as=\"event_id\",\n                                     model=Microlocation),)\n    schema = MicrolocationSchema\n    data_layer = {'session': db.session,\n                  'model': Microlocation,\n                  'methods': {'before_get_object': before_get_object}}\n\n\nclass MicrolocationRelationshipRequired(ResourceRelationship):\n    \"\"\"\n    Microlocation Relationship for required entities\n    \"\"\"\n    decorators = (api.has_permission('is_coorganizer', methods=\"PATCH\", fetch=\"event_id\", fetch_as=\"event_id\",\n                                     model=Microlocation),)\n    methods = ['GET', 'PATCH']\n    schema = MicrolocationSchema\n    data_layer = {'session': db.session,\n                  'model': Microlocation}\n\n\nclass MicrolocationRelationshipOptional(ResourceRelationship):\n    \"\"\"\n    Microlocation Relationship\n    \"\"\"\n    decorators = (api.has_permission('is_coorganizer', methods=\"PATCH,DELETE\", fetch=\"event_id\", fetch_as=\"event_id\",\n                                     model=Microlocation),)\n    schema = MicrolocationSchema\n    data_layer = {'session': db.session,\n                  'model': Microlocation}\n", "path": "app/api/microlocations.py"}]}