Repository: fossasia/open-event-server

Issue:
POST not working on /v1/event-invoices
**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




Discussion:

Resolving patch:
diff --git a/app/api/__init__.py b/app/api/__init__.py
--- a/app/api/__init__.py
+++ b/app/api/__init__.py
@@ -23,7 +23,7 @@
 from app.api.sponsors import SponsorList, SponsorListPost, SponsorDetail, SponsorRelationship
 from app.api.tracks import TrackList, TrackListPost, TrackDetail, TrackRelationshipOptional, TrackRelationshipRequired
 from app.api.speakers_calls import SpeakersCallList, SpeakersCallDetail, SpeakersCallRelationship
-from app.api.event_invoices import EventInvoiceList, EventInvoiceListPost, EventInvoiceDetail, \
+from app.api.event_invoices import EventInvoiceList, EventInvoiceDetail, \
     EventInvoiceRelationshipRequired, EventInvoiceRelationshipOptional
 from app.api.role_invites import RoleInviteListPost, RoleInviteList, RoleInviteDetail, RoleInviteRelationship
 from app.api.image_sizes import ImageSizeList, ImageSizeDetail
@@ -290,8 +290,7 @@
 api.route(TaxRelationship, 'tax_event', '/tax/<int:id>/relationships/event')
 
 # event invoices
-api.route(EventInvoiceListPost, '/event-invoices')
-api.route(EventInvoiceList, 'event_invoice_list', '/events/<int:event_id>/event-invoices',
+api.route(EventInvoiceList, 'event_invoice_list', '/event-invoices', '/events/<int:event_id>/event-invoices',
           '/events/<event_identifier>/event-invoices', '/users/<int:user_id>/event-invoices')
 api.route(EventInvoiceDetail, 'event_invoice_detail', '/event-invoices/<int:id>')
 api.route(EventInvoiceRelationshipRequired, 'event_invoice_user',
diff --git a/app/api/event_invoices.py b/app/api/event_invoices.py
--- a/app/api/event_invoices.py
+++ b/app/api/event_invoices.py
@@ -75,21 +75,6 @@ class Meta:
                                   type_='discount-code')
 
 
-class EventInvoiceListPost(ResourceList):
-    """
-    List and create Tracks
-    """
-    def before_post(self, args, kwargs, data):
-        require_relationship(['user', 'event'], data)
-
-        if not has_access('is_admin'):
-            raise ForbiddenException({'source': ''}, 'Admin access is required.')
-
-    schema = EventInvoiceSchema
-    data_layer = {'session': db.session,
-                  'model': EventInvoice}
-
-
 class EventInvoiceList(ResourceList):
     """
     List and Create Event Invoices


Test patch:
diff --git a/tests/hook_main.py b/tests/hook_main.py
--- a/tests/hook_main.py
+++ b/tests/hook_main.py
@@ -741,19 +741,6 @@ def invoice_get_list(transaction):
         db.session.commit()
 
 
-@hooks.before("Invoices > Event Invoices > Create Event Invoices")
-def invoice_post(transaction):
-    """
-    POST /event-invoices
-    :param transaction:
-    :return:
-    """
-    with stash['app'].app_context():
-        event = EventFactoryBasic()
-        db.session.add(event)
-        db.session.commit()
-
-
 @hooks.before("Invoices > Event Invoices Details > Event Invoices Details")
 def invoice_get_detail(transaction):
     """