Added pages and routes for Groups by tag and category

• Added:
- pages and routes for Groups by tag and category
This commit is contained in:
mgabdev
2020-09-14 17:12:45 -05:00
parent cb30e0dcbf
commit fafd1ef658
10 changed files with 355 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ class Api::V1::GroupsController < Api::BaseController
before_action -> { doorkeeper_authorize! :write, :'write:groups' }, except: [:index, :show]
before_action :require_user!, except: [:index, :show]
before_action :set_group, except: [:index, :create]
before_action :set_group, except: [:index, :create, :by_category, :by_tag]
def index
case current_tab
@@ -34,6 +34,26 @@ class Api::V1::GroupsController < Api::BaseController
render json: @groups, each_serializer: REST::GroupSerializer
end
def by_category
if !current_user
render json: { error: 'This method requires an authenticated user' }, status: 422
end
@groups = []
render json: @groups, each_serializer: REST::GroupSerializer
end
def by_tag
if !current_user
render json: { error: 'This method requires an authenticated user' }, status: 422
end
@groups = []
render json: @groups, each_serializer: REST::GroupSerializer
end
def current_tab
tab = 'featured'
tab = params[:tab] if ['featured', 'member', 'admin', 'new'].include? params[:tab]