build interface to work with object auth. Go to panel/new_blog/back_end/posts/ ,click New Auth link
This commit is contained in:
parent
31d7cd5b38
commit
32159564cd
|
@ -4,14 +4,6 @@ class Admin::ObjectAuthsController < ApplicationController
|
|||
# before_filter :is_admin? ,:only => :index
|
||||
|
||||
def index
|
||||
# @roles = Role.all.entries
|
||||
# apps = Purchase.where(:type =>"App")
|
||||
# @app_auth_data = apps.entries.map do |app|
|
||||
# app_c = eval(app.app_controller)
|
||||
# obj = app_c.new
|
||||
# obj_auth = obj.send "auth"
|
||||
# [:app_obj => app,:auth_field => obj_auth]
|
||||
# end
|
||||
# if current_user.admin?
|
||||
@object_auths = ObjectAuth.all
|
||||
# else
|
||||
|
@ -19,6 +11,21 @@ class Admin::ObjectAuthsController < ApplicationController
|
|||
# end
|
||||
end
|
||||
|
||||
def new
|
||||
obj = eval(params[:type]).find params[:obj_id]
|
||||
@object_auth=obj.object_auths.build
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @post }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
obj = eval(params[:object_auth][:type]).find params[:object_auth][:obj_id]
|
||||
@object_auth=obj.object_auths.create :title=> params[:object_auth][:title]
|
||||
redirect_to edit_admin_object_auth_path(@object_auth)
|
||||
end
|
||||
|
||||
def create_role
|
||||
object_auth = ObjectAuth.find(params[:id])
|
||||
params[:new].each do |item|
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<% content_for :secondary do %>
|
||||
<ul class="list">
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<%= flash_messages %>
|
||||
<h1><%= t('object_auth.new_object_auth') %></h1>
|
||||
<%= form_for @object_auth, :url => admin_object_auths_path do |f| %>
|
||||
<%= f.label :title %>
|
||||
<%= f.text_field :title, :class => 'text' %>
|
||||
<%= f.hidden_field :obj_id, :value => params[:obj_id] %>
|
||||
<%= f.hidden_field :type, :value => params[:type] %>
|
||||
|
||||
<%= submit_tag 'Add Auth' %><br/>
|
||||
|
||||
<% end %>
|
||||
|
||||
<%= link_back %>
|
|
@ -14,8 +14,11 @@ PrototypeR4::Application.routes.draw do
|
|||
resources :assets
|
||||
resources :app_auths
|
||||
resources :object_auths do
|
||||
collection do
|
||||
match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init
|
||||
end
|
||||
member do
|
||||
match ':id/create_role',:action => 'create_role',:iia => "post",:as => :create_role
|
||||
match ':id/create_role',:action => 'create_role',:via => "post",:as => :create_role
|
||||
match 'remove/:type/:target_id' ,:action=> 'remove_role',:via => "delete",:as =>:remove
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,13 +30,5 @@ module OrbitCoreLib
|
|||
users
|
||||
end
|
||||
|
||||
def tell_me_class
|
||||
self.class.name
|
||||
end
|
||||
|
||||
def search_object_db
|
||||
ObjectAuth.where(obj_authable_type: self.class.name)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<tr>
|
||||
<td><%= post.title %></td>
|
||||
<td><%= truncate(post.body,:length=>15) %></td>
|
||||
<td><%= link_to t('blog.new_auth'), init_admin_object_auths_path("Post",post) %></td>
|
||||
<td><%= link_to t('blog.show'), panel_new_blog_back_end_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.edit'), edit_panel_new_blog_back_end_post_path(post) %></td>
|
||||
<td><%= link_to t('blog.delete'), panel_new_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<%= flash_messages %>
|
||||
<h1><%= t('blog.new_post') %></h1>
|
||||
<%= form_for @post, :url => panel_new_blog_back_end_posts_path do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<%= f.text_field :title, :class => 'text' %>
|
||||
<% end %>
|
||||
|
||||
<%= link_back %>
|
||||
|
|
Reference in New Issue