build interface to work with object auth. Go to panel/new_blog/back_end/posts/ ,click New Auth link
This commit is contained in:
1 parent
e20739e32b
commit
436f039c1b
6 files changed
+61
-35
No files matched your search
@@ -4,40 +4,47 @@ 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
|
||||
# @module_apps = current_user.managing_apps.collect{|t| t.managing_app}
|
||||
# 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|
|
||||
field = item[0]
|
||||
field_value = item[1]
|
||||
if field_value!=''
|
||||
case field
|
||||
when 'role'
|
||||
object_auth.send("add_#{field}",(Role.find field_value)) rescue nil
|
||||
when 'sub_role'
|
||||
object_auth.send("add_#{field}",(SubRole.find field_value)) rescue nil
|
||||
when 'privilege_user'
|
||||
object_auth.add_user_to_privilege_list (User.find field_value) rescue nil
|
||||
when 'blocked_user'
|
||||
object_auth.add_user_to_black_list (User.find field_value) rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to edit_admin_object_auth_path(object_auth)
|
||||
params[:new].each do |item|
|
||||
field = item[0]
|
||||
field_value = item[1]
|
||||
if field_value!=''
|
||||
case field
|
||||
when 'role'
|
||||
object_auth.send("add_#{field}",(Role.find field_value)) rescue nil
|
||||
when 'sub_role'
|
||||
object_auth.send("add_#{field}",(SubRole.find field_value)) rescue nil
|
||||
when 'privilege_user'
|
||||
object_auth.add_user_to_privilege_list (User.find field_value) rescue nil
|
||||
when 'blocked_user'
|
||||
object_auth.add_user_to_black_list (User.find field_value) rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to edit_admin_object_auth_path(object_auth)
|
||||
end
|
||||
|
||||
def remove_role
|
||||
|
||||
@@ -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 %>
|
||||
Reference in new issue
Block a user