We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Sentry]: 'EventInvoice' object has no attribute 'stripe_user_id'
https://sentry.eventyay.com/eventyay/dev-api/issues/59/

```
AttributeError: 'EventInvoice' object has no attribute 'stripe_user_id'
  File "flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "flask_admin/base.py", line 69, in inner
    return self._run_view(f, *args, **kwargs)
  File "flask_admin/base.py", line 368, in _run_view
    return fn(self, *args, **kwargs)
  File "flask_admin/model/base.py", line 2076, in edit_view
    return_url=return_url)
  File "flask_admin/base.py", line 308, in render
    return render_template(template, **kwargs)
  File "flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html", line 3, in top-level template code
    {% from 'admin/lib.html' import extra with context %} {# backward compatible #}
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/master.html", line 1, in top-level template code
    {% extends admin_base_template %}
  File "/app/app/templates/admin_base.html", line 1, in top-level template code
    {% extends 'admin/base.html' %}
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/base.html", line 37, in top-level template code
    {% block page_body %}
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/base.html", line 77, in block "page_body"
    {% block body %}{% endblock %}
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html", line 32, in block "body"
    {% block edit_form %}
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html", line 33, in block "edit_form"
    {{ lib.render_form(form, return_url, extra(), form_opts) }}
  File "jinja2/runtime.py", line 553, in _invoke
    rv = self._func(*arguments)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 202, in template
    {% call form_tag(action=action) %}
  File "jinja2/runtime.py", line 553, in _invoke
    rv = self._func(*arguments)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 182, in template
    {{ caller() }}
  File "jinja2/runtime.py", line 553, in _invoke
    rv = self._func(*arguments)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 203, in template
    {{ render_form_fields(form, form_opts=form_opts) }}
  File "jinja2/runtime.py", line 553, in _invoke
    rv = self._func(*arguments)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 175, in template
    {{ render_field(form, f, kwargs) }}
  File "jinja2/runtime.py", line 553, in _invoke
    rv = self._func(*arguments)
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html", line 130, in template
    {{ field(**kwargs)|safe }}
  File "wtforms/fields/core.py", line 153, in __call__
    return self.meta.render_field(self, kwargs)
  File "wtforms/meta.py", line 56, in render_field
    return field.widget(field, **render_kw)
  File "flask_admin/form/widgets.py", line 28, in __call__
    return super(Select2Widget, self).__call__(field, **kwargs)
  File "wtforms/widgets/core.py", line 288, in __call__
    html.append(self.render_option(val, label, selected))
  File "wtforms/widgets/core.py", line 301, in render_option
    return HTMLString('<option %s>%s</option>' % (html_params(**options), escape(text_type(label), quote=False)))
  File "app/models/event_invoice.py", line 111, in __unicode__
    return self.stripe_user_id
```

