Repository: fossasia/open-event-server

Issue:
My-Ticket route is broken.
Some recent PR broke the `My-Ticket` Route of Frontend 

Stacktrace :
```py
 File "/Users/kush/open-event-server/venv/lib/python3.7/site-packages/marshmallow_jsonapi/flask.py", line 138, in get_self_url
    return self.get_url(obj, self.self_view, self.self_view_kwargs)
  File "/Users/kush/open-event-server/venv/lib/python3.7/site-packages/marshmallow_jsonapi/flask.py", line 125, in get_url
    return flask.url_for(**kwargs)
  File "/Users/kush/open-event-server/venv/lib/python3.7/site-packages/flask/helpers.py", line 370, in url_for
    return appctx.app.handle_url_build_error(error, endpoint, values)
  File "/Users/kush/open-event-server/venv/lib/python3.7/site-packages/flask/app.py", line 2215, in handle_url_build_error
    reraise(exc_type, exc_value, tb)
  File "/Users/kush/open-event-server/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/kush/open-event-server/venv/lib/python3.7/site-packages/flask/helpers.py", line 358, in url_for
    endpoint, values, method=method, force_external=external
  File "/Users/kush/open-event-server/venv/lib/python3.7/site-packages/werkzeug/routing.py", line 2020, in build
    raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'v1.order_invoice' with values ['order_identifier']. Did you mean 'v1.order_event_invoice' instead?
```


Discussion:
cc: @iamareebjamal 
#6656 might broke this..
Also breaking while buying a ticket

```
INFO:werkzeug:127.0.0.1 - - [18/Dec/2019 00:58:43] "POST /v1/orders HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/flask.py", line 70, in sentry_patched_wsgi_app
    environ, start_response
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/wsgi.py", line 120, in __call__
    reraise(*_capture_exception(hub))
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/_compat.py", line 57, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/wsgi.py", line 116, in __call__
    _sentry_start_response, start_response, span
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/flask.py", line 69, in <lambda>
    return SentryWsgiMiddleware(lambda *a, **kw: old_app(self, *a, **kw))(
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/codedsun/Documents/FOSS/open-event-server/app/__init__.py", line 79, in __call__
    return self.app(environ, start_response)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/codedsun/Documents/FOSS/open-event-server/app/api/helpers/permissions.py", line 46, in decorator
    return fn(*args, **kwargs)
  File "/usr/local/bin/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 32, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 88, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/bin/src/flask-rest-jsonapi/flask_rest_jsonapi/resource.py", line 68, in dispatch_request
    response = method(*args, **kwargs)
  File "/usr/local/bin/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 56, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/bin/src/flask-rest-jsonapi/flask_rest_jsonapi/resource.py", line 204, in post
    result = schema.dump(obj).data
  File "/usr/local/lib/python3.7/site-packages/marshmallow/schema.py", line 509, in dump
    **kwargs
  File "/usr/local/lib/python3.7/site-packages/marshmallow/marshalling.py", line 138, in serialize
    index=(index if index_errors else None)
  File "/usr/local/lib/python3.7/site-packages/marshmallow/marshalling.py", line 62, in call_and_store
    value = getter_func(data)
  File "/usr/local/lib/python3.7/site-packages/marshmallow/marshalling.py", line 132, in <lambda>
    getter = lambda d: field_obj.serialize(attr_name, d, accessor=accessor)
  File "/Users/codedsun/Documents/FOSS/open-event-server/app/api/schema/__init__.py", line 8, in serialize
    return self._serialize(None, attr, obj)
  File "/usr/local/lib/python3.7/site-packages/marshmallow_jsonapi/fields.py", line 246, in _serialize
    self_url = self.get_self_url(obj)
  File "/usr/local/lib/python3.7/site-packages/marshmallow_jsonapi/flask.py", line 138, in get_self_url
    return self.get_url(obj, self.self_view, self.self_view_kwargs)
  File "/usr/local/lib/python3.7/site-packages/marshmallow_jsonapi/flask.py", line 125, in get_url
    return flask.url_for(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask/helpers.py", line 356, in url_for
    return appctx.app.handle_url_build_error(error, endpoint, values)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2061, in handle_url_build_error
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/flask/helpers.py", line 345, in url_for
    force_external=external)
  File "/usr/local/lib/python3.7/site-packages/werkzeug/routing.py", line 2005, in build
    raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'v1.order_invoice' with values ['order_identifier']. Did you mean 'v1.order_event_invoice' instead?
```
> #6656 might broke this..

@codedsun If it is the root cause, I am working on making the PR
@vishakhanihore Let @iamareebjamal confirm what went wrong.
@mrsaicharan1 can you please check it m?

On Wed, 18 Dec, 2019, 01:13 Suneet Srivastava, <notifications@github.com>
wrote:

> @vishakhanihore <https://github.com/vishakhanihore> Let @iamareebjamal
> <https://github.com/iamareebjamal> confirm what went wrong.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/fossasia/open-event-server/issues/6673?email_source=notifications&email_token=AM6PS4UHAGM3IMOLD2AKHOTQZETVJA5CNFSM4J3UPVU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHDXBYQ#issuecomment-566718690>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AM6PS4UVGFJOSNQK2ICRDUDQZETVJANCNFSM4J3UPVUQ>
> .
>

@kushthedude @mariobehling The solution implemented was a workaround. I am making a new PR reverting the workaround and implementing the solution.

Resolving patch:
diff --git a/app/api/schema/orders.py b/app/api/schema/orders.py
--- a/app/api/schema/orders.py
+++ b/app/api/schema/orders.py
@@ -117,7 +117,7 @@ def initial_values(self, data):
                          type_="event")
 
     event_invoice = Relationship(attribute='invoice',
-                                 self_view='v1.order_invoice',
+                                 self_view='v1.order_event_invoice',
                                  self_view_kwargs={'order_identifier': '<identifier>'},
                                  related_view='v1.event_invoice_detail',
                                  related_view_kwargs={'id': '<id>'},


Test patch: