refine the location module done

This commit is contained in:
Rueshyna 2012-11-08 12:34:26 +08:00
parent dbfc70e520
commit e6a9555dd8
5 changed files with 22 additions and 22 deletions

View File

@ -1,10 +1,10 @@
class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
before_filter :clean_values, :only => [:create, :update] #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, :delete]
before_filter :force_order_for_user,:except => :get_locations before_filter :force_order_for_user,:except => :get_locations
before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations] #before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations]
def index def index
@locations = Location.all @locations = Location.all
@ -28,7 +28,7 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
end end
def show def show
@location = Location..find(params[:id]) @location = Location.find(params[:id])
respond_to do |format| respond_to do |format|
format.html format.html
format.json { render json: @location } format.json { render json: @location }
@ -36,22 +36,22 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController
end end
def create def create
debugger
@location = Location.new(params[:location]) @location = Location.new(params[:location])
if @location.save @location.save!
format.html { redirect_to @location } redirect_to panel_gprs_back_end_locations_url
format.json { render json: @location, status: :created, location: @location }
end end
#render :action => "new"
def update
@location = Location.find(params[:id])
@location.update_attributes(params[:location])
redirect_to panel_gprs_back_end_locations_url
end end
def destroy def destroy
@location = Location..find(params[:id]) @location = Location.find(params[:id])
@location.destroy @location.destroy
redirect_to panel_gprs_back_end_locations_url
respond_to do |format|
format.json { head :no_content }
end
end end
def get_locations def get_locations

View File

@ -1,4 +1,3 @@
<%= form_for @location, :url => 'panel_gprs_back_end_locations_path' ,:class=>"form-horizontal" do |f| %>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="">Name</label> <label class="control-label" for="">Name</label>
<div class="controls"> <div class="controls">
@ -29,6 +28,3 @@
<%= f.submit "Save", :class=>"btn" %> <%= f.submit "Save", :class=>"btn" %>
</div> </div>
</div> </div>
<% end %>
<!-- </form> -->

View File

@ -1,2 +1,4 @@
<%= render 'form' %> <%= form_for @location, :url=> panel_gprs_back_end_location_path(@location), :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -18,11 +18,11 @@
<td><%= location.longitude%></td> <td><%= location.longitude%></td>
<td><%= location.latitude%></td> <td><%= location.latitude%></td>
<td><%= location.description%></td> <td><%= location.description%></td>
<td><%= link_to 'Edit', edit_panel_gprs_back_end_locations_path(location) %></td> <td><%= link_to 'Edit', edit_panel_gprs_back_end_location_path(location) %></td>
<td><%= link_to 'Destroy', location, method: :delete %> <td><%= link_to 'Destroy', panel_gprs_back_end_location_path(location), method: :delete , :confirm => t(:sure?) %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<td><%= link_to 'New', new_panel_gprs_back_end_locations_path %></td> <td><%= link_to 'New', new_panel_gprs_back_end_location_path %></td>

View File

@ -1 +1,3 @@
<%= render 'form' %> <%= form_for @location, :url=> panel_gprs_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>