Add circle posts history support (#18)
* Wip: make web backend * Wip: keep statuses if edit circle * Wip: Add circle history page and record circle posts * Add circle post to history in web ui when post * Add test
This commit is contained in:
parent
0a42f4b7e2
commit
df3b3f4185
19 changed files with 544 additions and 15 deletions
|
@ -20,6 +20,8 @@ class Circle < ApplicationRecord
|
|||
|
||||
has_many :circle_accounts, inverse_of: :circle, dependent: :destroy
|
||||
has_many :accounts, through: :circle_accounts
|
||||
has_many :circle_statuses, inverse_of: :circle, dependent: :destroy
|
||||
has_many :statuses, through: :circle_statuses
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
|
|
26
app/models/circle_status.rb
Normal file
26
app/models/circle_status.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: circle_statuses
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# circle_id :bigint(8)
|
||||
# status_id :bigint(8) not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class CircleStatus < ApplicationRecord
|
||||
belongs_to :circle
|
||||
belongs_to :status
|
||||
|
||||
validates :status, uniqueness: { scope: :circle }
|
||||
validate :account_own_status
|
||||
|
||||
private
|
||||
|
||||
def account_own_status
|
||||
errors.add(:status_id, :invalid) unless status.account_id == circle.account_id
|
||||
end
|
||||
end
|
|
@ -106,6 +106,7 @@ class Status < ApplicationRecord
|
|||
has_one :poll, inverse_of: :status, dependent: :destroy
|
||||
has_one :trend, class_name: 'StatusTrend', inverse_of: :status
|
||||
has_one :scheduled_expiration_status, inverse_of: :status, dependent: :destroy
|
||||
has_one :circle_status, inverse_of: :status, dependent: :destroy
|
||||
|
||||
validates :uri, uniqueness: true, presence: true, unless: :local?
|
||||
validates :text, presence: true, unless: -> { with_media? || reblog? }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue