mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-05 16:00:00 +01:00
* Try migrating from Travis to GitHub Actions for CI * Update actions.yml and tests.yml * Add ruby version * Update config/database.yml.example * Try rubocop and docker jobs * Fix indentation * Update tests.yml * Update tests.yml * Update gemfile * Update rubocop job and Gemfile * Update .rubocop_shopify_styleguide.yml * Update gemfile * Update .rubocop_todo.yml * Update rubocop configuration and styleguides * Fix rubocop offenses * Update .rubocop.yml * Update .rubocop.yml * Udate .codeclimate.yml * Update .codeclimate.yml * Update .codeclimate.yml * Update .codeclimate.yml * Setup unit tests * Update find_verified_user method in connection.rb * Add yarn cache and install to setup * install exporter dependencies; gdal/imagemagick * Introduce Gitpod to migration work (#1538) * Add CORS headers (#1536) * Create .gitpod.dockerfile * Create .gitpod.yml * Create database.yml.gitpod * Update .gitpod.yml * ruby 2.4.6 in gitpod.dockerfile * Update .gitpod.yml * Update database.yml.gitpod Co-authored-by: Sebastian Silva <sebastian@fuentelibre.org> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> * Install gdal and use egordm for yarn cache * Delete unnecessary query and fix layout * Run script with verbose output * Try installing package in action.yml * Setup controllers job * Fix indentation * Setup system tests job * Setup docker development build job * Fix identifiers * Fix path to action.yml * Update development dockerfile * Setup docker production build job * Update tests.yml * Setup assets precompilation job * Setup production environment * Update tests.yml * Update action.yml for production * Try with test setup * Remove action.yml for production * Change names of jobs for friendliness and clarity * Update .github/workflows/tests.yml Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> * Move dockerfiles to directory and change docker job names for clarity * Update docker job names Co-authored-by: Jeffrey Warren <jeff@unterbahn.com> Co-authored-by: Sebastian Silva <sebastian@fuentelibre.org>
58 lines
1.6 KiB
Ruby
58 lines
1.6 KiB
Ruby
require 'json'
|
|
|
|
class AnnotationsController < ApplicationController
|
|
# before_action :require_user, :except => [ :index, :show ]
|
|
before_action :find_map
|
|
|
|
def index
|
|
render(file: 'annotations/index.json.erb', content_type: 'application/json')
|
|
end
|
|
|
|
def create
|
|
geojson = params[:annotation]
|
|
|
|
respond_to do |format|
|
|
format.json do
|
|
@annotation = @map.annotations.create(
|
|
annotation_type: geojson[:properties][:annotation_type],
|
|
coordinates: geojson[:geometry][:coordinates],
|
|
text: geojson[:properties][:textContent],
|
|
style: geojson[:properties][:style]
|
|
)
|
|
@annotation.user_id = current_user.id if logged_in?
|
|
redirect_to(map_annotation_url(@map, @annotation)) if @annotation.save
|
|
end
|
|
end
|
|
end
|
|
|
|
def show
|
|
@annotation = Annotation.find(params[:id])
|
|
render(file: 'annotations/show.json.erb', content_type: 'application/json')
|
|
end
|
|
|
|
def update
|
|
@annotation = Annotation.find(params[:id])
|
|
geojson = params[:annotation]
|
|
return if @annotation.user_id.nil? || current_user.can_edit?(@annotation)
|
|
|
|
Annotation.update(@annotation.id,
|
|
coordinates: geojson[:geometry][:coordinates],
|
|
text: geojson[:properties][:textContent],
|
|
style: geojson[:properties][:style])
|
|
render(file: 'annotations/update.json.erb',
|
|
content_type: 'application/json')
|
|
end
|
|
|
|
def destroy
|
|
@annotation = Annotation.find(params[:id])
|
|
# if current_user.can_delete?(@annotation)
|
|
@annotation.delete
|
|
head(:ok)
|
|
# end
|
|
end
|
|
|
|
def find_map
|
|
@map = Map.find(params[:map_id])
|
|
end
|
|
end
|