diff --git a/docs/api/api_blueprint_source.apib b/docs/api/api_blueprint_source.apib index de001c5dc8..ec4a6b930d 100644 --- a/docs/api/api_blueprint_source.apib +++ b/docs/api/api_blueprint_source.apib @@ -21,7 +21,9 @@ The Open Event API Server - + + + diff --git a/docs/api/blueprint/group/followed_groups.apib b/docs/api/blueprint/group/followed_groups.apib new file mode 100644 index 0000000000..772c301475 --- /dev/null +++ b/docs/api/blueprint/group/followed_groups.apib @@ -0,0 +1,221 @@ +# Group Followed Groups + +This Group's APIs can be used for adding a particular group to the followed group's list of the user. + +## Followed Groups Collection [/v1/user-follow-groups] + +### Create a Followed Group [POST] + ++ Request + + + Headers + + Authorization: JWT + Content-Type: application/vnd.api+json + + + Body + + { + "data": { + "type": "user-follow-group", + "relationships": { + "group": { + "data": { + "id": "1", + "type": "group" + } + } + } + } + } + ++ Response 201 (application/vnd.api+json) + + { + "data": { + "type": "user-follow-group", + "relationships": { + "group": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/group", + "related": "/v1/user-follow-groups/1/group" + } + }, + "user": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/user", + "related": "/v1/user-follow-groups/1/user" + } + } + }, + "id": "1", + "links": { + "self": "/v1/user-follow-groups/1" + } + }, + "links": { + "self": "/v1/user-follow-groups/1" + }, + "jsonapi": { + "version": "1.0" + } +} + +## Followed Groups Collection List [/v1/users/1/followed-groups] + +### List All Followed Groups of an User [GET] + ++ Request + + + Headers + + Content-Type: application/vnd.api+json + + Authorization: JWT + ++ Response 200 (application/vnd.api+json) + + { + "data": [ + { + "type": "user-follow-group", + "relationships": { + "group": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/group", + "related": "/v1/user-follow-groups/1/group" + } + }, + "user": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/user", + "related": "/v1/user-follow-groups/1/user" + } + } + }, + "id": "1", + "links": { + "self": "/v1/user-follow-groups/1" + } + } + ], + "links": { + "self": "/v1/users/1/followed-groups" + }, + "meta": { + "count": 1 + }, + "jsonapi": { + "version": "1.0" + } + } + +## Followed Users Collection List [/v1/groups/1/followers] + +### List All Followed Users of a Group [GET] + ++ Request + + + Headers + + Authorization: JWT + ++ Response 200 (application/vnd.api+json) + + { + "data": [ + { + "type": "user-follow-group", + "relationships": { + "group": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/group", + "related": "/v1/user-follow-groups/1/group" + } + }, + "user": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/user", + "related": "/v1/user-follow-groups/1/user" + } + } + }, + "id": "1", + "links": { + "self": "/v1/user-follow-groups/1" + } + } + ], + "links": { + "self": "/v1/groups/1/followers" + }, + "meta": { + "count": 1 + }, + "jsonapi": { + "version": "1.0" + } + } + +## Followed Groups Detail [/v1/user-follow-groups/{group_id}] ++ Parameters + + group_id: 1 (integer) - ID of the User Group Followed in the form of an integer + +### Get Details [GET] + ++ Request + + + Headers + + Authorization: JWT + ++ Response 200 (application/vnd.api+json) + + { + "data": { + "type": "user-follow-group", + "relationships": { + "group": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/group", + "related": "/v1/user-follow-groups/1/group" + } + }, + "user": { + "links": { + "self": "/v1/user-follow-groups/1/relationships/user", + "related": "/v1/user-follow-groups/1/user" + } + } + }, + "id": "1", + "links": { + "self": "/v1/user-follow-groups/1" + } + }, + "links": { + "self": "/v1/user-follow-groups/1" + }, + "jsonapi": { + "version": "1.0" + } + } + +### Unfollow Followed Group [DELETE] + ++ Request + + + Headers + + Authorization: JWT + ++ Response 200 (application/vnd.api+json) + + { + "meta": { + "message": "Object successfully deleted" + }, + "jsonapi": { + "version": "1.0" + } + } diff --git a/docs/api/blueprint/groups.apib b/docs/api/blueprint/group/groups.apib similarity index 100% rename from docs/api/blueprint/groups.apib rename to docs/api/blueprint/group/groups.apib diff --git a/docs/api/blueprint/session/favourite_sessions.apib b/docs/api/blueprint/session/favourite_sessions.apib index 16429b9a18..0951662cba 100644 --- a/docs/api/blueprint/session/favourite_sessions.apib +++ b/docs/api/blueprint/session/favourite_sessions.apib @@ -64,7 +64,7 @@ This Group's APIs can be used for adding a particular session to the favourite l } } -## Favourite Sessions Collection List [/v1/user/1/favourite-sessions] +## Favourite Sessions Collection List [/v1/users/1/favourite-sessions] ### List All Favourite Sessions of an User [GET] diff --git a/tests/factories/group.py b/tests/factories/group.py index c68c0dcfb0..8ea4a1de25 100644 --- a/tests/factories/group.py +++ b/tests/factories/group.py @@ -2,6 +2,7 @@ from app.models.group import Group from tests.factories.base import BaseFactory +from tests.factories.event import EventFactoryBasic from tests.factories.user import UserFactory @@ -17,5 +18,11 @@ class GroupFactory(GroupFactoryBase): user_id = 1 +class GroupFactoryBasic(GroupFactoryBase): + user_id = 1 + event_id = 1 + + class GroupSubFactory(GroupFactoryBase): user = factory.SubFactory(UserFactory) + event = factory.RelatedFactory(EventFactoryBasic) diff --git a/tests/factories/user_follow_group.py b/tests/factories/user_follow_group.py new file mode 100644 index 0000000000..99c07be8a9 --- /dev/null +++ b/tests/factories/user_follow_group.py @@ -0,0 +1,14 @@ +import factory + +from app.models.user import User +from app.models.user_follow_group import UserFollowGroup +from tests.factories.base import BaseFactory +from tests.factories.group import GroupFactoryBasic + + +class UserFollowGroupFactory(BaseFactory): + class Meta: + model = UserFollowGroup + + user = factory.LazyAttribute(lambda a: User.query.first()) + group = factory.SubFactory(GroupFactoryBasic) diff --git a/tests/hook_main.py b/tests/hook_main.py index 61b452b736..214380c2b9 100644 --- a/tests/hook_main.py +++ b/tests/hook_main.py @@ -27,6 +27,7 @@ from tests.factories.event import EventFactoryBasic from tests.factories.group import GroupFactory from tests.factories.social_link import SocialLinkFactory +from tests.factories.user_follow_group import UserFollowGroupFactory from tests.factories.microlocation import MicrolocationFactory from tests.factories.image_size import EventImageSizeFactory, SpeakerImageSizeFactory from tests.factories.page import PageFactory @@ -49,6 +50,7 @@ from tests.factories.speakers_call import SpeakersCallFactory from tests.factories.tax import TaxFactory from tests.factories.session import SessionFactory, SessionFactoryBasic +from tests.factories.group import GroupFactory, GroupFactoryBasic from tests.factories.speaker import SpeakerFactory from tests.factories.ticket import TicketFactory from tests.factories.attendee import AttendeeFactory, AttendeeOrderSubFactory @@ -4809,6 +4811,73 @@ def favourite_session_delete(transaction): db.session.commit() +# ------------------------- User Follow Group ------------------------- + + +@hooks.before("Follow Groups > Follow Groups Collection List > List All Followed Groups") +def follow_groupss_list_get(transaction): + """ + GET /user-follow-groups + :param transaction: + :return: + """ + with stash['app'].app_context(): + user_follow_group = UserFollowGroupFactory() + db.session.add(user_follow_group) + db.session.commit() + + +@hooks.before("Followed Groups > Follow Groups Collection > Create a Followed Groups") +def followed_groups_list_post(transaction): + """ + POST /user-follow-groups + :param transaction: + :return: + """ + with stash['app'].app_context(): + group = GroupFactoryBasic() + db.session.add(group) + db.session.commit() + + +@hooks.before("Followed Groups > Followed Groups Detail > Get Details") +def follow_group_details_get(transaction): + """ + GET /user-follow-groups/1 + :param transaction: + :return: + """ + with stash['app'].app_context(): + user_follow_group = UserFollowGroupFactory() + db.session.add(user_follow_group) + db.session.commit() + +@hooks.before("Followed Groups > Followed Users Collection List > Followed Users Collection List") +def list_group_followers(transaction): + """ + GET /groups/1/followers + :param transaction: + :return: + """ + with stash['app'].app_context(): + user_follow_group = UserFollowGroupFactory() + db.session.add(user_follow_group) + db.session.commit() + + +@hooks.before("Follow Groups > Follow Groups Detail > Delete Followed Groups") +def follow_group_delete(transaction): + """ + DELETE /user-follow-groups/1 + :param transaction: + :return: + """ + with stash['app'].app_context(): + user_follow_group = UserFollowGroupFactory() + db.session.add(user_follow_group) + db.session.commit() + + # ------------------------- Admin Statistics -------------------------