diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb
index 7c6f60f0..ce404e53 100644
--- a/app/controllers/admin/object_auths_controller.rb
+++ b/app/controllers/admin/object_auths_controller.rb
@@ -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
diff --git a/app/views/admin/object_auths/new.html.erb b/app/views/admin/object_auths/new.html.erb
new file mode 100644
index 00000000..25fd6fd5
--- /dev/null
+++ b/app/views/admin/object_auths/new.html.erb
@@ -0,0 +1,23 @@
+<% content_for :secondary do %>
+
+<% end -%>
+
+
+
+
+
+
+<%= flash_messages %>
+<%= t('object_auth.new_object_auth') %>
+<%= 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' %>
+
+<% end %>
+
+<%= link_back %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index abe29824..d2fe14b8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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
diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb
index 8056f4f9..bf1d66a3 100644
--- a/lib/orbit_core_lib.rb
+++ b/lib/orbit_core_lib.rb
@@ -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
diff --git a/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/index.html.erb b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/index.html.erb
index 9473b70b..54ed9f1e 100644
--- a/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/index.html.erb
+++ b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/index.html.erb
@@ -21,6 +21,7 @@
<%= post.title %> |
<%= truncate(post.body,:length=>15) %> |
+ <%= link_to t('blog.new_auth'), init_admin_object_auths_path("Post",post) %> |
<%= link_to t('blog.show'), panel_new_blog_back_end_post_path(post) %> |
<%= link_to t('blog.edit'), edit_panel_new_blog_back_end_post_path(post) %> |
<%= link_to t('blog.delete'), panel_new_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %> |
diff --git a/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/new.html.erb b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/new.html.erb
index af5aa326..21758da8 100644
--- a/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/new.html.erb
+++ b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/new.html.erb
@@ -7,7 +7,7 @@
<%= flash_messages %>
<%= t('blog.new_post') %>
<%= 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 %>