New groups

This commit is contained in:
2458773093
2019-07-15 16:47:05 +03:00
parent fd50f03304
commit 1fabd28498
30 changed files with 809 additions and 285 deletions

View File

@@ -10,10 +10,24 @@ class Api::V1::GroupsController < Api::BaseController
before_action :set_group, except: [:index, :create]
def index
@groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account }).all
case current_tab
when 'featured'
@groups = Group.where(is_featured: true).limit(25).all
when 'member'
@groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account }).all
when 'admin'
@groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account, write_permissions: true }).all
end
render json: @groups, each_serializer: REST::GroupSerializer
end
def current_tab
tab = 'featured'
tab = params[:tab] if ['featured', 'member', 'admin'].include? params[:tab]
return tab
end
def show
render json: @group, serializer: REST::GroupSerializer
end