mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-11 18:59:59 +01:00
* Configurations update for rails 4.0 * ActiveSupport::Testing::Performance extracted to a gem * ruby prof required as a dependency * disable rubocop on bin folder * http patch * Comment out to allow testing * no longer supports plugin loading * lock to sprockets 2.12 * Active record patches * remove deprecated test syntax * fix failing tests * change new super class * replace right_aws with right_aws_api right_aws is no longer maintained, was throwing an error * Change test lib to minitest, add minitest reporters * lock to rails 4.2.11.1 * change rails version in install script * remove deprecation warnings * make app work * active record find patches * root_in_json include defaulted to false * confirm option removed in link helper * cookies serializer changed to hybrid * Change render :text to :plain render :text will be deprecated and poses a security risk * console for dev web * Check and fix interface functionality * fix export functionality * add protected attributes for the warpable model * fix image upload * Fix comments and images failing tests * include mass assignment security in annotations * render html for update images * clear mail array before every test * Fix codeclimate issues * skip failing test The test is failing because of different names in model(warpable) and controller(images) skipping this for now until we decide if we want to standardize the names * replace unprotected redirects * fix fa icons * fix login functionality * precompile images * fix codeclimate issues * Fix oauth icons
58 lines
1.6 KiB
Ruby
58 lines
1.6 KiB
Ruby
require 'json'
|
|
|
|
class AnnotationsController < ApplicationController
|
|
# before_filter :require_user, :except => [ :index, :show ]
|
|
before_filter :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
|