gprs byebye, location have two language, must have picture, long, lang have limit
This commit is contained in:
1 parent
c888d9cae4
commit
f1b6771b34
81 files changed
+196
-167
No files matched your search
Whitespace-only changes.
Whitespace-only changes.
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
||||
Whitespace-only changes.
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
||||
Whitespace-only changes.
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
class Panel::Location::BackEnd::LocationsController < OrbitBackendController
|
||||
include AdminHelper
|
||||
|
||||
before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :create, :update, :delete]
|
||||
before_filter :force_order_for_user,:except => [:get_locations,:index]
|
||||
|
||||
def index
|
||||
@location_infos = LocationInfo.all
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @locations }
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@location_info = LocationInfo.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @location }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@location_info = LocationInfo.find(params[:id])
|
||||
end
|
||||
|
||||
def show
|
||||
@location_info = LocationInfo.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @location }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@location_info = LocationInfo.new(params[:location_info])
|
||||
if @location_info.save
|
||||
flash[:success] = "Success!!"
|
||||
redirect_to panel_location_back_end_locations_url
|
||||
else
|
||||
error_msg = @location_info.errors.full_messages
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@location_info = LocationInfo.find(params[:id])
|
||||
@location_info.update_attributes(params[:location_info])
|
||||
redirect_to panel_location_back_end_locations_url
|
||||
end
|
||||
|
||||
def destroy
|
||||
@location_info = LocationInfo.find(params[:id])
|
||||
@location_info.destroy
|
||||
redirect_to panel_location_back_end_locations_url
|
||||
|
||||
end
|
||||
|
||||
def get_locations
|
||||
location_infos = LocationInfo.all
|
||||
@data = Array.new
|
||||
|
||||
location_infos.each do |location|
|
||||
picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}"
|
||||
thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}"
|
||||
@data << { name: location.name,
|
||||
pic_url: picurl,
|
||||
thumb_url: thumburl,
|
||||
longitude: location.longitude,
|
||||
latitude: location.latitude,
|
||||
description: location.description }
|
||||
end
|
||||
|
||||
render :json => JSON.pretty_generate({location: @data})
|
||||
end
|
||||
end
|
||||
Whitespace-only changes.
+2
@@ -0,0 +1,2 @@
|
||||
module Panel::Location::BackEnd::LocationsHelper
|
||||
end
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,19 @@
|
||||
class LocationInfo
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
mount_uploader :file, LocationsUploader
|
||||
|
||||
field :name, localize: true
|
||||
field :description, localize: true
|
||||
field :longitude, type: Float
|
||||
field :latitude, type: Float
|
||||
|
||||
validates :file, presence: true
|
||||
validates :longitude,
|
||||
numericality: { less_than_or_equal_to: 180.0, greater_than_or_equal_to: -180.0 },
|
||||
unless: Proc.new{self.longitude.blank?}
|
||||
validates :latitude,
|
||||
numericality: { less_than_or_equal_to: 90.0, greater_than_or_equal_to: -90.0 },
|
||||
unless: Proc.new{self.latitude.blank?}
|
||||
end
|
||||
@@ -0,0 +1,61 @@
|
||||
class LocationsUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or ImageScience support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::ImageScience
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
# storage :file
|
||||
# storage :s3
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"location/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url
|
||||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
||||
# end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
# version :thumb do
|
||||
# process :scale => [50, 50]
|
||||
# end
|
||||
|
||||
version :thumb do
|
||||
process :resize_to_fill => [150, 120]
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
# def extension_white_list
|
||||
# %w(jpg jpeg gif png)
|
||||
# end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
# def manipulate!
|
||||
# raise current_path.inspect
|
||||
# image = ::MiniMagick::Image.open(current_path)
|
||||
# image = yield(image)
|
||||
# image.write(current_path)
|
||||
# ::MiniMagick::Image.open(current_path)
|
||||
# rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
|
||||
# raise CarrierWave::ProcessingError.new("Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: #{e}")
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
Whitespace-only changes.
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
<% @location_info.errors.full_messages.each do |msg| %>
|
||||
<li>* <%= msg %></li>
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for=""><%= t "name" %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :name_translations do |f| %>
|
||||
<%= f.text_field locale, :class=>'span4', :value => (@location_info.name_translations[locale.to_s] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for=""><%= t 'picture' %></label>
|
||||
<div class="controls">
|
||||
<%= @location_info.file? ? ( link_to t(:view), @location_info.file.url, {:class => 'for_preview btn', :target => '_blank', :title => t(:view)}) : '' %>
|
||||
<%= f.file_field :file %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for=""><%= t 'coordinates' %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
|
||||
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for=""><%= t 'description' %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :description_translations do |f| %>
|
||||
<%= f.text_area locale, :class=>'span4', :cols=>"30", :row=>"5", :value => (@location_info.description_translations[locale.to_s] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<%= f.submit t("submit"), :class=>"btn" %>
|
||||
</div>
|
||||
</div>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<%= form_for @location_info, :url=> panel_location_back_end_location_path(@location_info), :html => { :class=>"form-horizontal"} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1"><%= t('location.picture') %></th>
|
||||
<th class="span1"><%= t('location.name') %></th>
|
||||
<th class="span1"><%= t('location.longitude') %></th>
|
||||
<th class="span1"><%= t('location.latitude') %></th>
|
||||
<th class="span3"><%= t('location.description') %></th>
|
||||
<%if is_manager? %>
|
||||
<th class="span1"><%= t('location.edit') %></th>
|
||||
<th class="span1"><%= t('location.delete') %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_locations" class="sort-holder">
|
||||
<% @location_infos.each do |location| %>
|
||||
<tr class="with_action">
|
||||
<td><%= image_tag(location.file, alt: location.file, size: "50x50" ) if !location.file.blank? %></td>
|
||||
<td><%= location.name %></td>
|
||||
<td><%= location.longitude%></td>
|
||||
<td><%= location.latitude%></td>
|
||||
<td><%= location.description %></td>
|
||||
<%if is_manager? %>
|
||||
<td><%= link_to 'Edit', edit_panel_location_back_end_location_path(location) %></td>
|
||||
<td><%= link_to 'Destroy', panel_location_back_end_location_path(location), method: :delete , :confirm => t(:sure?) %></td>
|
||||
<%end%>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%if is_manager? %>
|
||||
<td><%= link_to 'New', new_panel_location_back_end_location_path %></td>
|
||||
<% end %>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<%= form_for @location_info, :url=> panel_location_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
Reference in new issue
Block a user