feat: Portal endpoint (#4633)

This commit is contained in:
Tejaswini Chile
2022-05-16 13:59:59 +05:30
committed by GitHub
parent 6535624cd6
commit 938fb887c4
39 changed files with 198 additions and 132 deletions

View File

@@ -1,4 +1,5 @@
class Api::V1::Accounts::Kbase::CategoriesController < Api::V1::Accounts::Kbase::BaseController
class Api::V1::Accounts::CategoriesController < Api::V1::Accounts::BaseController
before_action :portal
before_action :fetch_category, except: [:index, :create]
def index
@@ -24,6 +25,10 @@ class Api::V1::Accounts::Kbase::CategoriesController < Api::V1::Accounts::Kbase:
@category = @portal.categories.find(params[:id])
end
def portal
@portal ||= Current.account.portals.find_by(slug: params[:portal_id])
end
def category_params
params.require(:category).permit(
:name, :description, :position

View File

@@ -1,9 +0,0 @@
class Api::V1::Accounts::Kbase::BaseController < Api::V1::Accounts::BaseController
before_action :portal
private
def portal
@portal ||= Current.account.kbase_portals.find_by(slug: params[:portal_id])
end
end

View File

@@ -1,14 +1,14 @@
class Api::V1::Accounts::Kbase::PortalsController < Api::V1::Accounts::BaseController
class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
before_action :fetch_portal, except: [:index, :create]
def index
@portals = Current.account.kbase_portals
@portals = Current.account.portals
end
def show; end
def create
@portal = Current.account.kbase_portals.create!(portal_params)
@portal = Current.account.portals.create!(portal_params)
end
def update
@@ -23,7 +23,7 @@ class Api::V1::Accounts::Kbase::PortalsController < Api::V1::Accounts::BaseContr
private
def fetch_portal
@portal = Current.account.kbase_portals.find_by(slug: permitted_params[:id])
@portal = Current.account.portals.find_by(slug: permitted_params[:id])
end
def permitted_params
@@ -32,7 +32,7 @@ class Api::V1::Accounts::Kbase::PortalsController < Api::V1::Accounts::BaseContr
def portal_params
params.require(:portal).permit(
:account_id, :color, :custom_domain, :header_text, :homepage_link, :name, :page_title, :slug
:account_id, :color, :custom_domain, :header_text, :homepage_link, :name, :page_title, :slug, :archived
)
end
end