gprs byebye, location have two language, must have picture, long, lang have limit
This commit is contained in:
1 parent
91afad23ba
commit
c44b4163e4
78 files changed
+144
-117
No files matched your search
-3
@@ -1,3 +0,0 @@
|
||||
= Gprs
|
||||
|
||||
This project rocks and uses MIT-LICENSE.
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
module Panel::Gprs::BackEnd::LocationsHelper
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
class Location
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
mount_uploader :file, GprsUploader
|
||||
|
||||
field :name
|
||||
field :description
|
||||
field :longitude, type: Float
|
||||
field :latitude, type: Float
|
||||
end
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="">Name</label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :name, :class=>"span4", :placeholder => "Area" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="">Picture</label>
|
||||
<div class="controls">
|
||||
<%= f.file_field :file %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="">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="">Description</label>
|
||||
<div class="controls">
|
||||
<%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<%= f.submit "Save", :class=>"btn" %>
|
||||
</div>
|
||||
</div>
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
<%= form_for @location, :url=> panel_gprs_back_end_location_path(@location), :html => { :class=>"form-horizontal"} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
<%= form_for @location, :url=> panel_gprs_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
Whitespace-only changes.
-4
@@ -1,4 +0,0 @@
|
||||
require "gprs/engine"
|
||||
|
||||
module Gprs
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class GprsTest < ActiveSupport::TestCase
|
||||
test "truth" do
|
||||
assert_kind_of Module, Gprs
|
||||
end
|
||||
end
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class Panel::Gprs::BackEnd::LocationsHelperTest < ActionView::TestCase
|
||||
end
|
||||
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
source "http://rubygems.org"
|
||||
|
||||
# Declare your gem's dependencies in gprs.gemspec.
|
||||
# Declare your gem's dependencies in location.gemspec.
|
||||
# Bundler will treat runtime dependencies like base dependencies, and
|
||||
# development dependencies will be added by default to the :development group.
|
||||
gemspec
|
||||
File renamed without changes.
@@ -0,0 +1,3 @@
|
||||
= Location
|
||||
|
||||
This project rocks and uses MIT-LICENSE.
|
||||
+1
-1
@@ -14,7 +14,7 @@ end
|
||||
|
||||
RDoc::Task.new(:rdoc) do |rdoc|
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = 'Gprs'
|
||||
rdoc.title = 'Location'
|
||||
rdoc.options << '--line-numbers'
|
||||
rdoc.rdoc_files.include('README.rdoc')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+23
-23
@@ -1,13 +1,11 @@
|
||||
class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
|
||||
class Panel::Location::BackEnd::LocationsController < OrbitBackendController
|
||||
include AdminHelper
|
||||
|
||||
#before_filter :clean_values, :only => [:create, :update]
|
||||
|
||||
before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
|
||||
before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :create, :update, :delete]
|
||||
before_filter :force_order_for_user,:except => [:get_locations,:index]
|
||||
#before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations]
|
||||
|
||||
def index
|
||||
@locations = Location.all
|
||||
@location_infos = LocationInfo.all
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @locations }
|
||||
@@ -15,7 +13,7 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
|
||||
end
|
||||
|
||||
def new
|
||||
@location = Location.new
|
||||
@location_info = LocationInfo.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
@@ -24,11 +22,11 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
|
||||
end
|
||||
|
||||
def edit
|
||||
@location = Location.find(params[:id])
|
||||
@location_info = LocationInfo.find(params[:id])
|
||||
end
|
||||
|
||||
def show
|
||||
@location = Location.find(params[:id])
|
||||
@location_info = LocationInfo.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @location }
|
||||
@@ -36,29 +34,34 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
|
||||
end
|
||||
|
||||
def create
|
||||
@location = Location.new(params[:location])
|
||||
@location.save!
|
||||
redirect_to panel_gprs_back_end_locations_url
|
||||
@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 = Location.find(params[:id])
|
||||
@location.update_attributes(params[:location])
|
||||
redirect_to panel_gprs_back_end_locations_url
|
||||
@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 = Location.find(params[:id])
|
||||
@location.destroy
|
||||
redirect_to panel_gprs_back_end_locations_url
|
||||
@location_info = LocationInfo.find(params[:id])
|
||||
@location_info.destroy
|
||||
redirect_to panel_location_back_end_locations_url
|
||||
|
||||
end
|
||||
|
||||
def get_locations
|
||||
locations = Location.all
|
||||
location_infos = LocationInfo.all
|
||||
@data = Array.new
|
||||
|
||||
locations.each do |location|
|
||||
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,
|
||||
@@ -69,9 +72,6 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
|
||||
description: location.description }
|
||||
end
|
||||
|
||||
#print readable json
|
||||
render :json => JSON.pretty_generate({location: @data})
|
||||
|
||||
#render :json => {location: @data}.to_json
|
||||
end
|
||||
end
|
||||
File renamed without changes.
+2
@@ -0,0 +1,2 @@
|
||||
module Panel::Location::BackEnd::LocationsHelper
|
||||
end
|
||||
File renamed without changes.
File renamed without 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
|
||||
|
||||
File renamed without 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 %>
|
||||
|
||||
+7
-8
@@ -13,22 +13,21 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_locations" class="sort-holder">
|
||||
<% @locations.each do |location| %>
|
||||
<% @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.name %></td>
|
||||
<td><%= location.longitude%></td>
|
||||
<td><%= location.latitude%></td>
|
||||
<td><%= location.description%></td>
|
||||
<td><%= location.description %></td>
|
||||
<%if is_manager? %>
|
||||
<td><%= link_to 'Edit', edit_panel_gprs_back_end_location_path(location) %></td>
|
||||
<td><%= link_to 'Destroy', panel_gprs_back_end_location_path(location), method: :delete , :confirm => t(:sure?) %></td>
|
||||
<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_gprs_back_end_location_path %></td>
|
||||
<% end %>
|
||||
<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 %>
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
Rails.application.routes.draw do
|
||||
namespace :panel do
|
||||
namespace :gprs do
|
||||
namespace :location do
|
||||
namespace :back_end do
|
||||
|
||||
match "locations/get_locations" => "locations#get_locations"
|
||||
@@ -0,0 +1,4 @@
|
||||
require "location/engine"
|
||||
|
||||
module Location
|
||||
end
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
module Gprs
|
||||
module Location
|
||||
class Engine < Rails::Engine
|
||||
end
|
||||
end
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
module Gprs
|
||||
module Location
|
||||
VERSION = "0.0.1"
|
||||
end
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# desc "Explaining what the task does"
|
||||
# task :gprs do
|
||||
# task :location do
|
||||
# # Task goes here
|
||||
# end
|
||||
Vendored
+5
-5
@@ -1,17 +1,17 @@
|
||||
$:.push File.expand_path("../lib", __FILE__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
require "gprs/version"
|
||||
require "location/version"
|
||||
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "gprs"
|
||||
s.version = Gprs::VERSION
|
||||
s.name = "location"
|
||||
s.version = Location::VERSION
|
||||
s.authors = ["TODO: Your name"]
|
||||
s.email = ["TODO: Your email"]
|
||||
s.homepage = "TODO"
|
||||
s.summary = "TODO: Summary of Gprs."
|
||||
s.description = "TODO: Description of Gprs."
|
||||
s.summary = "TODO: Summary of Location."
|
||||
s.description = "TODO: Description of Location."
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
||||
s.test_files = Dir["test/**/*"]
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"title": "location",
|
||||
"version": "0.1",
|
||||
"organization": "Rulingcom",
|
||||
"author": "RD dep",
|
||||
"intro": "A simple blog……",
|
||||
"update_info": "Some info",
|
||||
"create_date": "11-11-2011",
|
||||
"widgets": [],
|
||||
"category": [],
|
||||
"enable_frontend": false
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
|
||||
require 'rails/all'
|
||||
|
||||
Bundler.require
|
||||
require "gprs"
|
||||
require "location"
|
||||
|
||||
module Dummy
|
||||
class Application < Rails::Application
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class Panel::Gprs::BackEnd::LocationsControllerTest < ActionController::TestCase
|
||||
class Panel::Location::BackEnd::LocationsControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
File renamed without changes.
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class LocationTest < ActiveSupport::TestCase
|
||||
test "truth" do
|
||||
assert_kind_of Module, Location
|
||||
end
|
||||
end
|
||||
File renamed without changes.
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class Panel::Location::BackEnd::LocationsHelperTest < ActionView::TestCase
|
||||
end
|
||||
Reference in new issue
Block a user