add models for signature data
This commit is contained in:
parent
5f3e4fc358
commit
081d0167b7
8 changed files with 44 additions and 0 deletions
|
|
@ -29,6 +29,8 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
has_many :reports, as: :item
|
||||
|
||||
has_one :signature, class_name: "CommentSignature", dependent: :delete
|
||||
|
||||
scope :including_author, -> { includes(:author => :profile) }
|
||||
scope :for_a_stream, -> { including_author.merge(order('created_at ASC')) }
|
||||
|
||||
|
|
|
|||
7
app/models/comment_signature.rb
Normal file
7
app/models/comment_signature.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class CommentSignature < ActiveRecord::Base
|
||||
include Diaspora::Signature
|
||||
|
||||
self.primary_key = :comment_id
|
||||
belongs_to :comment
|
||||
validates :comment, presence: true
|
||||
end
|
||||
|
|
@ -10,6 +10,8 @@ class Like < ActiveRecord::Base
|
|||
|
||||
include Diaspora::Relayable
|
||||
|
||||
has_one :signature, class_name: "LikeSignature", dependent: :delete
|
||||
|
||||
alias_attribute :parent, :target
|
||||
|
||||
class Generator < Diaspora::Federated::Generator
|
||||
|
|
|
|||
7
app/models/like_signature.rb
Normal file
7
app/models/like_signature.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class LikeSignature < ActiveRecord::Base
|
||||
include Diaspora::Signature
|
||||
|
||||
self.primary_key = :like_id
|
||||
belongs_to :like
|
||||
validates :like, presence: true
|
||||
end
|
||||
|
|
@ -7,6 +7,8 @@ class PollParticipation < ActiveRecord::Base
|
|||
belongs_to :poll
|
||||
belongs_to :poll_answer, counter_cache: :vote_count
|
||||
|
||||
has_one :signature, class_name: "PollParticipationSignature", dependent: :delete
|
||||
|
||||
alias_attribute :parent, :poll
|
||||
|
||||
validates :poll_answer, presence: true
|
||||
|
|
|
|||
7
app/models/poll_participation_signature.rb
Normal file
7
app/models/poll_participation_signature.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class PollParticipationSignature < ActiveRecord::Base
|
||||
include Diaspora::Signature
|
||||
|
||||
self.primary_key = :poll_participation_id
|
||||
belongs_to :poll_participation
|
||||
validates :poll_participation, presence: true
|
||||
end
|
||||
3
app/models/signature_order.rb
Normal file
3
app/models/signature_order.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class SignatureOrder < ActiveRecord::Base
|
||||
validates :order, presence: true, uniqueness: true
|
||||
end
|
||||
14
lib/diaspora/signature.rb
Normal file
14
lib/diaspora/signature.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
module Diaspora
|
||||
module Signature
|
||||
def self.included(model)
|
||||
model.class_eval do
|
||||
belongs_to :signature_order
|
||||
validates :signature_order, presence: true
|
||||
|
||||
validates :author_signature, presence: true
|
||||
|
||||
serialize :additional_data, Hash
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue