chore: Add articles metadata (#5125)

This commit is contained in:
Tejaswini Chile
2022-07-28 13:59:16 +05:30
committed by GitHub
parent 7f48cffeb3
commit 41df70fb96
19 changed files with 74 additions and 15 deletions

View File

@@ -2,10 +2,11 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
before_action :portal
before_action :check_authorization
before_action :fetch_article, except: [:index, :create]
before_action :set_current_page, only: [:index]
def index
@articles = @portal.articles
@articles = @articles.search(list_params) if params[:payload].present?
@articles = @articles.search(list_params) if list_params.present?
end
def create
@@ -45,8 +46,10 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
end
def list_params
params.require(:payload).permit(
:category_slug, :locale, :query, :page
)
params.permit(:locale, :query, :page, :category_slug)
end
def set_current_page
@current_page = params[:page] || 1
end
end

View File

@@ -2,6 +2,7 @@ class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseControlle
before_action :portal
before_action :check_authorization
before_action :fetch_category, except: [:index, :create]
before_action :set_current_page, only: [:index]
def index
@categories = @portal.categories.search(params)
@@ -49,4 +50,8 @@ class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseControlle
:name, :description, :position, :slug, :locale, :parent_category_id, :associated_category_id
)
end
def set_current_page
@current_page = params[:page] || 1
end
end

View File

@@ -3,6 +3,7 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
before_action :fetch_portal, except: [:index, :create]
before_action :check_authorization
before_action :set_current_page, only: [:index]
def index
@portals = Current.account.portals
@@ -66,4 +67,8 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
def portal_member_params
params.require(:portal).permit(:account_id, member_ids: [])
end
def set_current_page
@current_page = params[:page] || 1
end
end