Permalink
Browse files

[^] add edit for places

  • Loading branch information...
1 parent cf28efb commit 67abda0a1c1ea5bba62e18e0d0ce3bec5ecef52b @x13enos committed Mar 29, 2012
View
235 Application Log
@@ -0,0 +1,235 @@
+# Logfile created on 2012-03-28 22:45:06 +0300 by logger.rb/25413
+
+
+Started PUT "/admin/categorys/18" for 127.0.0.1 at 2012-03-28 22:46:04 +0300
+
+
+Started PUT "/admin/categorys/18" for 127.0.0.1 at 2012-03-28 22:47:52 +0300
+
+
+Started PUT "/admin/categorys/18" for 127.0.0.1 at 2012-03-28 22:47:58 +0300
+
+
+Started PUT "/admin/categorys/18" for 127.0.0.1 at 2012-03-28 22:48:35 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:52:32 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:52:32 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:52:32 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:52:32 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:52:32 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:52:32 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:52:32 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:53:30 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:53:49 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:53:49 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:53:49 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:53:49 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:53:49 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:53:49 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:53:49 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:54:01 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:01 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:54:01 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:01 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:01 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:01 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:01 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:54:12 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:54:19 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:54:24 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:54:33 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:54:36 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:54:45 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:54:45 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:45 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:45 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:45 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:45 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:54:45 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:55:07 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:55:07 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:55:07 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:55:07 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:55:07 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:55:07 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:55:07 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:57:14 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:57:14 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:14 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:14 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:14 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:14 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:14 +0300
+
+
+Started PUT "/admin/categorys/18" for 127.0.0.1 at 2012-03-28 22:57:21 +0300
+
+
+Started GET "/admin" for 127.0.0.1 at 2012-03-28 22:57:40 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:57:40 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:40 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:40 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:40 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:40 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:40 +0300
+
+
+Started GET "/admin/categorys" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/admin/close-icon.gif" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/assets/admin/edit_icon.jpg" for 127.0.0.1 at 2012-03-28 22:57:41 +0300
+
+
+Started GET "/admin/categorys/18/edit" for 127.0.0.1 at 2012-03-28 22:57:45 +0300
+
+
+Started GET "/assets/admin.css?body=1" for 127.0.0.1 at 2012-03-28 22:57:45 +0300
+
+
+Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:45 +0300
+
+
+Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:45 +0300
+
+
+Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:45 +0300
+
+
+Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:45 +0300
+
+
+Started GET "/assets/lightbox.js?body=1" for 127.0.0.1 at 2012-03-28 22:57:45 +0300
+
+
+Started PUT "/admin/categorys/18" for 127.0.0.1 at 2012-03-28 22:57:50 +0300
+
+
+Started PUT "/admin/categorys/18" for 127.0.0.1 at 2012-03-28 22:58:23 +0300
View
BIN app/assets/images/admin/edit_icon.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3 app/assets/javascripts/admin.js.coffee
@@ -49,14 +49,13 @@ $ ->
google.maps.event.addListener(marker_man, 'dragend', ->
- latlng_val(marker_man.position.Ua, marker_man.position.Va)
+ latlng_val(marker_man.position.Ta, marker_man.position.Ua)
)
$('#button_return').click( ->
marker_man.setOptions(
position: initialLocation
- map: map
)
map.setOptions(center: initialLocation)
latlng_val(position.coords.latitude, position.coords.longitude)
View
5 app/assets/javascripts/my_places.js.coffee
@@ -21,7 +21,7 @@ $ ->
url: "/places/get"
success: (data) ->
$(data).each( ->
- $(this.places).each( ->
+ $(this.sort_places).each( ->
marker = new google.maps.Marker(
position: new google.maps.LatLng(this.lat, this.long)
map: map
@@ -69,14 +69,13 @@ $ ->
google.maps.event.addListener(marker_man, 'dragend', ->
- latlng_val(marker_man.position.Ua, marker_man.position.Va)
+ latlng_val(marker_man.position.Ta, marker_man.position.Ua)
)
$('#button_return').click( ->
marker_man.setOptions(
position: initialLocation
- map: map
)
map.setOptions(center: initialLocation)
latlng_val(position.coords.latitude, position.coords.longitude)
View
2 app/assets/javascripts/places.js.coffee
@@ -16,7 +16,7 @@ $ ->
success: (data) ->
$(data).each( ->
array_marker = []
- $(this.places).each( ->
+ $(this.sort_places).each( ->
marker = new google.maps.Marker(
position: new google.maps.LatLng(this.lat, this.long)
map: map
View
10 app/controllers/admin/categorys_controller.rb
@@ -20,6 +20,16 @@ def create
redirect_to admin_categorys_path
end
+ def edit
+ @category = Category.find(params[:id])
+ end
+
+ def update
+ @category = Category.find(params[:id])
+ @category.update_attributes(params[:category])
+ redirect_to admin_categorys_path
+ end
+
def destroy
@category = Category.find(params[:id])
@category.destroy
View
28 app/controllers/admin/places_controller.rb
@@ -1,9 +1,14 @@
# -*- encoding : utf-8 -*-
class Admin::PlacesController < AdminController
- before_filter :get_category
def index
- @places = @category.places
+ if params[:filter] == "untested_places"
+ @places = Place.where('enable = ?', false)
+ else
+ get_category
+ @places = @category.places
+ end
+
respond_to do |format|
@@ -24,25 +29,34 @@ def new
end
def create
+ get_category
@place = @category.places.new(params[:place].merge(:enable => true), :without_protection => true)
@place.save
redirect_to admin_category_places_path(@category.id)
end
+ def edit
+ @place = Place.find(params[:id])
+ end
+
+ def update
+ @place = Place.find(params[:id])
+ @place.update_attributes(params[:place], :without_protection => true)
+ redirect_to :back
+ end
+
def destroy
@place = Place.find(params[:id])
if @place.destroy
- redirect_to admin_category_places_path(@category.id), :notice => "Координаты были удалены"
+ redirect_to admin_places_path(:filter => 'untested_places'), :notice => "Координаты были удалены"
else
- redirect_to admin_category_places_path(@category.id), :notice => "Ошибка при удалении"
+ redirect_to admin_places_path(:filter => 'untested_places'), :notice => "Ошибка при удалении"
end
end
private
def get_category
- @category = Category.find(params[:category_id])
+ @category = Category.find(params[:filter])
end
-
-
end
View
2 app/controllers/my/places_controller.rb
@@ -19,7 +19,7 @@ def new
def create
@place = current_user.places.new(params[:place])
@place.save
- redirect_to my_places_path
+ redirect_to places_path
end
def get_places
View
2 app/views/admin/categorys/_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_for @category, :url => :admin_categorys do |f| %>
+<%= form_for [:admin, @category] do |f| %>
<div>
<%= f.label :name %><br />
View
3 app/views/admin/categorys/edit.html.erb
@@ -0,0 +1,3 @@
+<h2>Редактирование категории</h2>
+
+<%= render 'form' %>
View
5 app/views/admin/categorys/index.html.erb
@@ -1,8 +1,9 @@
<% @categorys.each do |c| %>
<div class="category_admin">
- <%= link_to c.name, admin_category_places_path(c) %>
+ <%= link_to c.name, admin_places_path(:filter => c.id, :filter_name => c.name) %>
<%= link_to image_tag("admin/close-icon.gif"), admin_category_path(c), :method => :delete %>
+ <%= link_to image_tag("admin/edit_icon.jpg"), edit_admin_category_path(c) %>
</div>
<% end %>
-<div><%= link_to "Новая категория", new_admin_category_path, :id => "new_category" %></div>
+<div><%= link_to "Новая категория", new_admin_category_path, :id => "new_category" %></div>
View
7 app/views/admin/places/_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_for @place, :url => :admin_category_places do |f| %>
+<%= form_for [:admin, @place] do |f| %>
<div>
<%= f.label "Широта" %>
<%= f.text_field :lat, :id => 'lat' %>
@@ -7,5 +7,10 @@
<%= f.label "Долгота" %>
<%= f.text_field :long, :id => 'lag' %>
</div>
+ <div>
+ <%= f.label 'Утверждена' %>
+ <%= f.check_box :enable %>
+ </div>
+ <%= text_field_tag(:back_url, params[:back_url] ) %>
<%= f.submit "Сохранить координаты" %>
<% end %>
View
3 app/views/admin/places/edit.html.erb
@@ -0,0 +1,3 @@
+<h2>Редактирование метки</h2>
+
+<%= render 'form' %>
View
10 app/views/admin/places/index.html.erb
@@ -3,8 +3,14 @@
<div>
<%= c.lat %>,
<%= c.long %>
- <%= link_to image_tag("admin/close-icon.gif"), admin_category_place_path(@category.id, c), :method => :delete %>
+ <% if params[:filter] == 'untested_places' %>
+ <%= link_to image_tag('admin/edit_icon.jpg'), edit_admin_place_path(c, :back_url => 'untested_places') %>
+ <%= link_to image_tag("admin/close-icon.gif"), admin_place_path(c, :filter => 'untested_places'), :method => :delete %>
+ <% else %>
+ <%= link_to image_tag('admin/edit_icon.jpg'), edit_admin_place_path(c) %>
+ <%= link_to image_tag("admin/close-icon.gif"), admin_place_path(c), :method => :delete %>
+ <% end %>
</div>
<% end %>
-<%= link_to "Добавить координаты", new_admin_category_place_path(@category.id) %>
+<%= link_to "Добавить координаты", new_admin_place_path %>
View
1 app/views/layouts/admin.html.erb
@@ -16,6 +16,7 @@
<%= link_to "Типы кофе", admin_coffee_types_path %>
<%= link_to "Изображеньки", admin_images_path %>
<%= link_to "Категории меток", admin_categorys_path %>
+ <%= link_to "Непроверенные", admin_places_path(:filter => "untested_places") %>
</div>
View
2 app/views/places/index.html.erb
@@ -26,6 +26,8 @@
<%= c.name %>
</div>
<% end %>
+
+ <%= link_to 'Добавить свою метку', new_my_place_path %>
</div>
View
5 config/routes.rb
@@ -7,9 +7,8 @@
namespace :admin do
resources :coffee_types
resources :images
- resources :categorys do
- resources :places
- end
+ resources :categorys
+ resources :places
end
resources :admin, :only => :index
View
21,654 log/development.log
21,654 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 67abda0

Please sign in to comment.