mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-09 05:15:53 +10:00
Add share instance list api
This commit is contained in:
@@ -38,7 +38,7 @@ gem 'activeadmin', '~> 1.0.0.pre1'
|
||||
gem 'devise'
|
||||
gem 'jwt'
|
||||
|
||||
gem 'active_model_serializers', '~> 0.9.3'
|
||||
gem 'active_model_serializers', '~>0.10.0.rc2'
|
||||
gem 'versionist'
|
||||
gem 'houston'
|
||||
gem 'kaminari', '~> 0.16.3'
|
||||
|
||||
+3
-3
@@ -20,8 +20,8 @@ GEM
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
active_model_serializers (0.9.3)
|
||||
activemodel (>= 3.2)
|
||||
active_model_serializers (0.10.0.rc2)
|
||||
activemodel (>= 4.0)
|
||||
activeadmin (1.0.0.pre1)
|
||||
arbre (~> 1.0, >= 1.0.2)
|
||||
bourbon
|
||||
@@ -303,7 +303,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
active_model_serializers (~> 0.9.3)
|
||||
active_model_serializers (~> 0.10.0.rc2)
|
||||
activeadmin (~> 1.0.0.pre1)
|
||||
awesome_print (~> 1.6.1)
|
||||
better_errors
|
||||
|
||||
@@ -25,7 +25,7 @@ class Api::V1::PostsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
|
||||
render json: @current_user.share_instances.page(params[:page]), each_serializer: ShareInstanceSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class PostSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :view_account, :url, :title
|
||||
|
||||
def title
|
||||
object.try(:name)
|
||||
end
|
||||
|
||||
def view_account
|
||||
object.view_account || 0
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class ShareInstanceSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :description, :sharable_type
|
||||
|
||||
belongs_to :sharable, serializer: PostSerializer
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddViewAccountToArticle < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :articles, :view_account, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddViewAccountToWebPage < ActiveRecord::Migration
|
||||
def change
|
||||
|
||||
add_column :web_pages, :view_account, :integer
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class UpdateViewAccountToWebPage < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :web_pages, :view_account, :integer, default: 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class UpdateViewAccountToArticle < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :articles, :view_account, :integer, default: 0
|
||||
end
|
||||
end
|
||||
+9
-7
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150802040745) do
|
||||
ActiveRecord::Schema.define(version: 20150802115544) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -54,9 +54,10 @@ ActiveRecord::Schema.define(version: 20150802040745) do
|
||||
t.string "url"
|
||||
t.string "author"
|
||||
t.string "content"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "processed", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "processed", default: false
|
||||
t.integer "view_account", default: 0
|
||||
end
|
||||
|
||||
create_table "auth_tokens", force: :cascade do |t|
|
||||
@@ -125,9 +126,10 @@ ActiveRecord::Schema.define(version: 20150802040745) do
|
||||
create_table "web_pages", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "url"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "processed", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "processed", default: false
|
||||
t.integer "view_account", default: 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user