forked from fossasia/open-event-server
/
hook_main.py
4484 lines (3775 loc) · 119 KB
/
hook_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os.path as path
import sys
import dredd_hooks as hooks
import requests
# DO NOT REMOVE THIS. This adds the project root for successful imports. Imports from the project directory should be
# placed only below this
sys.path.insert(1, path.abspath(path.join(__file__, "../..")))
from flask_migrate import Migrate
from flask import Flask
from app.models import db
from app.models.user import OWNER
# imports from factories
from app.factories.event_location import EventLocationFactory
from app.factories.custom_system_role import CustomSysRoleFactory
from app.factories.panel_permission import PanelPermissionFactory
from app.factories.user import UserFactory
from app.factories.notification_action import NotificationActionFactory
from app.factories.notification import NotificationFactory
from app.factories.event import EventFactoryBasic
from app.factories.social_link import SocialLinkFactory
from app.factories.microlocation import MicrolocationFactory
from app.factories.image_size import EventImageSizeFactory, SpeakerImageSizeFactory
from app.factories.page import PageFactory
from app.factories.event_copyright import EventCopyrightFactory
from app.factories.setting import SettingFactory
from app.factories.event_type import EventTypeFactory
from app.factories.discount_code import DiscountCodeFactory, DiscountCodeTicketFactory
from app.factories.access_code import AccessCodeFactory
from app.factories.custom_form import CustomFormFactory
from app.factories.faq import FaqFactory
from app.factories.event_topic import EventTopicFactory
from app.factories.event_invoice import EventInvoiceFactory
from app.factories.event_sub_topic import EventSubTopicFactory
from app.factories.sponsor import SponsorFactory
from app.factories.speakers_call import SpeakersCallFactory
from app.factories.tax import TaxFactory
from app.factories.session import SessionFactory
from app.factories.speaker import SpeakerFactory
from app.factories.ticket import TicketFactory
from app.factories.attendee import AttendeeFactory
from app.factories.session_type import SessionTypeFactory
from app.factories.track import TrackFactory
from app.factories.ticket_tag import TicketTagFactory
from app.factories.role import RoleFactory
from app.factories.module import ModuleFactory
from app.factories.ticket_fee import TicketFeesFactory
from app.factories.role_invite import RoleInviteFactory
from app.factories.custom_placeholder import CustomPlaceholderFactory
from app.factories.user_permission import UserPermissionFactory
from app.factories.email_notification import EmailNotificationFactory
from app.factories.activities import ActivityFactory
from app.factories.stripe_authorization import StripeAuthorizationFactory
from app.factories.mail import MailFactory
from app.factories.order import OrderFactory
from app.factories.faq_type import FaqTypeFactory
from app.factories.user_email import UserEmailFactory
from app.factories.feedback import FeedbackFactory
from app.factories.service import ServiceFactory
from app.factories.message_setting import MessageSettingsFactory
from app.factories.user_favourite_events import UserFavouriteEventFactory
stash = {}
api_username = "open_event_test_user@fossasia.org"
api_password = "fossasia"
api_uri = "http://localhost:5000/v1/auth/login"
def obtain_token():
data = {
"email": api_username,
"password": api_password
}
url = api_uri
response = requests.post(url, json=data)
response.raise_for_status()
parsed_body = response.json()
token = parsed_body["access_token"]
return token
def create_super_admin(email, password):
user = UserFactory(email=email, password=password, is_super_admin=True,
is_admin=True, is_verified=True)
db.session.add(user)
db.session.commit()
return user
@hooks.before_all
def before_all(transaction):
app = Flask(__name__)
app.config.from_object('config.TestingConfig')
db.init_app(app)
Migrate(app, db)
stash['app'] = app
stash['db'] = db
@hooks.before_each
def before_each(transaction):
with stash['app'].app_context():
db.engine.execute("drop schema if exists public cascade")
db.engine.execute("create schema public")
db.create_all()
create_super_admin(api_username, api_password)
if 'token' in stash:
print('adding a token')
else:
stash['token'] = obtain_token()
transaction['request']['headers']['Authorization'] = "JWT " + stash['token']
@hooks.after_each
def after_each(transaction):
with stash['app'].app_context():
db.session.remove()
# ------------------------- Authentication -------------------------
@hooks.before("Authentication > JWT Authentication > Authenticate and generate token")
@hooks.before("Authentication > JWT Authentication > Authenticate with remember me")
@hooks.before("Authentication > JWT Authentication > Authenticate with remember me for mobile")
def skip_auth(transaction):
"""
POST /v1/auth/login
:param transaction:
:return:
"""
transaction['request']['headers']['Authorization'] = ""
with stash['app'].app_context():
user = UserFactory(email="email@example.com", password="password", is_verified=True)
db.session.add(user)
db.session.commit()
print('User Created')
@hooks.before("Authentication > Re-Authentication > Generate fresh token")
@hooks.before("Authentication > Token Refresh > Access Token Refresh for Web")
@hooks.before("Authentication > Token Refresh > Access Token Refresh for mobile")
def skip_token_refresh(transaction):
"""
POST /v1/auth/token/refresh
:param transaction:
:return:
"""
transaction['skip'] = True
# ------------------------- Users -------------------------
@hooks.before("Users > Users Collection > List All Users")
def user_get_list(transaction):
"""
GET /users
:param transaction:
:return:
"""
with stash['app'].app_context():
user = UserFactory()
db.session.add(user)
db.session.commit()
@hooks.before("Users > Users Collection > Create User")
def user_post(transaction):
"""
POST /users
:param transaction:
:return:
"""
with stash['app'].app_context():
user = UserFactory()
db.session.add(user)
db.session.commit()
@hooks.before("Users > User Details > Get Details")
def user_get_detail(transaction):
"""
GET /users/2
:param transaction:
:return:
"""
with stash['app'].app_context():
user = UserFactory()
db.session.add(user)
db.session.commit()
@hooks.before("Users > User Details > Update User")
def user_patch(transaction):
"""
PATCH /users/2
:param transaction:
:return:
"""
with stash['app'].app_context():
user = UserFactory()
db.session.add(user)
db.session.commit()
@hooks.before("Users > User Details > Delete User")
def user_delete(transaction):
"""
DELETE /users/2
:param transaction:
:return:
"""
with stash['app'].app_context():
user = UserFactory()
db.session.add(user)
db.session.commit()
@hooks.before("Users > Get User Details for a Notification > Get User Details for a Notification")
def user_notification(transaction):
"""
GET /notifications/1/user
:param transaction:
:return:
"""
with stash['app'].app_context():
notification_action = NotificationActionFactory()
db.session.add(notification_action)
db.session.commit()
notification = NotificationFactory()
notification.actions = [notification_action]
db.session.add(notification)
db.session.commit()
@hooks.before("Users > Get User Details for an Event Invoice > Get User Details for an Event Invoice")
def user_event_invoice(transaction):
"""
GET /event-invoices/1/user
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
@hooks.before("Users > Get User Details for an Access Code > Get User Details for an Access Code")
def user_access_code(transaction):
"""
GET /access-codes/1/user
:param transaction:
:return:
"""
with stash['app'].app_context():
access_code = AccessCodeFactory()
db.session.add(access_code)
db.session.commit()
@hooks.before("Users > Get User Details for an Email Notification > Get User Details for an Email Notification")
def user_email_notification(transaction):
"""
GET /email-notifications/1/user
:param transaction:
:return:
"""
with stash['app'].app_context():
email_notification = EmailNotificationFactory()
db.session.add(email_notification)
db.session.commit()
@hooks.before("Users > Get User Details for a Discount Code > Get User Details for a Discount Code")
def user_discount_code(transaction):
"""
GET /discount-codes/1/user
:param transaction:
:return:
"""
with stash['app'].app_context():
discount_code = DiscountCodeFactory()
db.session.add(discount_code)
db.session.commit()
@hooks.before("Users > Get User Details for a Speaker > Get User Details for a Speaker")
def user_speaker(transaction):
"""
GET /speakers/1/user
:param transaction:
:return:
"""
with stash['app'].app_context():
speaker = SpeakerFactory()
db.session.add(speaker)
db.session.commit()
@hooks.before("Users > Check if the email is available > Check if email is available")
def user_check_email(transaction):
"""
POST /users/checkEmail
:param transaction:
:return:
"""
transaction['skip'] = True
# ------------------------- Events -------------------------
@hooks.before("Events > Events Collection > List All Events")
def event_get_list(transaction):
"""
GET /events
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
@hooks.before("Events > Events Collection > Create Event")
def event_post(transaction):
"""
POST /events
:param transaction:
:return:
"""
with stash['app'].app_context():
module = ModuleFactory()
db.session.add(module)
RoleFactory(name=OWNER) # TODO: Change to get_or_create in event after_created
db.session.commit()
@hooks.before("Events > Event Details > Event Details")
def event_get_detail(transaction):
"""
GET /events/1
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
@hooks.before("Events > Event Details > Update Event")
def event_patch(transaction):
"""
PATCH /events/1
:param transaction:
:return:
"""
with stash['app'].app_context():
module = ModuleFactory()
db.session.add(module)
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
@hooks.before("Events > Event Details > Delete Event")
def event_delete(transaction):
"""
DELETE /events/1
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
@hooks.before("Events > Events of an Event Type > List All Events of an Event Type")
def evnt_type_event_get_list(transaction):
"""
GET /event-types/1/events
:param transaction:
:return:
"""
with stash['app'].app_context():
event_type = EventTypeFactory()
db.session.add(event_type)
event = EventFactoryBasic(event_type_id=1)
db.session.add(event)
db.session.commit()
@hooks.before("Events > Events under an Event Topic > List All Events under an Event Topic")
def evnt_topic_event_get_list(transaction):
"""
GET /event-topics/1/events
:param transaction:
:return:
"""
with stash['app'].app_context():
event_topic = EventTopicFactory()
db.session.add(event_topic)
event = EventFactoryBasic(event_topic_id=1)
db.session.add(event)
db.session.commit()
@hooks.before("Events > Events under an Event Sub-topic > List All Events under an Event Sub-topic")
def evnt_sub_topic_event_get_list(transaction):
"""
GET /event-sub-topics/1/events
:param transaction:
:return:
"""
with stash['app'].app_context():
event_sub_topic = EventSubTopicFactory()
db.session.add(event_sub_topic)
event = EventFactoryBasic(event_sub_topic_id=1)
db.session.add(event)
db.session.commit()
@hooks.before("Events > Events under a User > List All Events under a User")
def user_event_get_list(transaction):
"""
GET /users/1/events
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
@hooks.before("Events > Events for a Discount Code > List All Events for a Discount Code")
def discount_code_event_get_list(transaction):
"""
GET /discount-codes/1/events
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
discount_code = DiscountCodeFactory(event_id=1)
db.session.add(discount_code)
db.session.commit()
@hooks.before("Events > Get Event for a Ticket > Event Details for a Ticket")
def event_ticket(transaction):
"""
GET /tickets/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
ticket = TicketFactory()
db.session.add(ticket)
db.session.commit()
@hooks.before("Events > Get Event for a Microlocation > Event Details for a Microlocation")
def event_microlocation(transaction):
"""
GET /microlocations/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
microlocation = MicrolocationFactory()
db.session.add(microlocation)
db.session.commit()
@hooks.before("Events > Get Event for a Social Link > Event Details for a Social Link")
def event_social_link(transaction):
"""
GET /social-links/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
social_link = SocialLinkFactory()
db.session.add(social_link)
db.session.commit()
@hooks.before("Events > Get Event for a Sponsor > Event Details for a Sponsor")
def event_sponsor(transaction):
"""
GET /sponsors/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
sponsor = SponsorFactory()
db.session.add(sponsor)
db.session.commit()
@hooks.before("Events > Get Event for a Speakers Call > Event Details for a Speakers Call")
def event_speakers_call(transaction):
"""
GET /speakers-calls/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
speakers_call = SpeakersCallFactory()
db.session.add(speakers_call)
db.session.commit()
@hooks.before("Events > Get Event for a Track > Event Details for a Track")
def event_track(transaction):
"""
GET /tracks/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
track = TrackFactory()
db.session.add(track)
db.session.commit()
@hooks.before("Events > Get Event for a Session Type > Event Details for a Session Type")
def event_session_types(transaction):
"""
GET /session-types/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
session_type = SessionTypeFactory()
db.session.add(session_type)
db.session.commit()
@hooks.before("Events > Get Event for an Event Copyright > Event Details for an Event Copyright")
def event_event_copyright(transaction):
"""
GET /event-copyrights/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
event_copyright = EventCopyrightFactory()
db.session.add(event_copyright)
db.session.commit()
@hooks.before("Events > Get Event for a Tax > Event Details for a Tax")
def event_tax(transaction):
"""
GET /tax/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
tax = TaxFactory()
db.session.add(tax)
db.session.commit()
@hooks.before("Events > Get Event for an Event Invoice > Event Details for an Event Invoice")
def event_event_invoice(transaction):
"""
GET /event-invoices/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
@hooks.before("Events > Get Event for a Discount Code > Event Details for a Discount Code")
def event_discount_code(transaction):
"""
GET /discount-codes/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
discount_code = DiscountCodeFactory(event_id=1)
db.session.add(discount_code)
db.session.commit()
@hooks.before("Events > Get Event for a Session > Event Details for a Session")
def event_sessions(transaction):
"""
GET /sessions/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
session = SessionFactory()
db.session.add(session)
db.session.commit()
@hooks.before("Events > Get Event for a Ticket Tag > Event Details for a Ticket Tag")
def event_ticket_tag(transaction):
"""
GET /ticket-tags/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
ticket_tag = TicketTagFactory()
db.session.add(ticket_tag)
db.session.commit()
@hooks.before("Events > Get Event for a Role Invite > Event Details for a Role Invite")
def event_role_invite(transaction):
"""
GET /role-invites/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
role_invite = RoleInviteFactory()
db.session.add(role_invite)
db.session.commit()
@hooks.before("Events > Get Event for a Speaker > Event Details for a Speaker")
def event_speaker(transaction):
"""
GET /speakers/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
speaker = SpeakerFactory()
db.session.add(speaker)
db.session.commit()
@hooks.before("Events > Get Event for an Email Notification > Event Details for an Email Notification")
def event_email_notification(transaction):
"""
GET /email-notifications/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
email_notification = EmailNotificationFactory()
db.session.add(email_notification)
db.session.commit()
@hooks.before("Events > Get Event for an Attendee > Event Details for an Attendee")
def event_attendee(transaction):
"""
GET /attendees/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
attendee = AttendeeFactory()
db.session.add(attendee)
db.session.commit()
@hooks.before("Events > Get Event for a Custom Form > Event Details for a Custom Form")
def event_custom_form(transaction):
"""
GET /custom-forms/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
custom_form = CustomFormFactory()
db.session.add(custom_form)
db.session.commit()
@hooks.before("Events > Get Event for a FAQ > Event Details for a FAQ")
def event_faq(transaction):
"""
GET /faqs/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
faq = FaqFactory()
db.session.add(faq)
db.session.commit()
@hooks.before("Events > Get Event for a Stripe Authorization > Event Details for a Stripe Authorization")
def event_stripe_authorization(transaction):
"""
GET /stripe-authorization/1/event
:param transaction:
:return:
"""
with stash['app'].app_context():
stripe_authorization = StripeAuthorizationFactory()
db.session.add(stripe_authorization)
db.session.commit()
# ------------------------- Feedback -------------------------
@hooks.before("Feedback > Feedback Collection > Create Feedback")
def feedback_post(transaction):
"""
POST /feedbacks
:param transaction:
:return:
"""
with stash['app'].app_context():
session = SessionFactory()
db.session.add(session)
db.session.commit()
@hooks.before("Feedback > Feedback Detail > Feedback Detail")
def feedback_get_detail(transaction):
"""
GET /feedbacks/1
:param transaction:
:return:
"""
with stash['app'].app_context():
feedback = FeedbackFactory()
db.session.add(feedback)
db.session.commit()
@hooks.before("Feedback > Feedback Detail > Update Feedback")
def feedback_patch(transaction):
"""
PATCH /feedbacks/1
:param transaction:
:return:
"""
with stash['app'].app_context():
feedback = FeedbackFactory()
db.session.add(feedback)
db.session.commit()
@hooks.before("Feedback > Feedback Detail > Delete Feedback")
def feedback_delete(transaction):
"""
DELETE /feedbacks/1
:param transaction:
:return:
"""
with stash['app'].app_context():
feedback = FeedbackFactory()
db.session.add(feedback)
db.session.commit()
@hooks.before(
"Feedback > Event Feedback Collection > List All Feedbacks for an Event")
def feedback_get_list(transaction):
"""
GET /events/1/Feedbacks
:param transaction:
:return:
"""
with stash['app'].app_context():
feedback = FeedbackFactory()
db.session.add(feedback)
db.session.commit()
# ------------------------- Copyright -------------------------
@hooks.before("Copyright > Event Copyright > Create Event Copyright")
def copyright_post(transaction):
"""
POST /event-copyrights
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
@hooks.before("Copyright > Event Copyright Details > Event Copyright Details")
def copyright_get_detail(transaction):
"""
GET /event-copyrights/1
:param transaction:
:return:
"""
with stash['app'].app_context():
copyright = EventCopyrightFactory()
db.session.add(copyright)
db.session.commit()
@hooks.before("Copyright > Event Copyright Details > Update Event Copyright")
def copyright_patch(transaction):
"""
PATCH /event-copyrights/1
:param transaction:
:return:
"""
with stash['app'].app_context():
copyright = EventCopyrightFactory()
db.session.add(copyright)
db.session.commit()
@hooks.before("Copyright > Event Copyright Details > Delete Event Copyright")
def copyright_delete(transaction):
"""
DELETE /event-copyrights/1
:param transaction:
:return:
"""
with stash['app'].app_context():
copyright = EventCopyrightFactory()
db.session.add(copyright)
db.session.commit()
@hooks.before("Copyright > Get Event Copyright for an Event > Event Copyright Details")
def event_copyright(transaction):
"""
GET /events/1/event-copyright
:param transaction:
:return:
"""
with stash['app'].app_context():
copyright = EventCopyrightFactory()
db.session.add(copyright)
db.session.commit()
# ------------------------- Invoices -------------------------
@hooks.before("Invoices > Event Invoices > Get Event Invoices")
def invoice_get_list(transaction):
"""
GET /event-invoices
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
@hooks.before("Invoices > Event Invoices Details > Event Invoices Details")
def invoice_get_detail(transaction):
"""
GET /event-invoices/1
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
@hooks.before("Invoices > Event Invoices Details > Update Event Invoices")
def invoice_patch(transaction):
"""
PATCH /event-invoices/1
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
@hooks.before("Invoices > Event Invoices Details > Delete Event Invoices")
def invoice_delete(transaction):
"""
DELETE /event-invoices/1
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
@hooks.before("Invoices > Event Invoice List of an Event > List Event Invoices of an Event")
def event_event_invoice_get_list(transaction):
"""
GET /events/1/event-invoices
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
@hooks.before("Invoices > Event Invoice List of a User > List Event Invoices of a User")
def user_event_invoice_get_list(transaction):
"""
GET /users/1/event-invoices
:param transaction:
:return:
"""
with stash['app'].app_context():
event_invoice = EventInvoiceFactory()
db.session.add(event_invoice)
db.session.commit()
# ------------------------- Microlocation -------------------------
@hooks.before("Microlocations > Microlocation Collection > Create Microlocation")
def microlocation_post(transaction):
"""
POST /events/1/microlocations
:param transaction:
:return:
"""
with stash['app'].app_context():
event = EventFactoryBasic()
db.session.add(event)
db.session.commit()
@hooks.before("Microlocations > Microlocation Details > Microlocation Details")
def microlation_get_detail(transaction):
"""
GET /microlocations/1
:param transaction:
:return:
"""
with stash['app'].app_context():
microlocation = MicrolocationFactory()
db.session.add(microlocation)
db.session.commit()
@hooks.before("Microlocations > Microlocation Details > Update Microlocation")
def microlocation_patch(transaction):
"""
PATCH /microlocations/1
:param transaction:
:return:
"""
with stash['app'].app_context():
microlocation = MicrolocationFactory()
db.session.add(microlocation)
db.session.commit()
@hooks.before("Microlocations > Microlocation Details > Delete Microlocation")
def microlocation_delete(transaction):
"""
DELETE /microlocations/1
:param transaction:
:return:
"""