Repository: fossasia/open-event-server

Issue:
Add API blueprints of Favourite Events of a User
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

Add API blueprints of Favourite Events of a User

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
**Wanna work on this issue**


Discussion:
Others can claim.

Resolving patch:
diff --git a/app/factories/user_favourite_events.py b/app/factories/user_favourite_events.py
new file mode 100644
--- /dev/null
+++ b/app/factories/user_favourite_events.py
@@ -0,0 +1,14 @@
+import factory
+
+from app.factories.user import UserFactory
+from app.factories.event import EventFactoryBasic
+from app.models.user_favourite_event import db, UserFavouriteEvent
+
+
+class UserFavouriteEventFactory(factory.alchemy.SQLAlchemyModelFactory):
+    class Meta:
+        model = UserFavouriteEvent
+        sqlalchemy_session = db.session
+
+    user = factory.RelatedFactory(UserFactory)
+    event = factory.RelatedFactory(EventFactoryBasic)


Test patch:
diff --git a/tests/hook_main.py b/tests/hook_main.py
--- a/tests/hook_main.py
+++ b/tests/hook_main.py
@@ -62,6 +62,7 @@
 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
 
 
 
@@ -4353,3 +4354,56 @@ def panel_permissions_custom_system_role(transaction):
         panel_permission = PanelPermissionFactory()
         db.session.add(panel_permission)
         db.session.commit()
+
+# ------------------------- User Favourite Events -------------------------
+
+@hooks.before("Favourite Events > Favourite Events Collection > List All Favourite Events")
+def favourite_events_list_get(transaction):
+    """
+    GET /user-favourite-events
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_fav_event = UserFavouriteEventFactory()
+        db.session.add(user_fav_event)
+        db.session.commit()
+
+
+@hooks.before("Favourite Events > Favourite Events Collection > Create a Favourite Event")
+def favourite_events_list_post(transaction):
+    """
+    POST /user-favourite-events
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_fav_event = UserFavouriteEventFactory()
+        db.session.add(user_fav_event)
+        db.session.commit()
+
+
+@hooks.before("Favourite Events > Favourite Events Detail > Get Details")
+def favourite_event_details_get(transaction):
+    """
+    GET /user-favourite-events/1
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_fav_event = UserFavouriteEventFactory()
+        db.session.add(user_fav_event)
+        db.session.commit()
+
+
+@hooks.before("Favourite Events > Favourite Events Detail > Delete Favourite Event")
+def favourite_event_delete(transaction):
+    """
+    DELETE /user-favourite-events/1
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_fav_event = UserFavouriteEventFactory()
+        db.session.add(user_fav_event)
+        db.session.commit()