keep permission of topic/synapse in sync with map its deferring to from beginning (#1053)
* Update topic.rb * Update synapse.rb
This commit is contained in:
parent
53bc4ee1c8
commit
952cf4e79f
2 changed files with 12 additions and 0 deletions
|
@ -22,6 +22,7 @@ class Synapse < ApplicationRecord
|
|||
where(topic1_id: topic_id).or(where(topic2_id: topic_id))
|
||||
}
|
||||
|
||||
before_create :set_perm_by_defer
|
||||
after_update :after_updated
|
||||
|
||||
delegate :name, to: :user, prefix: true
|
||||
|
@ -62,6 +63,12 @@ class Synapse < ApplicationRecord
|
|||
output += %(\n)
|
||||
output
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_perm_by_defer
|
||||
permission = defer_to_map.permission if defer_to_map
|
||||
end
|
||||
|
||||
def after_updated
|
||||
attrs = %w(desc category permission defer_to_map_id)
|
||||
|
|
|
@ -16,6 +16,7 @@ class Topic < ApplicationRecord
|
|||
|
||||
belongs_to :metacode
|
||||
|
||||
before_create :set_perm_by_defer
|
||||
before_create :create_metamap?
|
||||
after_update :after_updated
|
||||
|
||||
|
@ -134,6 +135,10 @@ class Topic < ApplicationRecord
|
|||
|
||||
protected
|
||||
|
||||
def set_perm_by_defer
|
||||
permission = defer_to_map.permission if defer_to_map
|
||||
end
|
||||
|
||||
def create_metamap?
|
||||
return unless (link == '') && (metacode.name == 'Metamap')
|
||||
|
||||
|
|
Loading…
Reference in a new issue