from auth.auth_view import RegisteredAuthorizedView from campaigns.schemas import CampaignTabRequestModel, campaigns_tab_response_schema, campaign_tab_request_schema from campaigns.services.campaigns_tab_service import CampaignsTabService from flask_apispec import marshal_with, use_kwargs, doc @doc(tags=['CampaignsTab']) class CampaignsTabView(RegisteredAuthorizedView): service = CampaignsTabService() @doc(description='Retrieve campaigns tab by project_id') @use_kwargs(campaign_tab_request_schema, location='query') @marshal_with(schema=campaigns_tab_response_schema, code=200, description='JSON with campaigns details.') @marshal_with(schema=None, code=401, description='User is not authenticated.') @marshal_with(schema=None, code=403, description='User does not have access to the project') @marshal_with(schema=None, code=404, description='Project or campaign is not found.') def get(self, params, project_id): self.permissions.can_access_project(project_id) return self.service.get_campaigns_tab_by_project(project_id=project_id, params=params)