We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Issue with Event Importing
Importing Event with Copyright information in event.json fails.

The issue is because of CopyrightDAO which has no real value of version_key defined. 


--- 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/helpers/utils.py`
Content:
```
1 import json
2 from hashlib import md5
3 
4 from flask import request
5 from flask.ext.restplus import Resource as RestplusResource
6 from flask_restplus import Model, fields, reqparse
7 
8 from .helpers import get_object_list, get_object_or_404, get_object_in_event, \
9     create_model, validate_payload, delete_model, update_model, \
10     handle_extra_payload, get_paginated_list
11 from app.models.event import Event as EventModel
12 from app.helpers.data import update_version
13 
14 from .error_docs import (
15     notfound_error_model,
16     notauthorized_error_model,
17     validation_error_model,
18     invalidservice_error_model,
19 )
20 
21 DEFAULT_PAGE_START = 1
22 DEFAULT_PAGE_LIMIT = 20
23 
24 POST_RESPONSES = {
25     400: ('Validation error', validation_error_model),
26     401: ('Authentication failure', notauthorized_error_model),
27     404: ('Event does not exist', notfound_error_model),
28     201: 'Resource created successfully'
29 }
30 
31 PUT_RESPONSES = {
32     400: ('Validation Error', validation_error_model),
33     401: ('Authentication failure', notauthorized_error_model),
34     404: ('Object/Event not found', notfound_error_model)
35 }
36 
37 SERVICE_RESPONSES = {
38     404: ('Service not found', notfound_error_model),
39     400: ('Service does not belong to event', invalidservice_error_model),
40 }
41 
42 # Parameters for a paginated response
43 PAGE_PARAMS = {
44     'start': {
45         'description': 'Serial number to start from',
46         'type': int,
47         'default': DEFAULT_PAGE_START
48     },
49     'limit': {
50         'description': 'Limit on the number of results',
51         'type': int,
52         'default': DEFAULT_PAGE_LIMIT
53     },
54 }
55 
56 # Base Api Model for a paginated response
57 PAGINATED_MODEL = Model('PaginatedModel', {
58     'start': fields.Integer,
59     'limit': fields.Integer,
60     'count': fields.Integer,
61     'next': fields.String,
62     'previous': fields.String
63 })
64 
65 
66 # Custom Resource Class
67 class Resource(RestplusResource):
68     def dispatch_request(self, *args, **kwargs):
69         resp = super(Resource, self).dispatch_request(*args, **kwargs)
70 
71         # ETag checking.
72         if request.method == 'GET':
73             old_etag = request.headers.get('If-None-Match', '')
74             # Generate hash
75             data = json.dumps(resp)
76             new_etag = md5(data).hexdigest()
77 
78             if new_etag == old_etag:
79                 # Resource has not changed
80                 return '', 304
81             else:
82                 # Resource has changed, send new ETag value
83                 return resp, 200, {'ETag': new_etag}
84         elif request.method == 'POST':
85             # Grab just the response data
86             # Exclude status code and headers
87             resp_data = resp[0]
88 
89             data = json.dumps(resp_data)
90             etag = md5(data).hexdigest()
91 
92             # Add ETag to response headers
93             resp[2].update({'ETag': etag})
94 
95         return resp
96 
97 
98 # Base class for Paginated Resource
99 class PaginatedResourceBase():
100     """
101     Paginated Resource Helper class
102     This includes basic properties used in the class
103     """
104     parser = reqparse.RequestParser()
105     parser.add_argument('start', type=int, default=DEFAULT_PAGE_START)
106     parser.add_argument('limit', type=int, default=DEFAULT_PAGE_LIMIT)
107 
108 
109 # DAO for Models
110 class BaseDAO:
111     """
112     DAO for a basic independent model
113     """
114     version_key = 'base_ver'
115 
116     def __init__(self, model, post_api_model=None, put_api_model=None):
117         self.model = model
118         self.post_api_model = post_api_model
119         self.put_api_model = put_api_model if put_api_model else post_api_model
120 
121     def get(self, id_):
122         return get_object_or_404(self.model, id_)
123 
124     def list(self, **kwargs):
125         return get_object_list(self.model, **kwargs)
126 
127     def paginated_list(self, url=None, args={}, **kwargs):
128         return get_paginated_list(self.model, url=url, args=args, **kwargs)
129 
130     def create(self, data, validate=True):
131         if validate:
132             data = self.validate(data, self.post_api_model)
133         item = create_model(self.model, data)
134         self.update_version(item.id)
135         return item
136 
137     def update(self, id_, data, validate=True):
138         if validate:
139             data = self.validate_put(data, self.put_api_model)
140         item = update_model(self.model, id_, data)
141         self.update_version(id_)
142         return item
143 
144     def delete(self, id_):
145         item = delete_model(self.model, id_)
146         self.update_version(id_)
147         return item
148 
149     def validate(self, data, model=None, check_required=True):
150         if not model:
151             model = self.post_api_model
152         if model:
153             data = handle_extra_payload(data, model)
154             validate_payload(data, model, check_required=check_required)
155         return data
156 
157     def validate_put(self, data, model=None):
158         """
159         Abstraction over validate with check_required set to False
160         """
161         return self.validate(data, model=model, check_required=False)
162 
163     def update_version(self, event_id):
164         """
165         Update version of the component of the event
166         """
167         update_version(event_id, False, self.version_key)
168 
169     # Helper functions
170     def _del(self, data, fields):
171         """
172         Safe delete fields from payload
173         """
174         data_copy = data.copy()
175         for field in fields:
176             if field in data:
177                 del data_copy[field]
178         return data_copy
179 
180 
181 # DAO for Service Models
182 class ServiceDAO(BaseDAO):
183     """
184     Data Access Object for service models like microlocations,
185     speakers and so.
186     """
187     def get(self, event_id, sid):
188         return get_object_in_event(self.model, sid, event_id)
189 
190     def list(self, event_id, **kwargs):
191         # Check if an event with `event_id` exists
192         get_object_or_404(EventModel, event_id)
193         return get_object_list(self.model, event_id=event_id, **kwargs)
194 
195     def paginated_list(self, url=None, args={}, **kwargs):
196         return get_paginated_list(self.model, url=url, args=args, **kwargs)
197 
198     def create(self, event_id, data, url, validate=True):
199         if validate:
200             data = self.validate(data)
201         item = create_model(self.model, data, event_id=event_id)
202         self.update_version(event_id)
203         # Return created resource with a 201 status code and its Location
204         # (url) in the header.
205         resource_location = url + '/' + str(item.id)
206         return item, 201, {'Location': resource_location}
207 
208     def update(self, event_id, service_id, data, validate=True):
209         if validate:
210             data = self.validate_put(data)
211         item = update_model(self.model, service_id, data, event_id)
212         self.update_version(event_id)
213         return item
214 
215     def delete(self, event_id, service_id):
216         item = delete_model(self.model, service_id, event_id=event_id)
217         self.update_version(event_id)
218         return item
219 
220 # store task results in case of testing
221 # state and info
222 TASK_RESULTS = {}
223
```
--- 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/helpers/utils.py b/app/api/helpers/utils.py
--- a/app/api/helpers/utils.py
+++ b/app/api/helpers/utils.py
@@ -111,7 +111,7 @@
     """
     DAO for a basic independent model
     """
-    version_key = 'base_ver'
+    version_key = None
 
     def __init__(self, model, post_api_model=None, put_api_model=None):
         self.model = model
@@ -164,7 +164,8 @@
         """
         Update version of the component of the event
         """
-        update_version(event_id, False, self.version_key)
+        if self.version_key:
+            update_version(event_id, False, self.version_key)
 
     # Helper functions
     def _del(self, data, fields):

{"golden_diff": "diff --git a/app/api/helpers/utils.py b/app/api/helpers/utils.py\n--- a/app/api/helpers/utils.py\n+++ b/app/api/helpers/utils.py\n@@ -111,7 +111,7 @@\n     \"\"\"\n     DAO for a basic independent model\n     \"\"\"\n-    version_key = 'base_ver'\n+    version_key = None\n \n     def __init__(self, model, post_api_model=None, put_api_model=None):\n         self.model = model\n@@ -164,7 +164,8 @@\n         \"\"\"\n         Update version of the component of the event\n         \"\"\"\n-        update_version(event_id, False, self.version_key)\n+        if self.version_key:\n+            update_version(event_id, False, self.version_key)\n \n     # Helper functions\n     def _del(self, data, fields):\n", "issue": "Issue with Event Importing\nImporting Event with Copyright information in event.json fails.\n\nThe issue is because of CopyrightDAO which has no real value of version_key defined. \n\n", "before_files": [{"content": "import json\nfrom hashlib import md5\n\nfrom flask import request\nfrom flask.ext.restplus import Resource as RestplusResource\nfrom flask_restplus import Model, fields, reqparse\n\nfrom .helpers import get_object_list, get_object_or_404, get_object_in_event, \\\n    create_model, validate_payload, delete_model, update_model, \\\n    handle_extra_payload, get_paginated_list\nfrom app.models.event import Event as EventModel\nfrom app.helpers.data import update_version\n\nfrom .error_docs import (\n    notfound_error_model,\n    notauthorized_error_model,\n    validation_error_model,\n    invalidservice_error_model,\n)\n\nDEFAULT_PAGE_START = 1\nDEFAULT_PAGE_LIMIT = 20\n\nPOST_RESPONSES = {\n    400: ('Validation error', validation_error_model),\n    401: ('Authentication failure', notauthorized_error_model),\n    404: ('Event does not exist', notfound_error_model),\n    201: 'Resource created successfully'\n}\n\nPUT_RESPONSES = {\n    400: ('Validation Error', validation_error_model),\n    401: ('Authentication failure', notauthorized_error_model),\n    404: ('Object/Event not found', notfound_error_model)\n}\n\nSERVICE_RESPONSES = {\n    404: ('Service not found', notfound_error_model),\n    400: ('Service does not belong to event', invalidservice_error_model),\n}\n\n# Parameters for a paginated response\nPAGE_PARAMS = {\n    'start': {\n        'description': 'Serial number to start from',\n        'type': int,\n        'default': DEFAULT_PAGE_START\n    },\n    'limit': {\n        'description': 'Limit on the number of results',\n        'type': int,\n        'default': DEFAULT_PAGE_LIMIT\n    },\n}\n\n# Base Api Model for a paginated response\nPAGINATED_MODEL = Model('PaginatedModel', {\n    'start': fields.Integer,\n    'limit': fields.Integer,\n    'count': fields.Integer,\n    'next': fields.String,\n    'previous': fields.String\n})\n\n\n# Custom Resource Class\nclass Resource(RestplusResource):\n    def dispatch_request(self, *args, **kwargs):\n        resp = super(Resource, self).dispatch_request(*args, **kwargs)\n\n        # ETag checking.\n        if request.method == 'GET':\n            old_etag = request.headers.get('If-None-Match', '')\n            # Generate hash\n            data = json.dumps(resp)\n            new_etag = md5(data).hexdigest()\n\n            if new_etag == old_etag:\n                # Resource has not changed\n                return '', 304\n            else:\n                # Resource has changed, send new ETag value\n                return resp, 200, {'ETag': new_etag}\n        elif request.method == 'POST':\n            # Grab just the response data\n            # Exclude status code and headers\n            resp_data = resp[0]\n\n            data = json.dumps(resp_data)\n            etag = md5(data).hexdigest()\n\n            # Add ETag to response headers\n            resp[2].update({'ETag': etag})\n\n        return resp\n\n\n# Base class for Paginated Resource\nclass PaginatedResourceBase():\n    \"\"\"\n    Paginated Resource Helper class\n    This includes basic properties used in the class\n    \"\"\"\n    parser = reqparse.RequestParser()\n    parser.add_argument('start', type=int, default=DEFAULT_PAGE_START)\n    parser.add_argument('limit', type=int, default=DEFAULT_PAGE_LIMIT)\n\n\n# DAO for Models\nclass BaseDAO:\n    \"\"\"\n    DAO for a basic independent model\n    \"\"\"\n    version_key = 'base_ver'\n\n    def __init__(self, model, post_api_model=None, put_api_model=None):\n        self.model = model\n        self.post_api_model = post_api_model\n        self.put_api_model = put_api_model if put_api_model else post_api_model\n\n    def get(self, id_):\n        return get_object_or_404(self.model, id_)\n\n    def list(self, **kwargs):\n        return get_object_list(self.model, **kwargs)\n\n    def paginated_list(self, url=None, args={}, **kwargs):\n        return get_paginated_list(self.model, url=url, args=args, **kwargs)\n\n    def create(self, data, validate=True):\n        if validate:\n            data = self.validate(data, self.post_api_model)\n        item = create_model(self.model, data)\n        self.update_version(item.id)\n        return item\n\n    def update(self, id_, data, validate=True):\n        if validate:\n            data = self.validate_put(data, self.put_api_model)\n        item = update_model(self.model, id_, data)\n        self.update_version(id_)\n        return item\n\n    def delete(self, id_):\n        item = delete_model(self.model, id_)\n        self.update_version(id_)\n        return item\n\n    def validate(self, data, model=None, check_required=True):\n        if not model:\n            model = self.post_api_model\n        if model:\n            data = handle_extra_payload(data, model)\n            validate_payload(data, model, check_required=check_required)\n        return data\n\n    def validate_put(self, data, model=None):\n        \"\"\"\n        Abstraction over validate with check_required set to False\n        \"\"\"\n        return self.validate(data, model=model, check_required=False)\n\n    def update_version(self, event_id):\n        \"\"\"\n        Update version of the component of the event\n        \"\"\"\n        update_version(event_id, False, self.version_key)\n\n    # Helper functions\n    def _del(self, data, fields):\n        \"\"\"\n        Safe delete fields from payload\n        \"\"\"\n        data_copy = data.copy()\n        for field in fields:\n            if field in data:\n                del data_copy[field]\n        return data_copy\n\n\n# DAO for Service Models\nclass ServiceDAO(BaseDAO):\n    \"\"\"\n    Data Access Object for service models like microlocations,\n    speakers and so.\n    \"\"\"\n    def get(self, event_id, sid):\n        return get_object_in_event(self.model, sid, event_id)\n\n    def list(self, event_id, **kwargs):\n        # Check if an event with `event_id` exists\n        get_object_or_404(EventModel, event_id)\n        return get_object_list(self.model, event_id=event_id, **kwargs)\n\n    def paginated_list(self, url=None, args={}, **kwargs):\n        return get_paginated_list(self.model, url=url, args=args, **kwargs)\n\n    def create(self, event_id, data, url, validate=True):\n        if validate:\n            data = self.validate(data)\n        item = create_model(self.model, data, event_id=event_id)\n        self.update_version(event_id)\n        # Return created resource with a 201 status code and its Location\n        # (url) in the header.\n        resource_location = url + '/' + str(item.id)\n        return item, 201, {'Location': resource_location}\n\n    def update(self, event_id, service_id, data, validate=True):\n        if validate:\n            data = self.validate_put(data)\n        item = update_model(self.model, service_id, data, event_id)\n        self.update_version(event_id)\n        return item\n\n    def delete(self, event_id, service_id):\n        item = delete_model(self.model, service_id, event_id=event_id)\n        self.update_version(event_id)\n        return item\n\n# store task results in case of testing\n# state and info\nTASK_RESULTS = {}\n", "path": "app/api/helpers/utils.py"}], "after_files": [{"content": "import json\nfrom hashlib import md5\n\nfrom flask import request\nfrom flask.ext.restplus import Resource as RestplusResource\nfrom flask_restplus import Model, fields, reqparse\n\nfrom .helpers import get_object_list, get_object_or_404, get_object_in_event, \\\n    create_model, validate_payload, delete_model, update_model, \\\n    handle_extra_payload, get_paginated_list\nfrom app.models.event import Event as EventModel\nfrom app.helpers.data import update_version\n\nfrom .error_docs import (\n    notfound_error_model,\n    notauthorized_error_model,\n    validation_error_model,\n    invalidservice_error_model,\n)\n\nDEFAULT_PAGE_START = 1\nDEFAULT_PAGE_LIMIT = 20\n\nPOST_RESPONSES = {\n    400: ('Validation error', validation_error_model),\n    401: ('Authentication failure', notauthorized_error_model),\n    404: ('Event does not exist', notfound_error_model),\n    201: 'Resource created successfully'\n}\n\nPUT_RESPONSES = {\n    400: ('Validation Error', validation_error_model),\n    401: ('Authentication failure', notauthorized_error_model),\n    404: ('Object/Event not found', notfound_error_model)\n}\n\nSERVICE_RESPONSES = {\n    404: ('Service not found', notfound_error_model),\n    400: ('Service does not belong to event', invalidservice_error_model),\n}\n\n# Parameters for a paginated response\nPAGE_PARAMS = {\n    'start': {\n        'description': 'Serial number to start from',\n        'type': int,\n        'default': DEFAULT_PAGE_START\n    },\n    'limit': {\n        'description': 'Limit on the number of results',\n        'type': int,\n        'default': DEFAULT_PAGE_LIMIT\n    },\n}\n\n# Base Api Model for a paginated response\nPAGINATED_MODEL = Model('PaginatedModel', {\n    'start': fields.Integer,\n    'limit': fields.Integer,\n    'count': fields.Integer,\n    'next': fields.String,\n    'previous': fields.String\n})\n\n\n# Custom Resource Class\nclass Resource(RestplusResource):\n    def dispatch_request(self, *args, **kwargs):\n        resp = super(Resource, self).dispatch_request(*args, **kwargs)\n\n        # ETag checking.\n        if request.method == 'GET':\n            old_etag = request.headers.get('If-None-Match', '')\n            # Generate hash\n            data = json.dumps(resp)\n            new_etag = md5(data).hexdigest()\n\n            if new_etag == old_etag:\n                # Resource has not changed\n                return '', 304\n            else:\n                # Resource has changed, send new ETag value\n                return resp, 200, {'ETag': new_etag}\n        elif request.method == 'POST':\n            # Grab just the response data\n            # Exclude status code and headers\n            resp_data = resp[0]\n\n            data = json.dumps(resp_data)\n            etag = md5(data).hexdigest()\n\n            # Add ETag to response headers\n            resp[2].update({'ETag': etag})\n\n        return resp\n\n\n# Base class for Paginated Resource\nclass PaginatedResourceBase():\n    \"\"\"\n    Paginated Resource Helper class\n    This includes basic properties used in the class\n    \"\"\"\n    parser = reqparse.RequestParser()\n    parser.add_argument('start', type=int, default=DEFAULT_PAGE_START)\n    parser.add_argument('limit', type=int, default=DEFAULT_PAGE_LIMIT)\n\n\n# DAO for Models\nclass BaseDAO:\n    \"\"\"\n    DAO for a basic independent model\n    \"\"\"\n    version_key = None\n\n    def __init__(self, model, post_api_model=None, put_api_model=None):\n        self.model = model\n        self.post_api_model = post_api_model\n        self.put_api_model = put_api_model if put_api_model else post_api_model\n\n    def get(self, id_):\n        return get_object_or_404(self.model, id_)\n\n    def list(self, **kwargs):\n        return get_object_list(self.model, **kwargs)\n\n    def paginated_list(self, url=None, args={}, **kwargs):\n        return get_paginated_list(self.model, url=url, args=args, **kwargs)\n\n    def create(self, data, validate=True):\n        if validate:\n            data = self.validate(data, self.post_api_model)\n        item = create_model(self.model, data)\n        self.update_version(item.id)\n        return item\n\n    def update(self, id_, data, validate=True):\n        if validate:\n            data = self.validate_put(data, self.put_api_model)\n        item = update_model(self.model, id_, data)\n        self.update_version(id_)\n        return item\n\n    def delete(self, id_):\n        item = delete_model(self.model, id_)\n        self.update_version(id_)\n        return item\n\n    def validate(self, data, model=None, check_required=True):\n        if not model:\n            model = self.post_api_model\n        if model:\n            data = handle_extra_payload(data, model)\n            validate_payload(data, model, check_required=check_required)\n        return data\n\n    def validate_put(self, data, model=None):\n        \"\"\"\n        Abstraction over validate with check_required set to False\n        \"\"\"\n        return self.validate(data, model=model, check_required=False)\n\n    def update_version(self, event_id):\n        \"\"\"\n        Update version of the component of the event\n        \"\"\"\n        if self.version_key:\n            update_version(event_id, False, self.version_key)\n\n    # Helper functions\n    def _del(self, data, fields):\n        \"\"\"\n        Safe delete fields from payload\n        \"\"\"\n        data_copy = data.copy()\n        for field in fields:\n            if field in data:\n                del data_copy[field]\n        return data_copy\n\n\n# DAO for Service Models\nclass ServiceDAO(BaseDAO):\n    \"\"\"\n    Data Access Object for service models like microlocations,\n    speakers and so.\n    \"\"\"\n    def get(self, event_id, sid):\n        return get_object_in_event(self.model, sid, event_id)\n\n    def list(self, event_id, **kwargs):\n        # Check if an event with `event_id` exists\n        get_object_or_404(EventModel, event_id)\n        return get_object_list(self.model, event_id=event_id, **kwargs)\n\n    def paginated_list(self, url=None, args={}, **kwargs):\n        return get_paginated_list(self.model, url=url, args=args, **kwargs)\n\n    def create(self, event_id, data, url, validate=True):\n        if validate:\n            data = self.validate(data)\n        item = create_model(self.model, data, event_id=event_id)\n        self.update_version(event_id)\n        # Return created resource with a 201 status code and its Location\n        # (url) in the header.\n        resource_location = url + '/' + str(item.id)\n        return item, 201, {'Location': resource_location}\n\n    def update(self, event_id, service_id, data, validate=True):\n        if validate:\n            data = self.validate_put(data)\n        item = update_model(self.model, service_id, data, event_id)\n        self.update_version(event_id)\n        return item\n\n    def delete(self, event_id, service_id):\n        item = delete_model(self.model, service_id, event_id=event_id)\n        self.update_version(event_id)\n        return item\n\n# store task results in case of testing\n# state and info\nTASK_RESULTS = {}\n", "path": "app/api/helpers/utils.py"}]}