--- 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/models/event_invoice.py`
Content:
```
1 import time
2 import uuid
3 from datetime import datetime
4 
5 from app.api.helpers.db import get_count
6 from app.models import db
7 
8 
9 def get_new_identifier():
10     identifier = str(uuid.uuid4())
11     count = get_count(EventInvoice.query.filter_by(identifier=identifier))
12     if count == 0:
13         return identifier
14     else:
15         return get_new_identifier()
16 
17 
18 class EventInvoice(db.Model):
19     """
20     Stripe authorization information for an event.
21     """
22     __tablename__ = 'event_invoices'
23 
24     id = db.Column(db.Integer, primary_key=True)
25     identifier = db.Column(db.String, unique=True)
26     amount = db.Column(db.Float)
27     address = db.Column(db.String)
28     city = db.Column(db.String)
29     state = db.Column(db.String)
30     country = db.Column(db.String)
31     zipcode = db.Column(db.String)
32 
33     user_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='SET NULL'))
34     event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='SET NULL'))
35 
36     created_at = db.Column(db.DateTime(timezone=True))
37     completed_at = db.Column(db.DateTime(timezone=True), nullable=True, default=None)
38     transaction_id = db.Column(db.String)
39     paid_via = db.Column(db.String)
40     payment_mode = db.Column(db.String)
41     brand = db.Column(db.String)
42     exp_month = db.Column(db.Integer)
43     exp_year = db.Column(db.Integer)
44     last4 = db.Column(db.String)
45     stripe_token = db.Column(db.String)
46     paypal_token = db.Column(db.String)
47     status = db.Column(db.String)
48     invoice_pdf_url = db.Column(db.String)
49 
50     event = db.relationship('Event', backref='invoices')
51     user = db.relationship('User', backref='invoices')
52 
53     discount_code_id = db.Column(db.Integer, db.ForeignKey('discount_codes.id', ondelete='SET NULL'),
54                                  nullable=True, default=None)
55     discount_code = db.relationship('DiscountCode', backref='event_invoices')
56 
57     def __init__(self,
58                  amount=None,
59                  address=None,
60                  city=None,
61                  state=None,
62                  country=None,
63                  zipcode=None,
64                  transaction_id=None,
65                  paid_via=None,
66                  user_id=None,
67                  discount_code_id=None,
68                  event_id=None,
69                  invoice_pdf_url=None,
70                  payment_mode=None,
71                  brand=None,
72                  exp_month=None,
73                  exp_year=None,
74                  last4=None,
75                  stripe_token=None,
76                  paypal_token=None
77                  ):
78         self.identifier = get_new_identifier()
79         self.amount = amount
80         self.address = address
81         self.state = state
82         self.country = country
83         self.zipcode = zipcode
84         self.city = city
85         self.user_id = user_id
86         self.event_id = event_id
87         self.transaction_id = transaction_id
88         self.paid_via = paid_via
89         self.created_at = datetime.utcnow()
90         self.discount_code_id = discount_code_id
91         self.status = 'pending'
92         self.invoice_pdf_url = invoice_pdf_url
93         self.payment_mode = payment_mode
94         self.brand = brand
95         self.exp_month = exp_month
96         self.exp_year = exp_year
97         self.last4 = last4
98         self.stripe_token = stripe_token
99         self.paypal_token = paypal_token
100 
101     def get_invoice_number(self):
102         return 'I' + str(int(time.mktime(self.created_at.timetuple()))) + '-' + str(self.id)
103 
104     def __repr__(self):
105         return '<EventInvoice %r>' % self.stripe_user_id
106 
107     def __str__(self):
108         return unicode(self).encode('utf-8')
109 
110     def __unicode__(self):
111         return self.stripe_user_id
112
```
--- 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/models/event_invoice.py b/app/models/event_invoice.py
--- a/app/models/event_invoice.py
+++ b/app/models/event_invoice.py
@@ -102,10 +102,10 @@
         return 'I' + str(int(time.mktime(self.created_at.timetuple()))) + '-' + str(self.id)
 
     def __repr__(self):
-        return '<EventInvoice %r>' % self.stripe_user_id
+        return '<EventInvoice %r>' % self.invoice_pdf_url
 
     def __str__(self):
         return unicode(self).encode('utf-8')
 
     def __unicode__(self):
-        return self.stripe_user_id
+        return self.invoice_pdf_url

{"golden_diff": "diff --git a/app/models/event_invoice.py b/app/models/event_invoice.py\n--- a/app/models/event_invoice.py\n+++ b/app/models/event_invoice.py\n@@ -102,10 +102,10 @@\n         return 'I' + str(int(time.mktime(self.created_at.timetuple()))) + '-' + str(self.id)\n \n     def __repr__(self):\n-        return '<EventInvoice %r>' % self.stripe_user_id\n+        return '<EventInvoice %r>' % self.invoice_pdf_url\n \n     def __str__(self):\n         return unicode(self).encode('utf-8')\n \n     def __unicode__(self):\n-        return self.stripe_user_id\n+        return self.invoice_pdf_url\n", "issue": "[Sentry]: 'EventInvoice' object has no attribute 'stripe_user_id'\nhttps://sentry.eventyay.com/eventyay/dev-api/issues/59/\r\n\r\n```\r\nAttributeError: 'EventInvoice' object has no attribute 'stripe_user_id'\r\n  File \"flask/app.py\", line 1982, in wsgi_app\r\n    response = self.full_dispatch_request()\r\n  File \"flask/app.py\", line 1614, in full_dispatch_request\r\n    rv = self.handle_user_exception(e)\r\n  File \"flask_cors/extension.py\", line 161, in wrapped_function\r\n    return cors_after_request(app.make_response(f(*args, **kwargs)))\r\n  File \"flask/app.py\", line 1517, in handle_user_exception\r\n    reraise(exc_type, exc_value, tb)\r\n  File \"flask/app.py\", line 1612, in full_dispatch_request\r\n    rv = self.dispatch_request()\r\n  File \"flask/app.py\", line 1598, in dispatch_request\r\n    return self.view_functions[rule.endpoint](**req.view_args)\r\n  File \"flask_admin/base.py\", line 69, in inner\r\n    return self._run_view(f, *args, **kwargs)\r\n  File \"flask_admin/base.py\", line 368, in _run_view\r\n    return fn(self, *args, **kwargs)\r\n  File \"flask_admin/model/base.py\", line 2076, in edit_view\r\n    return_url=return_url)\r\n  File \"flask_admin/base.py\", line 308, in render\r\n    return render_template(template, **kwargs)\r\n  File \"flask/templating.py\", line 134, in render_template\r\n    context, ctx.app)\r\n  File \"flask/templating.py\", line 116, in _render\r\n    rv = template.render(context)\r\n  File \"jinja2/environment.py\", line 1008, in render\r\n    return self.environment.handle_exception(exc_info, True)\r\n  File \"jinja2/environment.py\", line 780, in handle_exception\r\n    reraise(exc_type, exc_value, tb)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html\", line 3, in top-level template code\r\n    {% from 'admin/lib.html' import extra with context %} {# backward compatible #}\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/master.html\", line 1, in top-level template code\r\n    {% extends admin_base_template %}\r\n  File \"/app/app/templates/admin_base.html\", line 1, in top-level template code\r\n    {% extends 'admin/base.html' %}\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/base.html\", line 37, in top-level template code\r\n    {% block page_body %}\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/base.html\", line 77, in block \"page_body\"\r\n    {% block body %}{% endblock %}\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html\", line 32, in block \"body\"\r\n    {% block edit_form %}\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/model/edit.html\", line 33, in block \"edit_form\"\r\n    {{ lib.render_form(form, return_url, extra(), form_opts) }}\r\n  File \"jinja2/runtime.py\", line 553, in _invoke\r\n    rv = self._func(*arguments)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html\", line 202, in template\r\n    {% call form_tag(action=action) %}\r\n  File \"jinja2/runtime.py\", line 553, in _invoke\r\n    rv = self._func(*arguments)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html\", line 182, in template\r\n    {{ caller() }}\r\n  File \"jinja2/runtime.py\", line 553, in _invoke\r\n    rv = self._func(*arguments)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html\", line 203, in template\r\n    {{ render_form_fields(form, form_opts=form_opts) }}\r\n  File \"jinja2/runtime.py\", line 553, in _invoke\r\n    rv = self._func(*arguments)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html\", line 175, in template\r\n    {{ render_field(form, f, kwargs) }}\r\n  File \"jinja2/runtime.py\", line 553, in _invoke\r\n    rv = self._func(*arguments)\r\n  File \"/app/.heroku/python/lib/python2.7/site-packages/flask_admin/templates/bootstrap3/admin/lib.html\", line 130, in template\r\n    {{ field(**kwargs)|safe }}\r\n  File \"wtforms/fields/core.py\", line 153, in __call__\r\n    return self.meta.render_field(self, kwargs)\r\n  File \"wtforms/meta.py\", line 56, in render_field\r\n    return field.widget(field, **render_kw)\r\n  File \"flask_admin/form/widgets.py\", line 28, in __call__\r\n    return super(Select2Widget, self).__call__(field, **kwargs)\r\n  File \"wtforms/widgets/core.py\", line 288, in __call__\r\n    html.append(self.render_option(val, label, selected))\r\n  File \"wtforms/widgets/core.py\", line 301, in render_option\r\n    return HTMLString('<option %s>%s</option>' % (html_params(**options), escape(text_type(label), quote=False)))\r\n  File \"app/models/event_invoice.py\", line 111, in __unicode__\r\n    return self.stripe_user_id\r\n```\n", "before_files": [{"content": "import time\nimport uuid\nfrom datetime import datetime\n\nfrom app.api.helpers.db import get_count\nfrom app.models import db\n\n\ndef get_new_identifier():\n    identifier = str(uuid.uuid4())\n    count = get_count(EventInvoice.query.filter_by(identifier=identifier))\n    if count == 0:\n        return identifier\n    else:\n        return get_new_identifier()\n\n\nclass EventInvoice(db.Model):\n    \"\"\"\n    Stripe authorization information for an event.\n    \"\"\"\n    __tablename__ = 'event_invoices'\n\n    id = db.Column(db.Integer, primary_key=True)\n    identifier = db.Column(db.String, unique=True)\n    amount = db.Column(db.Float)\n    address = db.Column(db.String)\n    city = db.Column(db.String)\n    state = db.Column(db.String)\n    country = db.Column(db.String)\n    zipcode = db.Column(db.String)\n\n    user_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='SET NULL'))\n    event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='SET NULL'))\n\n    created_at = db.Column(db.DateTime(timezone=True))\n    completed_at = db.Column(db.DateTime(timezone=True), nullable=True, default=None)\n    transaction_id = db.Column(db.String)\n    paid_via = db.Column(db.String)\n    payment_mode = db.Column(db.String)\n    brand = db.Column(db.String)\n    exp_month = db.Column(db.Integer)\n    exp_year = db.Column(db.Integer)\n    last4 = db.Column(db.String)\n    stripe_token = db.Column(db.String)\n    paypal_token = db.Column(db.String)\n    status = db.Column(db.String)\n    invoice_pdf_url = db.Column(db.String)\n\n    event = db.relationship('Event', backref='invoices')\n    user = db.relationship('User', backref='invoices')\n\n    discount_code_id = db.Column(db.Integer, db.ForeignKey('discount_codes.id', ondelete='SET NULL'),\n                                 nullable=True, default=None)\n    discount_code = db.relationship('DiscountCode', backref='event_invoices')\n\n    def __init__(self,\n                 amount=None,\n                 address=None,\n                 city=None,\n                 state=None,\n                 country=None,\n                 zipcode=None,\n                 transaction_id=None,\n                 paid_via=None,\n                 user_id=None,\n                 discount_code_id=None,\n                 event_id=None,\n                 invoice_pdf_url=None,\n                 payment_mode=None,\n                 brand=None,\n                 exp_month=None,\n                 exp_year=None,\n                 last4=None,\n                 stripe_token=None,\n                 paypal_token=None\n                 ):\n        self.identifier = get_new_identifier()\n        self.amount = amount\n        self.address = address\n        self.state = state\n        self.country = country\n        self.zipcode = zipcode\n        self.city = city\n        self.user_id = user_id\n        self.event_id = event_id\n        self.transaction_id = transaction_id\n        self.paid_via = paid_via\n        self.created_at = datetime.utcnow()\n        self.discount_code_id = discount_code_id\n        self.status = 'pending'\n        self.invoice_pdf_url = invoice_pdf_url\n        self.payment_mode = payment_mode\n        self.brand = brand\n        self.exp_month = exp_month\n        self.exp_year = exp_year\n        self.last4 = last4\n        self.stripe_token = stripe_token\n        self.paypal_token = paypal_token\n\n    def get_invoice_number(self):\n        return 'I' + str(int(time.mktime(self.created_at.timetuple()))) + '-' + str(self.id)\n\n    def __repr__(self):\n        return '<EventInvoice %r>' % self.stripe_user_id\n\n    def __str__(self):\n        return unicode(self).encode('utf-8')\n\n    def __unicode__(self):\n        return self.stripe_user_id\n", "path": "app/models/event_invoice.py"}], "after_files": [{"content": "import time\nimport uuid\nfrom datetime import datetime\n\nfrom app.api.helpers.db import get_count\nfrom app.models import db\n\n\ndef get_new_identifier():\n    identifier = str(uuid.uuid4())\n    count = get_count(EventInvoice.query.filter_by(identifier=identifier))\n    if count == 0:\n        return identifier\n    else:\n        return get_new_identifier()\n\n\nclass EventInvoice(db.Model):\n    \"\"\"\n    Stripe authorization information for an event.\n    \"\"\"\n    __tablename__ = 'event_invoices'\n\n    id = db.Column(db.Integer, primary_key=True)\n    identifier = db.Column(db.String, unique=True)\n    amount = db.Column(db.Float)\n    address = db.Column(db.String)\n    city = db.Column(db.String)\n    state = db.Column(db.String)\n    country = db.Column(db.String)\n    zipcode = db.Column(db.String)\n\n    user_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='SET NULL'))\n    event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='SET NULL'))\n\n    created_at = db.Column(db.DateTime(timezone=True))\n    completed_at = db.Column(db.DateTime(timezone=True), nullable=True, default=None)\n    transaction_id = db.Column(db.String)\n    paid_via = db.Column(db.String)\n    payment_mode = db.Column(db.String)\n    brand = db.Column(db.String)\n    exp_month = db.Column(db.Integer)\n    exp_year = db.Column(db.Integer)\n    last4 = db.Column(db.String)\n    stripe_token = db.Column(db.String)\n    paypal_token = db.Column(db.String)\n    status = db.Column(db.String)\n    invoice_pdf_url = db.Column(db.String)\n\n    event = db.relationship('Event', backref='invoices')\n    user = db.relationship('User', backref='invoices')\n\n    discount_code_id = db.Column(db.Integer, db.ForeignKey('discount_codes.id', ondelete='SET NULL'),\n                                 nullable=True, default=None)\n    discount_code = db.relationship('DiscountCode', backref='event_invoices')\n\n    def __init__(self,\n                 amount=None,\n                 address=None,\n                 city=None,\n                 state=None,\n                 country=None,\n                 zipcode=None,\n                 transaction_id=None,\n                 paid_via=None,\n                 user_id=None,\n                 discount_code_id=None,\n                 event_id=None,\n                 invoice_pdf_url=None,\n                 payment_mode=None,\n                 brand=None,\n                 exp_month=None,\n                 exp_year=None,\n                 last4=None,\n                 stripe_token=None,\n                 paypal_token=None\n                 ):\n        self.identifier = get_new_identifier()\n        self.amount = amount\n        self.address = address\n        self.state = state\n        self.country = country\n        self.zipcode = zipcode\n        self.city = city\n        self.user_id = user_id\n        self.event_id = event_id\n        self.transaction_id = transaction_id\n        self.paid_via = paid_via\n        self.created_at = datetime.utcnow()\n        self.discount_code_id = discount_code_id\n        self.status = 'pending'\n        self.invoice_pdf_url = invoice_pdf_url\n        self.payment_mode = payment_mode\n        self.brand = brand\n        self.exp_month = exp_month\n        self.exp_year = exp_year\n        self.last4 = last4\n        self.stripe_token = stripe_token\n        self.paypal_token = paypal_token\n\n    def get_invoice_number(self):\n        return 'I' + str(int(time.mktime(self.created_at.timetuple()))) + '-' + str(self.id)\n\n    def __repr__(self):\n        return '<EventInvoice %r>' % self.invoice_pdf_url\n\n    def __str__(self):\n        return unicode(self).encode('utf-8')\n\n    def __unicode__(self):\n        return self.invoice_pdf_url\n", "path": "app/models/event_invoice.py"}]}