diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1463de6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/log/*.log +test/dummy/tmp/ \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b2826c7 --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +source "http://rubygems.org" + +# Declare your gem's dependencies in personal_honor.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# jquery-rails is used by the dummy application +gem "jquery-rails" + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..406f17b --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2012 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..4feeb65 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += PersonalHonor + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..e63dfa9 --- /dev/null +++ b/Rakefile @@ -0,0 +1,39 @@ +#!/usr/bin/env rake +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'PersonalHonor' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task :default => :test diff --git a/app/assets/images/personal_honor/.gitkeep b/app/assets/images/personal_honor/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/personal_honor/.gitkeep b/app/assets/javascripts/personal_honor/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/personal_honor/desktop/personal_honors.js b/app/assets/javascripts/personal_honor/desktop/personal_honors.js new file mode 100644 index 0000000..18d17ac --- /dev/null +++ b/app/assets/javascripts/personal_honor/desktop/personal_honors.js @@ -0,0 +1,150 @@ +orbitDesktop.prototype.initializePersonalHonor = function(target,url,cache){ // this init journal papers + this.initializePersonalHonor.formCallback = function(data){ + if(data.success){ + o.notify(data.msg,"success"); + o.sub_menu_item($("div[content-type=menu] a").eq(0)); + }else{ + o.notify(data.msg,"alert"); + } + } + + this.initializePersonalHonor.list = function(){ // to open list part in journal papers page + var journalData; + var bindHandlers = function(){ // to bind handlers for list page + + } + bindHandlers(); + + var bindSecondaryHandlers = function(){ + $("#journal_p div#paper_list a.icon-check-empty").click(function(){ + if($(this).hasClass("icon-check-empty")){ + $(this).switchClass("icon-check-empty","icon-check",0); + } else if($(this) .hasClass("icon-check")) { + $(this).switchClass("icon-check","icon-check-empty",0); + } else if($(this).hasClass("icon-star")){ + $(this).removeClass("icon-star").addClass("icon-star-empty"); + } else if($(this).hasClass("icon-star-empty")){ + $(this).removeClass("icon-star-empty").addClass("icon-star"); + } + return false; + }) + } + o.enableSharing("div.share_mode"); + } + this.initializePersonalHonor.honorDelete = function(data,dom){ + var parent = dom.parent().parent().parent(); + if(data.success){ + parent.hide("slide",function(){parent.remove();}); + o.notify(data.msg,"success"); + } + } + + this.initializePersonalHonor.cancelhonor = function(){ + o.highlight_sub_menu_item(0); + } + + var uploadFiles = function(){ + $('#add_plugin_file a.add').click(function(){ + var new_id = $(this).prev().attr('value'); + var old_id = new RegExp("new_writing_journal_files", "g"); + $(this).prev().attr('value', parseInt(new_id) + 1); + var x = get_html(old_id,new_id); + var newfield = $(x); + $(this).parents('table').append(newfield); + newfield.find('.action a.delete').click(function(){ + newfield.remove(); + }); + return false; + }); + $('.action a.remove_existing_record').click(function(){ + $(this).toggleClass("color-red",function(){ + if($(this).hasClass('color-red')){ + $(this).next('.should_destroy').attr('value', 1); + }else{ + $(this).next('.should_destroy').removeAttr('value'); + } + }) + }); + } + + var languageSelect = function(){ + $(".language_select a").click(function(event) { + $("*[data-language]").hide(); + $("*[data-language="+$(this).data("lang")+"]").show(); + return false; + }); + } + + this.initializePersonalHonor.edithonor = function(){ + o.highlight_sub_menu_item(1); + uploadFiles(); + languageSelect(); + } + + this.initializePersonalHonor.addhonor = function(){ // to open add pages in journal papers page + uploadFiles(); + languageSelect(); + } + + this.initializePersonalHonor.brief = function(){ + o.enablelanguageSelect(); + $("textarea.editor").ckeditor({ + height: 300, + width: $(".overview").width() - 20 + }); + } + + this.initializePersonalHonor.coAuthorformCallback = function(data){ + if(data.success){ + o.notify(data.msg,"success"); + o.sub_menu_item($("div[content-type=menu] a").eq(3)); + }else{ + o.notify(data.msg,"alert"); + } + } + this.initializePersonalHonor.coauthor = function(){ // to open add pages in coauthor page + var bindHandlers = function(){ // to bind handlers for add page + + } + bindHandlers(); + } + this.initializePersonalHonor.coauthorRelationForm = function(data){ + if(data.success){ + o.notify(data.msg,"success"); + $("#co_author_relation_table").html(data.newvalue); + }else{ + o.notify(data.msg,"alert"); + } + } + this.initializePersonalHonor.coauthorRelationEditForm = function(data){ + if(data.success){ + o.notify(data.msg,"success"); + var x = o.layout_data.generate_layout_html(data.newvalue); + $("div[container=true] div.overview").html(x.markup); + }else{ + o.notify(data.msg,"alert"); + } + } + this.initializePersonalHonor.allnone = function(d,o){ + switch(o.attr("href")){ + case "all": + $("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check"); + break; + case "none": + $("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty"); + break; + } + } + this.initializePersonalHonor.allnone = function(d,o){ + switch(o.attr("href")){ + case "all": + $("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check"); + break; + case "none": + $("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty"); + break; + } + } +}; + + diff --git a/app/assets/stylesheets/personal_honor/.gitkeep b/app/assets/stylesheets/personal_honor/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/personal_honor/desktop/personal_honor.css b/app/assets/stylesheets/personal_honor/desktop/personal_honor.css new file mode 100644 index 0000000..fe90d85 --- /dev/null +++ b/app/assets/stylesheets/personal_honor/desktop/personal_honor.css @@ -0,0 +1,115 @@ +/* Books */ +[page-name="honor_list"] .list_t_item .inner { + padding-left: 30px; } +[page-name="honor_list"] .list_item_action { + font-size: 12px; + float: left; + margin-left: -30px; } + [page-name="honor_list"] .list_item_action a { + display: block; + width: 20px; + height: 20px; + line-height: 20px; + margin: 1px 1px 6px 1px; } + [page-name="honor_list"] .list_item_action .icon-star-empty { + color: #999; + font-size: 20px; } + [page-name="honor_list"] .list_item_action .icon-star { + color: #faa732; + font-size: 20px; } + [page-name="honor_list"] .list_item_action .icon-check-empty { + color: #999; + font-size: 20px; } + [page-name="honor_list"] .list_item_action .icon-check { + color: #333; + font-size: 20px; } +[page-name="honor_list"] .file_view .list_t_des { + overflow: hidden; } +[page-name="honor_list"] .file_view .file { + float: left; + width: 120px; + height: 50px; + padding: 6px; + margin: 1px; + position: relative; + -webkit-box-sizing: border-box; + /* webkit */ + -khtml-box-sizing: border-box; + /* konqueror */ + -moz-box-sizing: border-box; + /* firefox */ + -ms-box-sizing: border-box; + /* ie */ + box-sizing: border-box; + /* css3 */ } + [page-name="honor_list"] .file_view .file:hover { + background-color: #f7f7f7; } + [page-name="honor_list"] .file_view .file img { + width: 38px; + height: 38px; + position: absolute; + left: 6px; + top: 6px; } + [page-name="honor_list"] .file_view .file .filetitle { + display: block; + width: 100%; + height: 38px; + padding-left: 40px; + overflow: hidden; + -webkit-box-sizing: border-box; + /* webkit */ + -khtml-box-sizing: border-box; + /* konqueror */ + -moz-box-sizing: border-box; + /* firefox */ + -ms-box-sizing: border-box; + /* ie */ + box-sizing: border-box; + /* css3 */ } + +/* Books Books list */ +[page-name="books_books"] .datalist_item .inner { + padding-left: 30px; } +[page-name="books_books"] .list_item_action { + font-size: 12px; + float: left; + margin-left: -30px; } +[page-name="books_books"] .list_item_action i { + color: #999; + font-size: 20px; + display: block; + width: 20px; + height: 20px; + line-height: 20px; + margin: 1px 1px 6px 1px; } +[page-name="books_books"] .list_t_desc { + font-family: Arial, sans-serif; + font-size: 12px; + color: #999; } + +/* Books Co-Author */ +[page-name="books_coauthor"] .list_t_item { + height: 110px; } +[page-name="books_coauthor"] .list_item_function a { + display: inline-block; + padding: 4px; + font-family: Arial, sans-serif; + font-size: 11px; + -webkit-text-size-adjust: none; } +[page-name="books_coauthor"] .info { + font-family: Arial, sans-serif; } +[page-name="books_coauthor"] .info li { + margin-bottom: 8px; + color: #999; } +[page-name="books_coauthor"] .info .name { + font-size: 18px; + line-height: 24px; + color: #333; } + +/* Books Co-Author Relationship*/ +[page-name="books_coauthor_relation"] .edit_co_author_relation { + /*margin-left: -10px;*/ } +[page-name="books_coauthor_relation"] .form_space { + margin-bottom: 10px; + font-size: 18px; + font-family: Arial, sans-serif; } diff --git a/app/assets/stylesheets/personal_honor/desktop/personal_honor.scss b/app/assets/stylesheets/personal_honor/desktop/personal_honor.scss new file mode 100644 index 0000000..3d54ee3 --- /dev/null +++ b/app/assets/stylesheets/personal_honor/desktop/personal_honor.scss @@ -0,0 +1,123 @@ +@import "desktop-helper"; + +/* Books */ +[page-name="honor_list"] { + .list_t_item .inner { padding-left: 30px; } + .list_item_action { + font-size: 12px; + float: left; + margin-left: -30px; + + a { + display: block; + width: 20px; + height: 20px; + line-height: 20px; + margin: 1px 1px 6px 1px; + } + .icon-star-empty { color: #999; font-size: 20px; } + .icon-star { color: #faa732; font-size: 20px; } + .icon-check-empty { color: #999; font-size: 20px; } + .icon-check { color: #333; font-size: 20px; } + } + + .file_view { + .list_t_des { + overflow: hidden; + } + .file { + float: left; + width: 120px; + height: 50px; + padding: 6px; + margin: 1px; + position: relative; + @include box-sizing; + + &:hover { + background-color: lighten($gray, 10%); + } + img { + width: 38px; + height: 38px; + position: absolute; + left: 6px; + top: 6px; + } + .filetitle { + display: block; + width: 100%; + height: 38px; + padding-left: 40px; + overflow: hidden; + @include box-sizing; + } + } + } +} + +/* Books Books list */ +[page-name="books_books"] { + + .datalist_item .inner { + padding-left: 30px; + } + .list_item_action { + font-size: 12px; + float: left; + margin-left: -30px; + } + .list_item_action i { + color: #999; + font-size: 20px; + display: block; + width: 20px; + height: 20px; + line-height: 20px; + margin: 1px 1px 6px 1px; + } + .list_t_desc { + font-family: Arial, sans-serif; + font-size: 12px; + color: #999; + } +} + +/* Books Co-Author */ +[page-name="books_coauthor"] { + .list_t_item { + height: 110px; + } + .list_item_function {} + .list_item_function a { + display: inline-block; + padding: 4px; + font-family: Arial, sans-serif; + font-size: 11px; + -webkit-text-size-adjust: none; + } + .info { + font-family: Arial, sans-serif; + } + .info li { + margin-bottom: 8px; + color: #999; + } + .info .name { + font-size: 18px; + line-height: 24px; + color: #333; + } +} + +/* Books Co-Author Relationship*/ +[page-name="books_coauthor_relation"]{ + .edit_co_author_relation { + /*margin-left: -10px;*/ + } + .form_space { + margin-bottom: 10px; + font-size: 18px; + font-family: Arial, sans-serif; + } +} \ No newline at end of file diff --git a/app/controllers/.gitkeep b/app/controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..307a4ac --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,23 @@ +class ApplicationController < ActionController::Base + protect_from_forgery + before_filter :set_locale + + # Set I18n.locale + def set_locale + # update session if passed + session[:locale] = params[:locale] if params[:locale] + + # set locale based on session or default + begin + # check if locale is valid for non site pages + if !VALID_LOCALES.include?(session[:locale]) + I18n.locale = I18n.default_locale + else + I18n.locale = session[:locale] + end + rescue + I18n.locale = I18n.default_locale + end + end + +end diff --git a/app/controllers/panel/personal_honor/back_end/honor_categorys_controller.rb b/app/controllers/panel/personal_honor/back_end/honor_categorys_controller.rb new file mode 100644 index 0000000..6ae0919 --- /dev/null +++ b/app/controllers/panel/personal_honor/back_end/honor_categorys_controller.rb @@ -0,0 +1,121 @@ +class Panel::PersonalHonor::BackEnd::HonorCategorysController < OrbitBackendController + include OrbitControllerLib::DivisionForDisable + + open_for_manager :except => [:index] + + def index + + @honor_categorys = get_categories_for_index("HonorCategory") + @honor_category = HonorCategory.new(:display => 'List') + + @url = panel_personal_honor_back_end_honor_categorys_path + + respond_to do |format| + format.html # index.html.erb + format.js + end + end + + # GET /honors/1 + # GET /honors/1.xml + def show + + @honor_category = HonorCategory.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.js + end + end + + # GET /honors/new + # GET /honors/new.xml + def new + + @honor_category = HonorCategory.new(:display => 'List') + + @verb = :post + + respond_to do |format| + format.html # new.html.erb + format.js + end + end + + # GET /honors/1/edit + def edit + + @honor_category = HonorCategory.find(params[:id]) + + # @url = panel_personal_honor_back_end_honor_category_path(@honor_category) + # @url = eval("panel_personal_honor_back_end_#{@app_type}_path(@honor_category)") + @url = polymorphic_path([:panel, :personal_honor, :back_end, @honor_category]) + + @verb = :put + + respond_to do |format| + format.html + format.js + end + end + + # POST /honors + # POST /honors.xml + def create + + @honor_category = HonorCategory.new(params[:honor_category]) + + respond_to do |format| + if @honor_category.save + format.html { redirect_to(panel_personal_honor_back_end_honor_categorys_url, :notice => t('honor_category.create_honor_category_success')) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /honors/1 + # PUT /honors/1.xml + def update + + @honor_category = HonorCategory.find(params[:id]) + # debugger + # @url = panel_personal_honor_back_end_honor_category_path(@honor_category) + # @url = eval("panel_personal_honor_back_end_#{@app_type}_path(#{@honor_category})") + @url = polymorphic_path([:panel, :personal_honor, :back_end, @honor_category]) + + respond_to do |format| + if @honor_category.update_attributes(params[:honor_category]) + format.html { redirect_to(panel_personal_honor_back_end_honor_categorys_url, :notice => t('honor_category.update_honor_category_success')) } + # format.xml { head :ok } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + + # DELETE /honors/1 + # DELETE /honors/1.xml + def destroy + + @honor_category = HonorCategory.find(params[:id]) + @honor_category.disable = @honor_category.disable ? false : true + + if @honor_category.save! + respond_to do |format| + format.html { redirect_to(panel_personal_honor_back_end_honor_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("honor_category.update_failed") + format.html { render :action => "index" } + end + + end + +end diff --git a/app/controllers/panel/personal_honor/back_end/honors_controller.rb b/app/controllers/panel/personal_honor/back_end/honors_controller.rb new file mode 100644 index 0000000..0257082 --- /dev/null +++ b/app/controllers/panel/personal_honor/back_end/honors_controller.rb @@ -0,0 +1,265 @@ +class Panel::PersonalHonor::BackEnd::HonorsController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + + before_filter :only => [ :new,:edit,:update] do |controller| + controller.get_categorys('HonorCategory') + end + + def index + get_plugins + + # @tags = get_tags + # @categories = get_categories_for_index + # @statuses = get_statuses + # category_ids = @categories.collect{|t| t.id} + @honor_category_ids = HonorCategory.all.collect{|t| t.id.to_s} + [nil] + + @honors = get_sorted_and_filtered("honor", :honor_category_id.in => @honor_category_ids) + respond_to do |format| + format.html # index.html.erb + format.js { } + format.xml { render :xml => @honors } + end + end + + def honor_setting + + get_plugins + + @honor_types = HonorCategory.all + + @tags = get_tags + + @set_honor_type = HonorCategory.new(:display => 'List') + @honor_type_url = panel_personal_honor_back_end_honors_path + + + end + + def honor_category_quick_add + @set_honor_type = HonorCategory.new(:display => 'List') + @honor_type_url = panel_personal_honor_back_end_honors_path + @set_honor_type.id = params[:id] + + respond_to do |format| + format.js + end + + end + + def honor_category_quick_edit + + @set_honor_type = HonorCategory.find(params[:honor_id]) + @honor_type_url = panel_personal_honor_back_end_honor_path(@set_honor_type) + + respond_to do |format| + format.js + end + end + + # GET /honors/1 + # GET /honors/1.xml + def show + @honor = Honor.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @honor } + end + end + + # GET /honors/new + # GET /honors/new.xml + def new + + get_plugins + + @honor = Honor.new + @honor_categorys = HonorCategory.all + + @tags = get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @honor } + end + end + + # GET /honors/1/edit + def edit + + get_plugins + + @honor = Honor.find(params[:id]) + + @honor_types = HonorCategory.all + + @tags = get_tags + end + + # POST /honors + # POST /honors.xml + def create + + if params[:honor_category] + + @honor_category = HonorCategory.new(params[:honor_category]) + + respond_to do |format| + if @honor_category.save + format.js { render 'create_honor_setting' } + end + end + + else + + @honor_types = HonorCategory.all + @tags = get_tags + + @honor = Honor.new(params[:honor]) + + @honor.create_user_id = current_user.id + @honor.update_user_id = current_user.id + + if params[:honor][:user_id] + @honor.create_user_id = params[:honor][:user_id] + @honor.update_user_id = params[:honor][:user_id] + else + @honor.create_user_id = current_user.id + @honor.update_user_id = current_user.id + end + + respond_to do |format| + if @honor.save + + if params[:honor][:user_id] + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:honor][:user_id],:show_plugin_profile=>"Honor")) } + else + format.html { redirect_to(panel_personal_honor_back_end_honors_url) } + end + + format.xml { render :xml => @honor, :status => :created, :location => @honor } + else + format.html { render :action => "new" } + format.xml { render :xml => @honor.errors, :status => :unprocessable_entity } + end + end + end + + end + + # PUT /honors/1 + # PUT /honors/1.xml + def update + + if params[:honor_category] + + @honor_category = HonorCategory.find(params[:id]) + + respond_to do |format| + + if @honor_category.update_attributes(params[:honor_category]) + # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js { render 'update_honor_setting' } + end + end + + else + + @honor = Honor.find(params[:id]) + + @honor.update_user_id = current_user.id + + params[:honor][:tag_ids] ||=[] + + respond_to do |format| + if @honor.update_attributes(params[:honor]) + format.html { redirect_to(panel_personal_honor_back_end_honors_url) } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @honor.errors, :status => :unprocessable_entity } + end + end + end + + end + + # DELETE /honors/1 + # DELETE /honors/1.xml + def destroy + @honor = Honor.find(params[:id]) + @honor.destroy + + respond_to do |format| + format.html { redirect_to(panel_personal_honor_back_end_honors_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + honors = Honor.any_in(:_id => params[:ids]).destroy_all + end + redirect_to panel_personal_honor_back_end_honors_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + def data_share + + if params[:ids] + + @honors = Honor.any_in(:_id => params[:ids]) + + @honors.each do |honor| + + honor.is_hidden = params[:disable] + + honor.save + end + + end + + respond_to do |format| + + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:user_id],:show_plugin_profile=>"Honor")) } + format.json { render json: {"success"=>true}.to_json} + end + + end + + protected + + + # def get_index_categories(id = nil) + # @bulletin_categorys = [] + # if(is_manager? || is_admin?) + # @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all) + # elsif is_sub_manager? + # @bulletin_categorys = BulletinCategory.all + # end + # @bulletin_categorys + # end + + + # def get_categorys(id = nil) + # @honor_categorys = [] + # if(is_manager? || is_admin?) + # @honor_categorys = (id ? HonorCategory.admin_manager_all.find(id).to_a : HonorCategory.admin_manager_all)) + # elsif is_sub_manager? + # @honor_categorys = HonorCategory.all.authed_for_user(current_user,'edit') + # end + # if @honor_categorys.empty? && params[:action] != "index" + # flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") + # redirect_to :action => :index + # end + # end + + def get_plugins + @plugins = OrbitApp::Plugin::Registration.all + end + +end diff --git a/app/controllers/panel/personal_honor/back_end/personal_honor_intros_controller.rb b/app/controllers/panel/personal_honor/back_end/personal_honor_intros_controller.rb new file mode 100644 index 0000000..f89e92f --- /dev/null +++ b/app/controllers/panel/personal_honor/back_end/personal_honor_intros_controller.rb @@ -0,0 +1,10 @@ +class Panel::PersonalHonor::BackEnd::PersonalHonorIntrosController < Admin::PersonalPluginIntrosController + + def initialize + super + @app_type = 'personal_honor_intro' + @app_type_name = 'personal_honor' + @reback_name = 'Honor' + end + +end diff --git a/app/controllers/panel/personal_honor/desktop/personal_honors_controller.rb b/app/controllers/panel/personal_honor/desktop/personal_honors_controller.rb new file mode 100644 index 0000000..14e2e9c --- /dev/null +++ b/app/controllers/panel/personal_honor/desktop/personal_honors_controller.rb @@ -0,0 +1,71 @@ +class Panel::PersonalHonor::Desktop::PersonalHonorsController < ApplicationController + + def index + @honors = Honor.where(create_user_id: current_user.id) + @view_by = params[:view] + page = params[:page] + page ||= 1 + + @per_column = 5 + + case @view_by + when "abstract" + @per_column = 1 + when "file" + @per_column = 2 + end + + if @view_by.nil? + @view_by = " " + @honors = @honors.asc(:paper_title) + else + @honors = @honors.asc(@view_by).asc(:paper_title) + end + @honors = @honors.page(page).per(50) + respond_to do |format| + format.html { render :layout => false} + end + end + + def new + @honor = Honor.new + render :layout => false + end + + def create + params[:honor][:create_user_id] = current_user.id + @honor = Honor.new(params[:honor]) + if @honor.save + render json: {success: true, msg: t('create_success')}.to_json + else + error_msg = @honor.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def edit + @honor = Honor.find(params[:id]) + render :layout => false + end + + def update + params[:honor][:create_user_id] = current_user.id + @honor = Honor.find(params[:id]) + if @honor.update_attributes(params[:honor]) + render json: {success: true, msg: t('create_success')}.to_json + else + error_msg = @honor.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def destroy + @honor = Honor.find(params[:id]) + @honor.destroy + render :json => {success: true, msg: t('delete_success')} + end + + def honors_window + render :layout => false + end +end \ No newline at end of file diff --git a/app/controllers/panel/personal_honor/desktop/plugin_intros_controller.rb b/app/controllers/panel/personal_honor/desktop/plugin_intros_controller.rb new file mode 100644 index 0000000..5ac33cb --- /dev/null +++ b/app/controllers/panel/personal_honor/desktop/plugin_intros_controller.rb @@ -0,0 +1,32 @@ +class Panel::PersonalHonor::Desktop::PluginIntrosController < ApplicationController + + def index + @intro = PersonalHonorIntro.where(:user_id => current_user.id.to_s).first + if @intro.blank? + @intro = PersonalHonorIntro.new + render "new", :layout => false + else + render "edit", :layout => false + end + end + + def create + @intro = PersonalHonorIntro.new(params[:personal_honor_intro]) + @intro.user_id = current_user.id + if @intro.save + render :json => {"success" => true}.to_json + else + render :json => {"success" => false}.to_json + end + end + + def update + @intro = PersonalHonorIntro.find(params[:id]) + if @intro.update_attributes(params[:personal_honor_intro]) + render :json => {"success" => true}.to_json + else + render :json => {"success" => false}.to_json + end + end + +end \ No newline at end of file diff --git a/app/controllers/panel/personal_honor/front_end/honors_controller.rb b/app/controllers/panel/personal_honor/front_end/honors_controller.rb new file mode 100644 index 0000000..b2e4835 --- /dev/null +++ b/app/controllers/panel/personal_honor/front_end/honors_controller.rb @@ -0,0 +1,23 @@ +class Panel::PersonalHonor::FrontEnd::HonorsController < OrbitWidgetController + + def initialize + super + @app_title = 'personal_honor' + end + + + def index + + @honors = Honor.where(:is_hidden => false).desc(:year).page(params[:page]).per(10) + + end + + # GET /honors/1 + # GET /honors/1.xml + def show + @honor = Honor.find(params[:id]) + + end + + +end diff --git a/app/controllers/panel/personal_honor/plugin/honors_controller.rb b/app/controllers/panel/personal_honor/plugin/honors_controller.rb new file mode 100644 index 0000000..662109d --- /dev/null +++ b/app/controllers/panel/personal_honor/plugin/honors_controller.rb @@ -0,0 +1,233 @@ +class Panel::PersonalHonor::Plugin::HonorsController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + before_filter :only => [ :new,:edit,:update] do |controller| + controller.get_categorys('HonorCategory') + end + + def index + + get_categorys("HonorCategory",params[:honor_category_ids]) + @filter = params[:filter] + new_filter = params[:new_filter] + + if @filter && params[:clear] + @filter.delete(params[:type]) + elsif @filter && new_filter + if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s) + @filter[new_filter[:type]].delete(new_filter[:id].to_s) + elsif @filter.has_key?(new_filter[:type]) + @filter[new_filter[:type]] << new_filter[:id].to_s + else + @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]}) + end + elsif new_filter + @filter = {new_filter[:type] => [new_filter[:id].to_s]} + end + + @honor_categorys = get_categories_for_index("HonorCategory") + @honor_category_ids = @honor_categorys.collect{|t| t.id.to_s} + [nil] + + @honors = (params[:sort] || @filter) ? get_sorted_and_filtered("honor",:create_user_id => current_user.id) : get_viewable("honor", :create_user_id => current_user.id) + + @tags = get_tags + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @honors } + format.js + end + end + + def honor_setting + + @honor_types = HonorCategory.all + + @tags = get_tags + + @set_honor_type = HonorCategory.new(:display => 'List') + @honor_type_url = panel_personal_honor_plugin_honors_path + + + end + + def honor_category_quick_add + @set_honor_type = HonorCategory.new(:display => 'List') + @honor_type_url = panel_personal_honor_plugin_honors_path + @set_honor_type.id = params[:id] + + respond_to do |format| + format.js + end + + end + + def honor_category_quick_edit + + @set_honor_type = HonorCategory.find(params[:honor_id]) + @honor_type_url = panel_personal_honor_plugin_honor_path(@set_honor_type) + + respond_to do |format| + format.js + end + end + + # GET /honors/1 + # GET /honors/1.xml + def show + @honor = Honor.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @honor } + end + end + + # GET /honors/new + # GET /honors/new.xml + def new + + @honor = Honor.new + @honor_categorys = HonorCategory.all + + @tags = get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @honor } + end + end + + # GET /honors/1/edit + def edit + @honor = Honor.find(params[:id]) + + @honor_types = HonorCategory.all + + @tags = get_tags + end + + # POST /honors + # POST /honors.xml + def create + + if params[:honor_category] + + @honor_category = HonorCategory.new(params[:honor_category]) + + respond_to do |format| + if @honor_category.save + format.js { render 'create_honor_setting' } + end + end + + else + + @honor_types = HonorCategory.all + @tags = get_tags + + @honor = Honor.new(params[:honor]) + + @honor.create_user_id = current_user.id + @honor.update_user_id = current_user.id + + respond_to do |format| + if @honor.save + format.html { redirect_to(panel_personal_honor_plugin_honors_url) } + format.xml { render :xml => @honor, :status => :created, :location => @honor } + else + format.html { render :action => "new" } + format.xml { render :xml => @honor.errors, :status => :unprocessable_entity } + end + end + end + + end + + # PUT /honors/1 + # PUT /honors/1.xml + def update + + if params[:honor_category] + + @honor_category = HonorCategory.find(params[:id]) + + respond_to do |format| + + if @honor_category.update_attributes(params[:honor_category]) + # format.html { redirect_to(panel_announcement_plugin_bulletins_url) } + format.js { render 'update_honor_setting' } + end + end + + else + + @honor = Honor.find(params[:id]) + + @honor.update_user_id = current_user.id + + params[:honor][:tag_ids] ||=[] + + respond_to do |format| + if @honor.update_attributes(params[:honor]) + format.html { redirect_to(panel_personal_honor_plugin_honors_url) } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @honor.errors, :status => :unprocessable_entity } + end + end + end + + end + + # DELETE /honors/1 + # DELETE /honors/1.xml + def destroy + @honor = Honor.find(params[:id]) + @honor.destroy + + respond_to do |format| + format.html { redirect_to(panel_personal_honor_plugin_honors_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + honors = Honor.any_in(:_id => params[:ids]).destroy_all + end + redirect_to panel_personal_honor_plugin_honors_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + protected + + + # def get_index_categories(id = nil) + # @bulletin_categorys = [] + # if(is_manager? || is_admin?) + # @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all) + # elsif is_sub_manager? + # @bulletin_categorys = BulletinCategory.all + # end + # @bulletin_categorys + # end + + + # def get_categorys(id = nil) + # @honor_categorys = [] + # if(is_manager? || is_admin?) + # @honor_categorys = (id ? HonorCategory.admin_manager_all.find(id).to_a : HonorCategory.admin_manager_all)) + # elsif is_sub_manager? + # @honor_categorys = HonorCategory.all.authed_for_user(current_user,'edit') + # end + # if @honor_categorys.empty? && params[:action] != "index" + # flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") + # redirect_to :action => :index + # end + # end + +end diff --git a/app/helpers/.gitkeep b/app/helpers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/panel/personal_honor/desktop/personal_honors_helper.rb b/app/helpers/panel/personal_honor/desktop/personal_honors_helper.rb new file mode 100644 index 0000000..6505de7 --- /dev/null +++ b/app/helpers/panel/personal_honor/desktop/personal_honors_helper.rb @@ -0,0 +1,96 @@ +module Panel::PersonalHonor::Desktop::PersonalHonorsHelper + def publication_record publication, view + content_tag :li, + "item" => "true", + "data-id" => publication.id.to_s, + :class => "list_t_item #{view.blank? ? '' : "#{view}_view" } #{publication.is_hidden? ? "private" : "public" }" do + content_tag :div, + :class => "inner" do + marker(publication.id) + \ + content(publication, view) + \ + edit_or_delete(publication) + end + end + end + + def marker id + content_tag :div, + :class => "list_item_action" do + content_tag(:a, "",:href=>"", + :class => "icon-check-empty", + "toggle-onclick"=>"icon-check-empty icon-check", + "data-id" => id.to_s, + "ajax-remote"=>"false") + \ + content_tag(:a, "",:href=>"", + :class => "icon-star-empty", + "toggle-onclick"=>"icon-star-empty icon-star", + "data-id" => id.to_s, + "ajax-remote"=>"false") + end + end + + def content publication, view + case view + when "award_name" + des = content_tag(:div, publication.award_name, + :class => "list_t_des") + when "keywords" + des = content_tag(:div, publication.keywords, + :class => "list_t_des") + end + + content_tag(:div, publication.award_name, + :class => "list_t_title") + des + + end + + def edit_or_delete publication + content_tag :div, + :class => "list_item_function" do + content_tag(:a, t("edit"), + :class => "journal_paper_edit admbg2 admtxt", + :href => edit_panel_personal_honor_desktop_personal_honor_path(publication), + "callback-method" => "edithonor", + "ajax-remote" => "get") + \ + content_tag(:a, t(:delete_), + "ajax-remote" => "delete", + "confirm-message" => t("sure?"), + "callback-method" => "honorDelete", + :class => "journal_paper_delete admbg2 admtxt", + :href => panel_personal_honor_desktop_personal_honor_path(publication)) + end + end + + def link_publication_file publication + publication.writing_book_files.map{|file| + link_to(image_tag(check_file_type(file.file.url)) + \ + content_tag(:span, (file.title_translations[I18n.locale.to_s] rescue nil), :class => "filetitle"), + file.file.url, + :class => "file", + "target" => "_blank", + "title" => (file.title_translations[I18n.locale.to_s] rescue nil)) + }.inject(:+) + end + + def check_file_type file + if not file.nil? + file_type = MIME::Types.type_for(file).first.to_s.split("/")[1] + file_type = "/assets/ft-icons/#{file_type}/#{file_type}-48_32.png" + else + file_type = "" + end + end + + def generate_authors_name ids + author_name = ids.map{|m| + if m == "0" + #{:id => 0, :text => current_user.name, :email => current_user.email } + {:id => 0, :text => current_user.name } + else + #{:id => m, :text => ConferenceCoAuthor.find(m).co_author, :email => ConferenceCoAuthor.find(m).email} + {:id => m, :text => ConferenceCoAuthor.find(m).co_author} + end + } + author_name.to_json + end +end diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.gitkeep b/app/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/honor.rb b/app/models/honor.rb new file mode 100644 index 0000000..fede2c5 --- /dev/null +++ b/app/models/honor.rb @@ -0,0 +1,73 @@ +# encoding: utf-8 + +class Honor + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes + + include OrbitModel::LanguageRestrict + include OrbitModel::Status + include OrbitTag::Taggable + + LANGUAGE_TYPES = [ "English", "Chinese" ] + + + + # has_and_belongs_to_many :tags, :class_name => "PersonalHonorTag" + + belongs_to :honor_category + + field :year + field :award_name + field :awarding_unit + field :language + field :keywords + field :url + field :note + field :create_user_id, :type => BSON::ObjectId + field :update_user_id, :type => BSON::ObjectId + + paginates_per 10 + + # before_save :clean_checkboxs + + validates_presence_of :award_name + + before_validation :add_http + + validates :url, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i, :unless => Proc.new{self.url.blank?} + + def self.search( category_id = nil ) + + if category_id.to_s.size > 0 + + find(:all, :conditions => {honor_category_id: category_id}).desc( :is_top, :title ) + + else + + find(:all).desc( :is_top, :title) + + end + + end + + + def self.widget_datas + + where( :is_hidden => false ).desc(:is_top, :created_at) + + end + + protected + + def add_http + unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//] + self.url = 'http://' + self.url + end + end + + def clean_checkboxs + self.tagged_ids.delete('') + end + +end \ No newline at end of file diff --git a/app/models/honor_category.rb b/app/models/honor_category.rb new file mode 100644 index 0000000..c5a4453 --- /dev/null +++ b/app/models/honor_category.rb @@ -0,0 +1,24 @@ +# encoding: utf-8 + +class HonorCategory + include Mongoid::Document + include Mongoid::Timestamps + include OrbitCoreLib::ObjectAuthable + include OrbitCoreLib::ObjectDisable + # include Mongoid::MultiParameterAttributes + AfterObjectAuthUrl = '/panel/personal_honor/back_end/honor_categorys' + APP_NAME = 'honor' + # ObjectAuthTitlesOptions = %W{edit} + ObjectAuthTitlesOptions = %W{submit_new fact_check} + + field :key + + field :title, localize: true + + has_many :honors + + def pp_object + title + end + +end \ No newline at end of file diff --git a/app/models/personal_honor_intro.rb b/app/models/personal_honor_intro.rb new file mode 100644 index 0000000..967427f --- /dev/null +++ b/app/models/personal_honor_intro.rb @@ -0,0 +1,4 @@ +class PersonalHonorIntro < PersonalPluginIntro + + +end diff --git a/app/views/.gitkeep b/app/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/panel/personal_honor/back_end/honors/_filter.html.erb b/app/views/panel/personal_honor/back_end/honors/_filter.html.erb new file mode 100644 index 0000000..ad02d4d --- /dev/null +++ b/app/views/panel/personal_honor/back_end/honors/_filter.html.erb @@ -0,0 +1,9 @@ +
+
+ <%= render 'sort_headers' %> +
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "sort_header" %> +<% end %> \ No newline at end of file diff --git a/app/views/panel/personal_honor/back_end/honors/_form.html.erb b/app/views/panel/personal_honor/back_end/honors/_form.html.erb new file mode 100644 index 0000000..f6d21b4 --- /dev/null +++ b/app/views/panel/personal_honor/back_end/honors/_form.html.erb @@ -0,0 +1,163 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + <%= f.error_messages %> + + +
+ + + + + + +
+ + +
+ + <% if !params[:user_id].blank? %> + +
+ +
+ <%= User.from_id(params[:user_id]).name rescue ''%> +
+
+ + <% end %> + + +
+ +
+ <%= select_year((@honor.year ? @honor.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'honor[year]', :class => "span1"} ) %> +
+
+ + +
+ +
+ <%= f.select :honor_category_id, @honor_categorys.collect {|t| [ t.title, t.id ]} %> +
+
+ + +
+ +
+ <%= f.text_field :award_name %> +
+
+ + +
+ +
+ <%= f.text_field :awarding_unit %> +
+
+ + +
+ +
+ <%= f.text_field :url , :class => "span6" %> +
+
+ + +
+ +
+ <%= f.text_field :keywords %> +
+
+ + +
+ +
+ <%= f.radio_button :language, "Chinese" %> <%= t("personal_honor.Chinese") %> + <%= f.radio_button :language, "English" %> <%= t("personal_honor.English") %> +
+
+ + +
+ +
+ <%= f.text_area :note, rows: 2, class: "input-block-level" %> +
+
+ +
+ + + <% if show_form_status_field(@honor) %> +
+ + +
+ +
+ +
+
+ +
+ <% end %> + + +
+ + +
+ +
+ <% @tags.each do |tag| %> + + <% end %> +
+
+ +
+ +
+ +
+ + +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
\ No newline at end of file diff --git a/app/views/panel/personal_honor/back_end/honors/_honor.html.erb b/app/views/panel/personal_honor/back_end/honors/_honor.html.erb new file mode 100644 index 0000000..d03c498 --- /dev/null +++ b/app/views/panel/personal_honor/back_end/honors/_honor.html.erb @@ -0,0 +1,17 @@ + + <%= honor.year %> + + <%= link_to honor.award_name, panel_personal_honor_front_end_honor_path(honor) %> +
+ +
+ + <%= honor.awarding_unit %> + <%= User.from_id(honor.create_user_id).name rescue ''%> + + diff --git a/app/views/panel/personal_honor/back_end/honors/_honor_type_qe.html.erb b/app/views/panel/personal_honor/back_end/honors/_honor_type_qe.html.erb new file mode 100644 index 0000000..de86537 --- /dev/null +++ b/app/views/panel/personal_honor/back_end/honors/_honor_type_qe.html.erb @@ -0,0 +1,34 @@ +<% # encoding: utf-8 %> + +<%= form_for(@set_honor_type, :remote => true, :url => @honor_type_url ) do |f| %> + + +