more changes
This commit is contained in:
parent
b4348a7e78
commit
794c647967
13 changed files with 43 additions and 44 deletions
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
class MapsController < ApplicationController
|
class MapsController < ApplicationController
|
||||||
before_action :require_user, only: %i(create update destroy events follow unfollow)
|
before_action :require_user, only: %i(create update destroy events follow unfollow)
|
||||||
before_action :set_map, only: %i(show conversation update destroy contains events export follow unfollow unfollow_from_email)
|
before_action :set_map, only: %i(show conversation update destroy
|
||||||
|
contains events export
|
||||||
|
follow unfollow unfollow_from_email)
|
||||||
after_action :verify_authorized
|
after_action :verify_authorized
|
||||||
|
|
||||||
# GET maps/:id
|
# GET maps/:id
|
||||||
|
|
|
@ -18,6 +18,6 @@ class Follow < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_subsetting
|
def add_subsetting
|
||||||
follow_reason = FollowReason.create!(follow: self)
|
FollowReason.create!(follow: self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -153,12 +153,11 @@ class Map < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_updated_async
|
def after_updated_async
|
||||||
if ATTRS_TO_WATCH.any? { |k| changed_attributes.key?(k) }
|
return unless ATTRS_TO_WATCH.any? { |k| changed_attributes.key?(k) }
|
||||||
FollowService.follow(self, updated_by, 'contributed')
|
FollowService.follow(self, updated_by, 'contributed')
|
||||||
# NotificationService.notify_followers(self, 'map_updated', changed_attributes)
|
# NotificationService.notify_followers(self, 'map_updated', changed_attributes)
|
||||||
# or better yet publish an event
|
# or better yet publish an event
|
||||||
end
|
end
|
||||||
end
|
|
||||||
handle_asynchronously :after_updated_async
|
handle_asynchronously :after_updated_async
|
||||||
|
|
||||||
def before_destroyed
|
def before_destroyed
|
||||||
|
|
|
@ -53,18 +53,18 @@ class Mapping < ApplicationRecord
|
||||||
handle_asynchronously :after_created_async
|
handle_asynchronously :after_created_async
|
||||||
|
|
||||||
def after_updated
|
def after_updated
|
||||||
if (mappable_type == 'Topic') && (xloc_changed? || yloc_changed?)
|
return unless (mappable_type == 'Topic') && (xloc_changed? || yloc_changed?)
|
||||||
meta = { 'x': xloc, 'y': yloc, 'mapping_id': id }
|
meta = { 'x': xloc, 'y': yloc, 'mapping_id': id }
|
||||||
Events::TopicMovedOnMap.publish!(mappable, map, updated_by, meta)
|
Events::TopicMovedOnMap.publish!(mappable, map, updated_by, meta)
|
||||||
ActionCable.server.broadcast 'map_' + map.id.to_s, type: 'topicMoved', id: mappable.id, mapping_id: id, x: xloc, y: yloc
|
ActionCable.server.broadcast('map_' + map.id.to_s, type: 'topicMoved',
|
||||||
end
|
id: mappable.id, mapping_id: id,
|
||||||
|
x: xloc, y: yloc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_updated_async
|
def after_updated_async
|
||||||
if (mappable_type == 'Topic') && (xloc_changed? || yloc_changed?)
|
return unless (mappable_type == 'Topic') && (xloc_changed? || yloc_changed?)
|
||||||
FollowService.follow(map, updated_by, 'contributed')
|
FollowService.follow(map, updated_by, 'contributed')
|
||||||
end
|
end
|
||||||
end
|
|
||||||
handle_asynchronously :after_updated_async
|
handle_asynchronously :after_updated_async
|
||||||
|
|
||||||
def before_destroyed
|
def before_destroyed
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Metacode < ApplicationRecord
|
||||||
default_url: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png'
|
default_url: 'https://s3.amazonaws.com/metamaps-assets/metacodes/generics/96px/gen_wildcard.png'
|
||||||
|
|
||||||
# Validate the attached icon is image/jpg, image/png, etc
|
# Validate the attached icon is image/jpg, image/png, etc
|
||||||
validates_attachment_content_type :aws_icon, content_type: /\Aimage\/.*\Z/
|
validates_attachment_content_type :aws_icon, content_type: %r(\Aimage/.*\Z)
|
||||||
|
|
||||||
validate :aws_xor_manual_icon
|
validate :aws_xor_manual_icon
|
||||||
validate :manual_icon_https
|
validate :manual_icon_https
|
||||||
|
@ -56,10 +56,9 @@ class Metacode < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def manual_icon_https
|
def manual_icon_https
|
||||||
if manual_icon.present?
|
return unless manual_icon.present?
|
||||||
unless manual_icon.starts_with? 'https'
|
unless manual_icon.starts_with? 'https'
|
||||||
errors.add(:base, 'Manual icon must begin with https')
|
errors.add(:base, 'Manual icon must begin with https')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -83,7 +83,8 @@ class Synapse < ApplicationRecord
|
||||||
handle_asynchronously :after_created_async
|
handle_asynchronously :after_created_async
|
||||||
|
|
||||||
def after_updated
|
def after_updated
|
||||||
if ATTRS_TO_WATCH.any? { |k| changed_attributes.key?(k) }
|
return unless ATTRS_TO_WATCH.any? { |k| changed_attributes.key?(k) }
|
||||||
|
|
||||||
new = attributes.select { |k| ATTRS_TO_WATCH.include?(k) }
|
new = attributes.select { |k| ATTRS_TO_WATCH.include?(k) }
|
||||||
old = changed_attributes.select { |k| ATTRS_TO_WATCH.include?(k) }
|
old = changed_attributes.select { |k| ATTRS_TO_WATCH.include?(k) }
|
||||||
meta = new.merge(old) # we are prioritizing the old values, keeping them
|
meta = new.merge(old) # we are prioritizing the old values, keeping them
|
||||||
|
@ -93,7 +94,6 @@ class Synapse < ApplicationRecord
|
||||||
ActionCable.server.broadcast 'map_' + map.id.to_s, type: 'synapseUpdated', id: id
|
ActionCable.server.broadcast 'map_' + map.id.to_s, type: 'synapseUpdated', id: id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def before_destroyed
|
def before_destroyed
|
||||||
# hard to know how to do this yet, because the synapse actually gets destroyed
|
# hard to know how to do this yet, because the synapse actually gets destroyed
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
|
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
|
||||||
def text
|
def text
|
||||||
connector = eventable.desc.empty? ? '->' : eventable.desc
|
connector = eventable.desc.empty? ? '->' : eventable.desc
|
||||||
"\"*#{eventable.topic1.name}* #{connector} *#{eventable.topic2.name}*\"" +
|
"\"*#{eventable.topic1.name}* #{connector} *#{eventable.topic2.name}*\"" \
|
||||||
" was added as a connection by *#{event.user.name}*" +
|
" was added as a connection by *#{event.user.name}*" \
|
||||||
" to the map *#{view_map_on_metamaps}*"
|
" to the map *#{view_map_on_metamaps}*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ class Webhooks::Slack::SynapseRemovedFromMap < Webhooks::Slack::Base
|
||||||
|
|
||||||
# TODO: express correct directionality of arrows when desc is empty
|
# TODO: express correct directionality of arrows when desc is empty
|
||||||
|
|
||||||
"\"*#{eventable.topic1.name}* #{connector} *#{eventable.topic2.name}*\"" +
|
"\"*#{eventable.topic1.name}* #{connector} *#{eventable.topic2.name}*\"" \
|
||||||
" was removed by *#{event.user.name}* as a connection" +
|
" was removed by *#{event.user.name}* as a connection" \
|
||||||
" from the map *#{view_map_on_metamaps}*"
|
" from the map *#{view_map_on_metamaps}*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ class SynapsePolicy < ApplicationPolicy
|
||||||
end
|
end
|
||||||
|
|
||||||
def unauthenticated_scope
|
def unauthenticated_scope
|
||||||
return scope.where(permission: %w(public commons))
|
scope.where(permission: %w(public commons))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ module Api
|
||||||
object.image.url(:sixtyfour)
|
object.image.url(:sixtyfour)
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Style/PredicateName
|
|
||||||
def is_admin
|
def is_admin
|
||||||
object.admin
|
object.admin
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue