Compare commits
2 commits
develop
...
fix/help-c
Author | SHA1 | Date | |
---|---|---|---|
|
fbb642e13d | ||
|
aa991b3cd3 |
11 changed files with 42 additions and 1 deletions
|
@ -2,6 +2,7 @@ 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
|
||||
|
@ -49,4 +50,8 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
|
|||
:category_slug, :locale, :query, :page
|
||||
)
|
||||
end
|
||||
|
||||
def set_current_page
|
||||
@current_page = params[:page] || 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# id :bigint not null, primary key
|
||||
# content :text
|
||||
# description :text
|
||||
# meta :jsonb
|
||||
# status :integer
|
||||
# title :string
|
||||
# views :integer
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
json.payload do
|
||||
json.array! @articles, partial: 'article', as: :article
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.current_page @current_page
|
||||
json.articles_count @articles.size
|
||||
end
|
||||
|
|
|
@ -25,3 +25,5 @@ if category.root_category.present?
|
|||
json.partial! 'api/v1/accounts/categories/associated_category.json.jbuilder', category: category.root_category
|
||||
end
|
||||
end
|
||||
|
||||
json.articles_count category.articles.published.try(:count)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
json.payload do
|
||||
json.array! @categories, partial: 'category', as: :category
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.current_page @current_page
|
||||
json.categories_count @categories.size
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
json.payload do
|
||||
json.array! @portals, partial: 'portal', as: :portal
|
||||
end
|
||||
|
||||
json.meta do
|
||||
json.current_page @current_page
|
||||
json.portals_count @portals.size
|
||||
end
|
||||
|
|
|
@ -23,3 +23,5 @@ if category.root_category.present?
|
|||
json.partial! partial: 'associated_category', category: category.root_category
|
||||
end
|
||||
end
|
||||
|
||||
json.articles_count category.articles.published.try(:count)
|
||||
|
|
5
db/migrate/20220720080126_add_meta_column_to_article.rb
Normal file
5
db/migrate/20220720080126_add_meta_column_to_article.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddMetaColumnToArticle < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :articles, :meta, :jsonb, default: {}
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_07_18_123938) do
|
||||
ActiveRecord::Schema.define(version: 2022_07_20_080126) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
|
@ -128,6 +128,7 @@ ActiveRecord::Schema.define(version: 2022_07_18_123938) do
|
|||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.bigint "author_id"
|
||||
t.bigint "associated_article_id"
|
||||
t.jsonb "meta", default: {}
|
||||
t.index ["associated_article_id"], name: "index_articles_on_associated_article_id"
|
||||
t.index ["author_id"], name: "index_articles_on_author_id"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue