gprs byebye, location have two language, must have picture, long, lang have limit
This commit is contained in:
parent
91afad23ba
commit
c44b4163e4
|
@ -69,8 +69,8 @@
|
|||
<%= content_tag :li, link_to(t(:tags), panel_calendar_back_end_tags_path), :class => active_for_action('/panel/calendar/back_end/tags', 'index')if (is_manager? rescue nil) %>
|
||||
<% end -%>
|
||||
<% end %>
|
||||
<%= content_tag :li, :class => active_for_controllers('locations') || active_for_app_auth("gprs") do -%>
|
||||
<%= link_to content_tag(:i, nil, :class => 'icons-location') + content_tag(:span, t(:location)), panel_gprs_back_end_locations_path %>
|
||||
<%= content_tag :li, :class => active_for_controllers('locations') do -%>
|
||||
<%= link_to content_tag(:i, nil, :class => 'icons-location') + content_tag(:span, t(:location)), panel_location_back_end_locations_path %>
|
||||
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('locations') ) do -%>
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
= Gprs
|
||||
|
||||
This project rocks and uses MIT-LICENSE.
|
|
@ -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
|
|
@ -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>
|
|
@ -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 %>
|
||||
|
|
@ -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 %>
|
|
@ -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
|
|
@ -1,4 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Panel::Gprs::BackEnd::LocationsHelperTest < ActionView::TestCase
|
||||
end
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
|||
= Location
|
||||
|
||||
This project rocks and uses MIT-LICENSE.
|
|
@ -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')
|
|
@ -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
|
2
vendor/built_in_modules/location/app/helpers/panel/location/back_end/locations_helper.rb
vendored
Normal file
2
vendor/built_in_modules/location/app/helpers/panel/location/back_end/locations_helper.rb
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
module Panel::Location::BackEnd::LocationsHelper
|
||||
end
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
class GprsUploader < CarrierWave::Uploader::Base
|
||||
class LocationsUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or ImageScience support:
|
||||
# include CarrierWave::RMagick
|
||||
|
@ -12,7 +12,7 @@ class GprsUploader < CarrierWave::Uploader::Base
|
|||
# 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
|
||||
"gprs/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
"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:
|
38
vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb
vendored
Normal file
38
vendor/built_in_modules/location/app/views/panel/location/back_end/locations/_form.html.erb
vendored
Normal file
|
@ -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
vendor/built_in_modules/location/app/views/panel/location/back_end/locations/edit.html.erb
vendored
Normal file
4
vendor/built_in_modules/location/app/views/panel/location/back_end/locations/edit.html.erb
vendored
Normal file
|
@ -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 %>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
</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>
|
||||
|
@ -21,14 +21,13 @@
|
|||
<td><%= location.latitude%></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>
|
||||
<td><%= link_to 'New', new_panel_location_back_end_location_path %></td>
|
||||
<% end %>
|
3
vendor/built_in_modules/location/app/views/panel/location/back_end/locations/new.html.erb
vendored
Normal file
3
vendor/built_in_modules/location/app/views/panel/location/back_end/locations/new.html.erb
vendored
Normal file
|
@ -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 %>
|
|
@ -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,4 +1,4 @@
|
|||
module Gprs
|
||||
module Location
|
||||
class Engine < Rails::Engine
|
||||
end
|
||||
end
|
|
@ -1,3 +1,3 @@
|
|||
module Gprs
|
||||
module Location
|
||||
VERSION = "0.0.1"
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
# desc "Explaining what the task does"
|
||||
# task :gprs do
|
||||
# task :location do
|
||||
# # Task goes here
|
||||
# end
|
|
@ -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/**/*"]
|
|
@ -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
|
||||
}
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class LocationTest < ActiveSupport::TestCase
|
||||
test "truth" do
|
||||
assert_kind_of Module, Location
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Panel::Location::BackEnd::LocationsHelperTest < ActionView::TestCase
|
||||
end
|
Reference in New Issue