automatic rubocop updates
This commit is contained in:
parent
0a62eb3299
commit
0ace202ace
158 changed files with 239 additions and 93 deletions
1
Gemfile
1
Gemfile
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
source 'https://rubygems.org'
|
||||
ruby '2.3.0'
|
||||
|
||||
|
|
1
Rakefile
1
Rakefile
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env rake
|
||||
# frozen_string_literal: true
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
|
|
3
Vagrantfile
vendored
3
Vagrantfile
vendored
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
|
@ -31,7 +32,7 @@ sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '3112';"
|
|||
|
||||
SCRIPT
|
||||
|
||||
VAGRANTFILE_API_VERSION = '2'.freeze
|
||||
VAGRANTFILE_API_VERSION = '2'
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.box = 'trusty64'
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V1
|
||||
class DeprecatedController < ApplicationController
|
||||
def method_missing
|
||||
render json: { error: "/api/v1 is deprecated! Please use /api/v2 instead." }
|
||||
render json: { error: '/api/v1 is deprecated! Please use /api/v2 instead.' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V1
|
||||
class MappingsController < DeprecatedController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V1
|
||||
class MapsController < DeprecatedController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V1
|
||||
class SynapsesController < DeprecatedController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V1
|
||||
class TokensController < DeprecatedController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V1
|
||||
class TopicsController < DeprecatedController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class MappingsController < RestfulController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class MapsController < RestfulController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class RestfulController < ActionController::Base
|
||||
|
@ -101,9 +102,9 @@ module Api
|
|||
next_page = current_page < total_pages ? current_page + 1 : 0
|
||||
|
||||
base_url = request.base_url + request.path
|
||||
nxt = request.query_parameters.merge(page: next_page).map{|x| x.join('=')}.join('&')
|
||||
prev = request.query_parameters.merge(page: prev_page).map{|x| x.join('=')}.join('&')
|
||||
last = request.query_parameters.merge(page: total_pages).map{|x| x.join('=')}.join('&')
|
||||
nxt = request.query_parameters.merge(page: next_page).map { |x| x.join('=') }.join('&')
|
||||
prev = request.query_parameters.merge(page: prev_page).map { |x| x.join('=') }.join('&')
|
||||
last = request.query_parameters.merge(page: total_pages).map { |x| x.join('=') }.join('&')
|
||||
response.headers['Link'] = [
|
||||
%(<#{base_url}?#{nxt}>; rel="next"),
|
||||
%(<#{base_url}?#{prev}>; rel="prev"),
|
||||
|
@ -163,7 +164,7 @@ module Api
|
|||
builder = builder.order(sort => direction)
|
||||
end
|
||||
end
|
||||
return builder
|
||||
builder
|
||||
end
|
||||
|
||||
def visible_records
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class SessionsController < ApplicationController
|
||||
def create
|
||||
@user = User.find_by(email: params[:email])
|
||||
if @user && @user.valid_password(params[:password])
|
||||
if @user&.valid_password(params[:password])
|
||||
sign_in(@user)
|
||||
render json: @user
|
||||
else
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class SynapsesController < RestfulController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class TokensController < RestfulController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class TopicsController < RestfulController
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class ApplicationController < ActionController::Base
|
||||
include ApplicationHelper
|
||||
include Pundit
|
||||
|
@ -60,10 +61,9 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def require_admin
|
||||
unless authenticated? && admin?
|
||||
return true if authenticated? && admin?
|
||||
redirect_to root_url, notice: 'You need to be an admin for that.'
|
||||
return false
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def user
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MainController < ApplicationController
|
||||
include TopicsHelper
|
||||
include MapsHelper
|
||||
|
@ -12,13 +13,13 @@ class MainController < ApplicationController
|
|||
def home
|
||||
@maps = policy_scope(Map).order('updated_at DESC').page(1).per(20)
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
format.html do
|
||||
if !authenticated?
|
||||
render 'main/home'
|
||||
else
|
||||
render 'maps/activemaps'
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -163,8 +164,8 @@ class MainController < ApplicationController
|
|||
@synapses = []
|
||||
end
|
||||
|
||||
#limit to 5 results
|
||||
@synapses = @synapses.to_a.slice(0,5)
|
||||
# limit to 5 results
|
||||
@synapses = @synapses.to_a.slice(0, 5)
|
||||
|
||||
render json: autocomplete_synapse_array_json(@synapses)
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MappingsController < ApplicationController
|
||||
before_action :require_user, only: [:create, :update, :destroy]
|
||||
after_action :verify_authorized, except: :index
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MapsController < ApplicationController
|
||||
before_action :require_user, only: [:create, :update, :access, :star, :unstar, :screenshot, :events, :destroy]
|
||||
after_action :verify_authorized, except: [:activemaps, :featuredmaps, :mymaps, :sharedmaps, :starredmaps, :usermaps]
|
||||
|
@ -107,7 +108,7 @@ class MapsController < ApplicationController
|
|||
|
||||
# GET maps/new
|
||||
def new
|
||||
@map = Map.new(name: "Untitled Map", permission: "public", arranged: true)
|
||||
@map = Map.new(name: 'Untitled Map', permission: 'public', arranged: true)
|
||||
authorize @map
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -305,9 +306,7 @@ class MapsController < ApplicationController
|
|||
@map = Map.find(params[:id])
|
||||
authorize @map
|
||||
star = Star.find_by_map_id_and_user_id(@map.id, current_user.id)
|
||||
if not star
|
||||
star = Star.create(map_id: @map.id, user_id: current_user.id)
|
||||
end
|
||||
star = Star.create(map_id: @map.id, user_id: current_user.id) unless star
|
||||
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
|
@ -321,9 +320,7 @@ class MapsController < ApplicationController
|
|||
@map = Map.find(params[:id])
|
||||
authorize @map
|
||||
star = Star.find_by_map_id_and_user_id(@map.id, current_user.id)
|
||||
if star
|
||||
star.delete
|
||||
end
|
||||
star&.delete
|
||||
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MessagesController < ApplicationController
|
||||
before_action :require_user, except: [:show]
|
||||
after_action :verify_authorized
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MetacodeSetsController < ApplicationController
|
||||
before_action :require_admin
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class SynapsesController < ApplicationController
|
||||
include TopicsHelper
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class TopicsController < ApplicationController
|
||||
include TopicsHelper
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Users::PasswordsController < Devise::PasswordsController
|
||||
protected
|
||||
|
||||
|
@ -5,7 +6,7 @@ class Users::PasswordsController < Devise::PasswordsController
|
|||
signed_in_root_path(resource)
|
||||
end
|
||||
|
||||
def after_sending_reset_password_instructions_path_for(resource_name)
|
||||
def after_sending_reset_password_instructions_path_for(_resource_name)
|
||||
new_user_session_path if is_navigational_format?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
before_action :configure_sign_up_params, only: [:create]
|
||||
before_action :configure_account_update_params, only: [:update]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class UsersController < ApplicationController
|
||||
before_action :require_user, only: [:edit, :update, :updatemetacodes]
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module ApplicationHelper
|
||||
def get_metacodeset
|
||||
@m = current_user.settings.metacodes
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module ContentHelper
|
||||
def resource_name
|
||||
:user
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module DeviseHelper
|
||||
def devise_error_messages!
|
||||
resource.errors.to_a[0]
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
module InMetacodeSetsHelper
|
||||
end
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
module MainHelper
|
||||
end
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
module MappingHelper
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module MapsHelper
|
||||
## this one is for building our custom JSON autocomplete format for typeahead
|
||||
def autocomplete_map_array_json(maps)
|
||||
|
@ -16,7 +17,7 @@ module MapsHelper
|
|||
|
||||
contributorTip = ''
|
||||
firstContributorImage = 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
|
||||
if m.contributors.count > 0
|
||||
if m.contributors.count.positive?
|
||||
firstContributorImage = m.contributors[0].image.url(:thirtytwo)
|
||||
m.contributors.each_with_index do |c, _index|
|
||||
userImage = c.image.url(:thirtytwo)
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
module MetacodeSetsHelper
|
||||
end
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
module MetacodesHelper
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module SynapsesHelper
|
||||
## this one is for building our custom JSON autocomplete format for typeahead
|
||||
def autocomplete_synapse_generic_json(unique)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module TopicsHelper
|
||||
## this one is for building our custom JSON autocomplete format for typeahead
|
||||
def autocomplete_array_json(topics)
|
||||
|
@ -7,7 +8,7 @@ module TopicsHelper
|
|||
topic['id'] = t.id
|
||||
topic['label'] = t.name
|
||||
topic['value'] = t.name
|
||||
topic['description'] = t.desc ? t.desc.truncate(70) : '' # make this return matched results
|
||||
topic['description'] = t.desc ? t.desc&.truncate(70) # make this return matched results
|
||||
topic['type'] = t.metacode.name
|
||||
topic['typeImageURL'] = t.metacode.icon
|
||||
topic['permission'] = t.permission
|
||||
|
@ -34,7 +35,7 @@ module TopicsHelper
|
|||
# add the node to the array
|
||||
array.push(node)
|
||||
|
||||
return array if count == 0
|
||||
return array if count.zero?
|
||||
|
||||
count -= 1
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module UsersHelper
|
||||
# build custom json autocomplete for typeahead
|
||||
def autocomplete_user_array_json(users)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'team@metamaps.cc'
|
||||
layout 'mailer'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MapMailer < ApplicationMailer
|
||||
default from: 'team@metamaps.cc'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Routing
|
||||
extend ActiveSupport::Concern
|
||||
include Rails.application.routes.url_helpers
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Event < ApplicationRecord
|
||||
KINDS = %w(user_present_on_map conversation_started_on_map topic_added_to_map synapse_added_to_map).freeze
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Events::ConversationStartedOnMap < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Events::NewMapping < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Events::UserPresentOnMap < Event
|
||||
# after_create :notify_users!
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class InMetacodeSet < ApplicationRecord
|
||||
belongs_to :metacode, class_name: 'Metacode', foreign_key: 'metacode_id'
|
||||
belongs_to :metacode_set, class_name: 'MetacodeSet', foreign_key: 'metacode_set_id'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Map < ApplicationRecord
|
||||
belongs_to :user
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Mapping < ApplicationRecord
|
||||
scope :topicmapping, -> { where(mappable_type: :Topic) }
|
||||
scope :synapsemapping, -> { where(mappable_type: :Synapse) }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Message < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :resource, polymorphic: true
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Metacode < ApplicationRecord
|
||||
has_many :in_metacode_sets
|
||||
has_many :metacode_sets, through: :in_metacode_sets
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MetacodeSet < ApplicationRecord
|
||||
belongs_to :user
|
||||
has_many :in_metacode_sets
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class PermittedParams < Struct.new(:params)
|
||||
%w(map synapse topic mapping token).each do |kind|
|
||||
define_method(kind) do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Star < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :map
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Synapse < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :defer_to_map, class_name: 'Map', foreign_key: 'defer_to_map_id'
|
||||
|
@ -44,10 +45,7 @@ class Synapse < ApplicationRecord
|
|||
# :nocov:
|
||||
def calculated_permission
|
||||
if defer_to_map
|
||||
defer_to_map.permission
|
||||
else
|
||||
permission
|
||||
end
|
||||
defer_to_map&.permission
|
||||
end
|
||||
# :nocov:
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Token < ApplicationRecord
|
||||
belongs_to :user
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Topic < ApplicationRecord
|
||||
include TopicsHelper
|
||||
|
||||
|
@ -74,10 +75,7 @@ class Topic < ApplicationRecord
|
|||
|
||||
def calculated_permission
|
||||
if defer_to_map
|
||||
defer_to_map.permission
|
||||
else
|
||||
permission
|
||||
end
|
||||
defer_to_map&.permission
|
||||
end
|
||||
|
||||
def as_json(_options = {})
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'open-uri'
|
||||
|
||||
class User < ApplicationRecord
|
||||
|
@ -41,7 +42,7 @@ class User < ApplicationRecord
|
|||
default_url: 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
|
||||
|
||||
# Validate the attached image is image/jpg, image/png, etc
|
||||
validates_attachment_content_type :image, content_type: %r(\Aimage/.*\Z)
|
||||
validates_attachment_content_type :image, content_type: %r{\Aimage/.*\Z}
|
||||
|
||||
# override default as_json
|
||||
def as_json(_options = {})
|
||||
|
@ -80,7 +81,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def starred_map?(map)
|
||||
return self.stars.where(map_id: map.id).exists?
|
||||
stars.where(map_id: map.id).exists?
|
||||
end
|
||||
|
||||
def settings
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class UserMap < ApplicationRecord
|
||||
belongs_to :map
|
||||
belongs_to :user
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class UserPreference
|
||||
attr_accessor :metacodes
|
||||
|
||||
|
@ -9,7 +10,7 @@ class UserPreference
|
|||
array.push(metacode.id.to_s) if metacode
|
||||
rescue ActiveRecord::StatementInvalid
|
||||
if m == 'Action'
|
||||
Rails.logger.warn("TODO: remove this travis workaround in user_preference.rb")
|
||||
Rails.logger.warn('TODO: remove this travis workaround in user_preference.rb')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhook < ApplicationRecord
|
||||
belongs_to :hookable, polymorphic: true
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
Webhooks::Slack::Base = Struct.new(:event) do
|
||||
include Routing
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhooks::Slack::ConversationStartedOnMap < Webhooks::Slack::Base
|
||||
def text
|
||||
"There is a live conversation starting on map *#{event.map.name}*. #{view_map_on_metamaps('Join in!')}"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
|
||||
def text
|
||||
"\"*#{eventable.mappable.topic1.name}* #{eventable.mappable.desc || '->'} *#{eventable.mappable.topic2.name}*\" was added as a connection to the map *#{view_map_on_metamaps}*"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base
|
||||
def text
|
||||
"New #{eventable.mappable.metacode.name} topic *#{eventable.mappable.name}* was added to the map *#{view_map_on_metamaps}*"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Webhooks::Slack::UserPresentOnMap < Webhooks::Slack::Base
|
||||
def text
|
||||
"Mapper *#{event.user.name}* has joined the map *#{event.map.name}*. #{view_map_on_metamaps('Map with them')}"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class ApplicationPolicy
|
||||
attr_reader :user, :record
|
||||
|
||||
|
@ -39,7 +40,7 @@ class ApplicationPolicy
|
|||
# explicitly say they want to (E.g. seeing/editing/deleting private
|
||||
# maps - they should be able to, but not by accident)
|
||||
def admin_override
|
||||
user && user.admin
|
||||
user&.admin
|
||||
end
|
||||
|
||||
def scope
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MainPolicy < ApplicationPolicy
|
||||
def initialize(user, _record)
|
||||
@user = user
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MapPolicy < ApplicationPolicy
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MappingPolicy < ApplicationPolicy
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MessagePolicy < ApplicationPolicy
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class SynapsePolicy < ApplicationPolicy
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class TokenPolicy < ApplicationPolicy
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class TopicPolicy < ApplicationPolicy
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class ApplicationSerializer < ActiveModel::Serializer
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class EventSerializer < ApplicationSerializer
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class MapSerializer < ApplicationSerializer
|
||||
|
@ -20,7 +21,7 @@ module Api
|
|||
}
|
||||
end
|
||||
|
||||
self.class_eval do
|
||||
class_eval do
|
||||
embed_dat
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class MappingSerializer < ApplicationSerializer
|
||||
|
@ -17,7 +18,7 @@ module Api
|
|||
}
|
||||
end
|
||||
|
||||
self.class_eval do
|
||||
class_eval do
|
||||
embed_dat
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class MetacodeSerializer < ApplicationSerializer
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class SynapseSerializer < ApplicationSerializer
|
||||
|
@ -16,7 +17,7 @@ module Api
|
|||
}
|
||||
end
|
||||
|
||||
self.class_eval do
|
||||
class_eval do
|
||||
embed_dat
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class TokenSerializer < ApplicationSerializer
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class TopicSerializer < ApplicationSerializer
|
||||
|
@ -16,7 +17,7 @@ module Api
|
|||
}
|
||||
end
|
||||
|
||||
self.class_eval do
|
||||
class_eval do
|
||||
embed_dat
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class UserSerializer < ApplicationSerializer
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Api
|
||||
module V2
|
||||
class WebhookSerializer < ApplicationSerializer
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class MapExportService < Struct.new(:user, :map)
|
||||
def json
|
||||
# marshal_dump turns OpenStruct into a Hash
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class Perm
|
||||
# e.g. Perm::ISSIONS
|
||||
ISSIONS = [:commons, :public, :private].freeze
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class WebhookService
|
||||
def self.publish!(webhook:, event:)
|
||||
return false unless webhook.event_types.include? event.kind
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative 'boot'
|
||||
|
||||
require 'csv'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'rubygems'
|
||||
require 'rails/commands/server'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# Load the Rails application.
|
||||
require_relative 'application'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
Metamaps::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
Metamaps::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
$codes = []
|
||||
if ActiveRecord::Base.connection.data_source_exists? 'users'
|
||||
$codes = ActiveRecord::Base.connection.execute('SELECT code FROM users').map { |user| user['code'] }
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
# frozen_string_literal: true
|
||||
ActiveModelSerializers.config.adapter = :json
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# ApplicationController.renderer.defaults.merge!(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
|
@ -9,4 +10,4 @@ Rails.application.config.assets.quiet = true
|
|||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
Rails.application.config.assets.precompile += %w( webpacked/metamaps.bundle.js )
|
||||
Rails.application.config.assets.precompile += %w(webpacked/metamaps.bundle.js)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue