From 71a5731fe8609e61fc93f6183fe8b42eec1b9911 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 9 May 2012 14:54:20 +0800 Subject: [PATCH 1/9] Permission setting for announcement for bulletin cate --- dump.rdb | Bin 0 -> 1102 bytes .../back_end/approvals_controller.rb | 42 ++---------- .../bulletin_category_setting_controller.rb | 63 ++++++++++++++++++ .../back_end/bulletin_categorys_helper.rb | 12 ++-- .../_modal_list.html.erb | 44 ++++++++++++ .../_privilege_user.html.erb | 26 ++++++++ .../setting.html.erb | 56 ++++++++++++++++ .../bulletin_category_setting/setting.js.erb | 2 + .../update_setting.js.erb | 1 + .../user_list.js.erb | 2 + .../_bulletin_category.html.erb | 2 +- .../announcement/config/routes.rb | 6 +- 12 files changed, 211 insertions(+), 45 deletions(-) create mode 100644 dump.rdb create mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_category_setting_controller.rb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/_modal_list.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/_privilege_user.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/setting.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/setting.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/update_setting.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/user_list.js.erb diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..e1bc5a6eb2e06156a00475f3f93497eb9b8adc60 GIT binary patch literal 1102 zcma)*O-sW-5Qew0S3eL01<@Km4%NbJnrxH3+6rDgSa0HCP1Yuu+Pa%kMf`8^kEz=x zBvIKQ_Il9290CCTM8=xn@_EMTd?FsXkj?cmOOg(Y1SOW|(e_4h#xC(} z+AagSw*4o-p>1^X14(}as7#nhc(7vuwmRT+z-?iVst=%b3NAn`K~?w%;aKA#^Q-}Y zLoJe7XdL8#p&#;K7IQIpVdH7cscM#LS3H?F_TNlDW>T8eyx@r+-b7<=o|#OH)UVsS zcVjhYEK{V>45LxFqB7BDE~ri<^npb&57I-V^PCMr=eb9nUf#Ct99y`dw(Z!&f)pW* z23CrUz1q80jq4~~Rbi`osi~OwTuL5%95uDIZM`qNAZn`Nx;#gl=Yn1%-8v?zVd^!4 zdo_7_jbK-sN3fTohFLo=x>z&AESK}j_h;uU=1&0=)&1NpLx!(Ue*eBI7TdVo(PEtC LYtCL$YJ7bI+M8Uz literal 0 HcmV?d00001 diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 566b0742..9f63a8ab 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -7,9 +7,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle @bulletin = Bulletin.find params[:bulletin_id] end - def approve - - end + # def approve + # + # end def setting @bulletin_categorys = BulletinCategory.all @@ -39,41 +39,7 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle def user_list @bulletin_category = BulletinCategory.find params[:category][:id] end - # def index - # get_categorys(params[:bulletin_category_id]) - # - # @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all - # @bulletin_categories = BulletinCategory.all - # - # module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) - # @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) - # - # respond_to do |format| - # format.html # index.html.erb - # format.js - # format.xml { render :xml => @bulletins } - # end - # end - # - # def new - # - # end - # - # def create - # - # end - # - # def update - # - # end - # - # def edit - # - # end - # - # def destroy - # - # end + protected def update_setting_by_params category = BulletinCategory.find params[:category][:id] diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_category_setting_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_category_setting_controller.rb new file mode 100644 index 00000000..4be5f6bc --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_category_setting_controller.rb @@ -0,0 +1,63 @@ +class Panel::Announcement::BackEnd::BulletinCategorySettingController < OrbitBackendController + before_filter :authenticate_user! + before_filter :for_app_manager + include AdminHelper + # layout 'admin' + def preview_and_approve + @bulletin = Bulletin.find params[:bulletin_id] + end + + # def approve + # + # end + + def setting + @bulletin_categorys = [] + @bulletin_categorys << BulletinCategory.find(params[:bulletin_category_id]) + @options_from_collection_for_select_bulletin_categorys = @bulletin_categorys.collect{|bc| [bc.i18n_variable[I18n.locale],bc.id] } + if params.has_key? :category + @bulletin_category = BulletinCategory.find params[:category][:id] + else + @bulletin_category = @bulletin_categorys.first + end + preload_object_auth = @bulletin_category.object_auths.where(title: 'submit').empty?? (@bulletin_category.object_auths.create! :title=> 'submit') : @bulletin_category.object_auths.where(title: 'submit') + @users_array = preload_object_auth.first.privilege_users rescue [] + respond_to do |format| + format.html + format.js + end + end + + def update_setting + object_auth = update_setting_by_params + if object_auth.save! + flash[:notice] = "Update Done" + else + flash[:notice] = "Update Failed" + end + end + + def user_list + @bulletin_category = BulletinCategory.find params[:category][:id] + end + + protected + def update_setting_by_params + category = BulletinCategory.find params[:category][:id] + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + object_auth_ary = category.object_auths.where(title: 'submit') || (category.object_auths.create :title=> 'submit') + object_auth = object_auth_ary.first + object_auth.privilege_users = privilege_users + object_auth + end + + def get_categorys(id = nil) + @bulletin_categorys = [] + if(is_manager? || is_admin?) + @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + elsif is_sub_manager? + @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + end + end + +end diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb index 27dbe8f0..96e09e61 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb @@ -2,13 +2,15 @@ module Panel::Announcement::BackEnd::BulletinCategorysHelper include ActionView::Helpers::UrlHelper - def show_submit_permission_link(bulletin_category) - oa = bulletin_category.get_object_auth_by_title('submit') + def show_permission_link(bulletin_category) + type = 'submit' + oa = bulletin_category.get_object_auth_by_title(type) if oa.nil? - bulletin_category.object_auths.new(title: 'submit' ).save - oa = bulletin_category.get_object_auth_by_title('submit') + bulletin_category.object_auths.new(title: type ).save + oa = bulletin_category.get_object_auth_by_title(type) end - link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) +# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) + link_to t('announcement.bulletin.cate_auth'),panel_announcement_back_end_bulletin_category_setting_path(bulletin_category) end end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/_modal_list.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/_modal_list.html.erb new file mode 100644 index 00000000..a73fdab2 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_category_setting/_modal_list.html.erb @@ -0,0 +1,44 @@ +<% if bulletin_category -%> + +