diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/assets/images/personal_patent/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/assets/images/personal_patent/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/assets/javascripts/personal_patent/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/assets/javascripts/personal_patent/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/assets/stylesheets/personal_patent/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/assets/stylesheets/personal_patent/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/application_controller.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/application_controller.rb new file mode 100644 index 00000000..307a4acd --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/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/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/tags_controller.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/tags_controller.rb new file mode 100644 index 00000000..b7479e8c --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/tags_controller.rb @@ -0,0 +1,8 @@ +class Panel::PersonalPatent::BackEnd::TagsController < Admin::TagsController + + def initialize + super + @app_title = 'personal_patent' + end + +end diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patent_categorys_controller.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patent_categorys_controller.rb new file mode 100644 index 00000000..fe7bc853 --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patent_categorys_controller.rb @@ -0,0 +1,119 @@ +class Panel::PersonalPatent::BackEnd::WritingPatentCategorysController < OrbitBackendController + include OrbitControllerLib::DivisionForDisable + + before_filter :force_order_for_visitor,:only=>[:index,:show] + before_filter :force_order_for_user,:except => [:index,:show] + before_filter :for_app_manager,:except => [:index] + + def index + + @writing_patent_categorys = WritingPatentCategory.all + @writing_patent_category = WritingPatentCategory.new(:display => 'List') + + @url = panel_personal_patent_back_end_writing_patent_categorys_path + + respond_to do |format| + format.html # index.html.erb + format.js + end + end + + # GET /projects/1 + # GET /projects/1.xml + def show + + @writing_patent_category = WritingPatentCategory.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.js + end + end + + # GET /projects/new + # GET /projects/new.xml + def new + + @writing_patent_category = WritingPatentCategory.new(:display => 'List') + + @verb = :post + + respond_to do |format| + format.html # new.html.erb + format.js + end + end + + # GET /projects/1/edit + def edit + + @writing_patent_category = WritingPatentCategory.find(params[:id]) + + @url = panel_personal_patent_back_end_writing_patent_category_path(@writing_patent_category) + + @verb = :put + + respond_to do |format| + format.html + format.js + end + end + + # POST /projects + # POST /projects.xml + def create + + @writing_patent_category = WritingPatentCategory.new(params[:writing_patent_category]) + + respond_to do |format| + if @writing_patent_category.save + format.html { redirect_to(panel_personal_patent_back_end_writing_patent_categorys_url, :notice => t('writing_patent_category.create_writing_patent_category_success')) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /projects/1 + # PUT /projects/1.xml + def update + + @writing_patent_category = WritingPatentCategory.find(params[:id]) + # debugger + @url = panel_personal_patent_back_end_writing_patent_category_path(@writing_patent_category) + + respond_to do |format| + if @writing_patent_category.update_attributes(params[:writing_patent_category]) + format.html { redirect_to(panel_personal_patent_back_end_writing_patent_categorys_url, :notice => t('writing_patent_category.update_writing_patent_category_success')) } + # format.xml { head :ok } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + + # DELETE /projects/1 + # DELETE /projects/1.xml + def destroy + + @writing_patent_category = WritingPatentCategory.find(params[:id]) + @writing_patent_category.disable = @writing_patent_category.disable ? false : true + + if @writing_patent_category.save! + respond_to do |format| + format.html { redirect_to(panel_personal_patent_back_end_writing_patent_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("writing_patent_category.update_failed") + format.html { render :action => "index" } + end + + end + +end diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.00.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.00.rb new file mode 100644 index 00000000..d038e1b8 --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.00.rb @@ -0,0 +1,244 @@ +class Panel::PersonalPatent::BackEnd::WritingPatentsController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + before_filter :force_order_for_visitor,:only=>[:index,:show] + before_filter :force_order_for_user,:except => [:index,:show] + # before_filter :for_app_manager,:except => [:index,:show] + before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| + controller.get_categorys('WritingPatentCategory') + end + + def index + + get_categorys("WritingPatentCategory",params[:writing_patent_category_id]) + @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 + + + @writing_patent_categorys = get_categories_for_index("WritingPatentCategory") + @writing_patent_category_ids = @writing_patent_categorys.collect{|t| t.id.to_s} + [nil] + + @writing_patents = (params[:sort] || @filter) ? get_sorted_and_filtered("writing_patent",:writing_patent_category_id.in => @writing_patent_category_ids) : get_viewable("writing_patent",:writing_patent_category_id.in => @writing_patent_category_ids) + + get_tags + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @writing_patents } + format.js + end + end + + def writing_patent_setting + + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + + @set_writing_patent_category = WritingPatentCategory.new(:display => 'List') + @writing_patent_category_url = panel_personal_patent_back_end_writing_patents_path + + + end + + def writing_patent_category_quick_add + @set_writing_patent_category = WritingPatentCategory.new(:display => 'List') + @writing_patent_category_url = panel_personal_patent_back_end_writing_patents_path + @set_writing_patent_category.id = params[:id] + + respond_to do |format| + format.js + end + + end + + def writing_patent_category_quick_edit + + @set_writing_patent_category = WritingPatentCategory.find(params[:writing_patent_id]) + @writing_patent_category_url = panel_personal_patent_back_end_writing_patent_path(@set_writing_patent_category) + + respond_to do |format| + format.js + end + end + + # GET /writing_patents/1 + # GET /writing_patents/1.xml + def show + @writing_patent = WritingPatent.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @writing_patent } + end + end + + # GET /writing_patents/new + # GET /writing_patents/new.xml + def new + + @writing_patent = WritingPatent.new + debugger + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @writing_patent } + end + end + + # GET /writing_patents/1/edit + def edit + @writing_patent = WritingPatent.find(params[:id]) + + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + end + + # POST /writing_patents + # POST /writing_patents.xml + def create + + if params[:writing_patent_category] + + @writing_patent_category = WritingPatentCategory.new(params[:writing_patent_category]) + + respond_to do |format| + if @writing_patent_category.save + format.js { render 'create_writing_patent_setting' } + end + end + + else + + + @writing_patent_categorys = WritingPatentCategory.all + get_tags + + @writing_patent = WritingPatent.new(params[:writing_patent]) + + @writing_patent.create_user_id = current_user.id + @writing_patent.update_user_id = current_user.id + + respond_to do |format| + if @writing_patent.save + format.html { redirect_to(panel_personal_patent_back_end_writing_patents_url) } + format.xml { render :xml => @writing_patent, :status => :created, :location => @writing_patent } + else + format.html { render :action => "new" } + format.xml { render :xml => @writing_patent.errors, :status => :unprocessable_entity } + end + end + end + + end + + # PUT /writing_patents/1 + # PUT /writing_patents/1.xml + def update + + if params[:writing_patent_category] + + @writing_patent_category = WritingPatentCategory.find(params[:id]) + + respond_to do |format| + + if @writing_patent_category.update_attributes(params[:writing_patent_category]) + # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js { render 'update_writing_patent_setting' } + end + end + + else + + @writing_patent = WritingPatent.find(params[:id]) + + @writing_patent.update_user_id = current_user.id + + params[:writing_patent][:tag_ids] ||=[] + + respond_to do |format| + if @writing_patent.update_attributes(params[:writing_patent]) + format.html { redirect_to(panel_personal_patent_back_end_writing_patents_url) } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @writing_patent.errors, :status => :unprocessable_entity } + end + end + end + + end + + # DELETE /writing_patents/1 + # DELETE /writing_patents/1.xml + def destroy + @writing_patent = WritingPatent.find(params[:id]) + @writing_patent.destroy + + respond_to do |format| + format.html { redirect_to(panel_personal_patent_back_end_writing_patents_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + writing_patents = WritingPatent.any_in(:_id => params[:ids]).delete_all + end + redirect_to panel_personal_patent_back_end_writing_patents_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) + # @writing_patent_categorys = [] + # if(is_manager? || is_admin?) + # @writing_patent_categorys = (id ? WritingPatent.admin_manager_all.find(id).to_a : WritingPatent.admin_manager_all)) + # elsif is_sub_manager? + # @writing_patent_categorys = WritingPatent.all.authed_for_user(current_user,'edit') + # end + # if @writing_patent_categorys.empty? && params[:action] != "index" + # flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") + # redirect_to :action => :index + # end + # end + + def get_tags + module_app = ModuleApp.first(:conditions => {:key => 'personal_patent'}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) + end + +end diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.rb new file mode 100644 index 00000000..a0bec01b --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.rb @@ -0,0 +1,244 @@ +class Panel::PersonalPatent::BackEnd::WritingPatentsController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + before_filter :force_order_for_visitor,:only=>[:index,:show] + before_filter :force_order_for_user,:except => [:index,:show] + # before_filter :for_app_manager,:except => [:index,:show] + before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| + controller.get_categorys('WritingPatentCategory') + end + + def index + + get_categorys("WritingPatentCategory",params[:writing_patent_writing_patent_category_id]) + @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 + + + @writing_patent_categorys = get_categories_for_index("WritingPatentCategory") + @writing_patent_category_ids = @writing_patent_categorys.collect{|t| t.id.to_s} + [nil] + + @writing_patents = (params[:sort] || @filter) ? get_sorted_and_filtered("writing_patent",:writing_patent_category_id.in => @writing_patent_category_ids) : get_viewable("writing_patent",:writing_patent_category_id.in => @writing_patent_category_ids) + + get_tags + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @writing_patents } + format.js + end + end + + def writing_patent_setting + + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + + @set_writing_patent_category = WritingPatentCategory.new(:display => 'List') + @writing_patent_category_url = panel_personal_patent_back_end_writing_patents_path + + + end + + def writing_patent_category_quick_add + @set_writing_patent_category = WritingPatentCategory.new(:display => 'List') + @writing_patent_category_url = panel_personal_patent_back_end_writing_patents_path + @set_writing_patent_category.id = params[:id] + + respond_to do |format| + format.js + end + + end + + def writing_patent_category_quick_edit + + @set_writing_patent_category = WritingPatentCategory.find(params[:writing_patent_id]) + @writing_patent_category_url = panel_personal_patent_back_end_writing_patent_path(@set_writing_patent_category) + + respond_to do |format| + format.js + end + end + + # GET /writing_patents/1 + # GET /writing_patents/1.xml + def show + @writing_patent = Project.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @writing_patent } + end + end + + # GET /writing_patents/new + # GET /writing_patents/new.xml + def new + + @writing_patent = Project.new + + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @writing_patent } + end + end + + # GET /writing_patents/1/edit + def edit + @writing_patent = Project.find(params[:id]) + + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + end + + # POST /writing_patents + # POST /writing_patents.xml + def create + + if params[:writing_patent_category] + + @writing_patent_category = WritingPatentCategory.new(params[:writing_patent_category]) + + respond_to do |format| + if @writing_patent_category.save + format.js { render 'create_writing_patent_setting' } + end + end + + else + + + @writing_patent_categorys = WritingPatentCategory.all + get_tags + + @writing_patent = Project.new(params[:writing_patent]) + + @writing_patent.create_user_id = current_user.id + @writing_patent.update_user_id = current_user.id + + respond_to do |format| + if @writing_patent.save + format.html { redirect_to(panel_personal_patent_back_end_writing_patents_url) } + format.xml { render :xml => @writing_patent, :status => :created, :location => @writing_patent } + else + format.html { render :action => "new" } + format.xml { render :xml => @writing_patent.errors, :status => :unprocessable_entity } + end + end + end + + end + + # PUT /writing_patents/1 + # PUT /writing_patents/1.xml + def update + + if params[:writing_patent_category] + + @writing_patent_category = WritingPatentCategory.find(params[:id]) + + respond_to do |format| + + if @writing_patent_category.update_attributes(params[:writing_patent_category]) + # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js { render 'update_writing_patent_setting' } + end + end + + else + + @writing_patent = Project.find(params[:id]) + + @writing_patent.update_user_id = current_user.id + + params[:writing_patent][:tag_ids] ||=[] + + respond_to do |format| + if @writing_patent.update_attributes(params[:writing_patent]) + format.html { redirect_to(panel_personal_patent_back_end_writing_patents_url) } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @writing_patent.errors, :status => :unprocessable_entity } + end + end + end + + end + + # DELETE /writing_patents/1 + # DELETE /writing_patents/1.xml + def destroy + @writing_patent = Project.find(params[:id]) + @writing_patent.destroy + + respond_to do |format| + format.html { redirect_to(panel_personal_patent_back_end_writing_patents_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + writing_patents = Project.any_in(:_id => params[:ids]).delete_all + end + redirect_to panel_personal_patent_back_end_writing_patents_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) + # @writing_patent_categorys = [] + # if(is_manager? || is_admin?) + # @writing_patent_categorys = (id ? Project.admin_manager_all.find(id).to_a : Project.admin_manager_all)) + # elsif is_sub_manager? + # @writing_patent_categorys = Project.all.authed_for_user(current_user,'edit') + # end + # if @writing_patent_categorys.empty? && params[:action] != "index" + # flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") + # redirect_to :action => :index + # end + # end + + def get_tags + module_app = ModuleApp.first(:conditions => {:key => 'personal_patent'}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) + end + +end diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/plugin/writing_patents_controller.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/plugin/writing_patents_controller.rb new file mode 100644 index 00000000..1acab41d --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/plugin/writing_patents_controller.rb @@ -0,0 +1,181 @@ +class Panel::PersonalPatent::Plugin::WritingPatentsController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + before_filter :force_order_for_visitor,:only=>[:index,:show] + before_filter :force_order_for_user,:except => [:index,:show] + # before_filter :for_app_manager,:except => [:index,:show] + before_filter :only => [ :new,:create,:edit,:update,:create] do |controller| + controller.get_categorys('WritingPatentCategory') + end + + def index + + get_categorys("WritingPatentCategory",params[:writing_patent_writing_patent_category_id]) + @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 + + + @writing_patent_categorys = get_categories_for_index("WritingPatentCategory") + @writing_patent_category_ids = @writing_patent_categories.collect{|t| t.id.to_s} + [nil] + + @writing_patents = (params[:sort] || @filter) ? get_sorted_and_filtered("writing_patent",:create_user_id => current_user.id) : get_viewable("writing_patent", :create_user_id => current_user.id) + + get_tags + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @writing_patents } + format.js + end + end + + # GET /writing_patents/1 + # GET /writing_patents/1.xml + def show + @writing_patent = Project.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @writing_patent } + end + end + + # GET /writing_patents/new + # GET /writing_patents/new.xml + def new + + @writing_patent = Project.new + + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @writing_patent } + end + end + + # GET /writing_patents/1/edit + def edit + @writing_patent = Project.find(params[:id]) + + @writing_patent_categorys = WritingPatentCategory.all + + get_tags + end + + # POST /writing_patents + # POST /writing_patents.xml + def create + + @writing_patent_categorys = WritingPatentCategory.all + get_tags + + @writing_patent = Project.new(params[:writing_patent]) + + @writing_patent.create_user_id = current_user.id + @writing_patent.update_user_id = current_user.id + + respond_to do |format| + if @writing_patent.save + format.html { redirect_to(panel_personal_writing_patent_plugin_writing_patents_url) } + format.xml { render :xml => @writing_patent, :status => :created, :location => @writing_patent } + else + format.html { render :action => "new" } + format.xml { render :xml => @writing_patent.errors, :status => :unprocessable_entity } + end + end + end + + + # PUT /writing_patents/1 + # PUT /writing_patents/1.xml + def update + + @writing_patent = Project.find(params[:id]) + + @writing_patent.update_user_id = current_user.id + + params[:writing_patent][:tag_ids] ||=[] + + respond_to do |format| + if @writing_patent.update_attributes(params[:writing_patent]) + format.html { redirect_to(panel_personal_writing_patent_plugin_writing_patents_url) } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @writing_patent.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /writing_patents/1 + # DELETE /writing_patents/1.xml + def destroy + @writing_patent = Project.find(params[:id]) + @writing_patent.destroy + + respond_to do |format| + format.html { redirect_to(panel_personal_writing_patent_plugin_writing_patents_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + writing_patents = Project.any_in(:_id => params[:ids]).delete_all + end + redirect_to panel_personal_writing_patent_plugin_writing_patents_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) + # @writing_patent_categorys = [] + # if(is_manager? || is_admin?) + # @writing_patent_categorys = (id ? Project.admin_manager_all.find(id).to_a : Project.admin_manager_all)) + # elsif is_sub_manager? + # @writing_patent_categorys = Project.all.authed_for_user(current_user,'edit') + # end + # if @writing_patent_categorys.empty? && params[:action] != "index" + # flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") + # redirect_to :action => :index + # end + # end + + def get_tags + module_app = ModuleApp.first(:conditions => {:key => 'personal_patent'}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}) + end + +end diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/helpers/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/helpers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/mailers/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/mailers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/models/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/models/personal_patent_tag.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/personal_patent_tag.rb new file mode 100644 index 00000000..752e62e6 --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/personal_patent_tag.rb @@ -0,0 +1,9 @@ +class PersonalPatentTag < Tag + + has_and_belongs_to_many :writing_patents + + def get_visible_links(sort = :title) + self.writing_patents.where(:is_hidden => false).desc(:is_top, sort) + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent.rb new file mode 100644 index 00000000..75bc5054 --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent.rb @@ -0,0 +1,108 @@ +# encoding: utf-8 + +class WritingPatent + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes + + # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } + + LANGUAGE_TYPES = [ "English", "Chinese" ] + + + field :patent_title, localize: true + field :authors, localize: true + + has_and_belongs_to_many :tags, :class_name => "PersonalPatentTag" + + belongs_to :writing_patent_category + + field :year + field :language + field :keywords + field :patent_no + field :patent_country + field :publish_date , :type => Date + field :url + field :note + field :create_user_id + field :update_user_id + + # field :is_top, :type => Boolean, :default => false + # field :is_hot, :type => Boolean, :default => false + # field :is_hidden, :type => Boolean, :default => false + + has_many :writing_patent_files, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :writing_patent_files, :allow_destroy => true + + # before_save :update_avliable_language, :clean_checkboxs + + validates :writing_patent_title, :at_least_one => true + + before_validation :add_http + + after_save :save_writing_patent_files + + validates :url, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, :unless => Proc.new{self.url.blank?} + + def self.search( category_id = nil ) + + if category_id.to_s.size > 0 + + find(:all, :conditions => {writing_patent_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 + + def is_top? + self.is_top + end + + def sorted_tags + tags.order_by(I18n.locale, :asc) + end + + def update_avliable_language + VALID_LOCALES.each do |locale| + if (title_translations[locale].blank? rescue true) + self["available_for_#{locale}".to_sym] = false + else + self["available_for_#{locale}".to_sym] = true + end + end + end + + def save_writing_patent_files + self.writing_patent_files.each do |t| + if t.should_destroy + t.destroy + end + end + 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.tag_ids.delete('') + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_category.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_category.rb new file mode 100644 index 00000000..e1dfcab0 --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_category.rb @@ -0,0 +1,28 @@ +# encoding: utf-8 + +class WritingPatentCategory + include Mongoid::Document + include Mongoid::Timestamps + include OrbitCoreLib::ObjectAuthable + include OrbitCoreLib::ObjectDisable + # include Mongoid::MultiParameterAttributes + AfterObjectAuthUrl = '/panel/personal_patent/back_end/writing_patent_categorys' + APP_NAME = 'project' + # ObjectAuthTitlesOptions = %W{edit} + ObjectAuthTitlesOptions = %W{submit_new fact_check} + + field :key + + field :title, localize: true + + has_many :writing_patents + + def pp_object + title + end + + def self.from_id(id) + WritingPatentCategory.find(id) rescue nil + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_file.rb b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_file.rb new file mode 100644 index 00000000..df7c5b45 --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_file.rb @@ -0,0 +1,14 @@ +class WritingPatentFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + # field :description, localize: true + field :should_destroy, :type => Boolean + field :title, localize: true + + belongs_to :writing_patent + +end diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/views/.gitkeep b/vendor/built_in_modules/personal_patent/app - %BDƻs/views/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/_form.html.erb b/vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/_form.html.erb new file mode 100644 index 00000000..c3542e8b --- /dev/null +++ b/vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/_form.html.erb @@ -0,0 +1,30 @@ +<% # encoding: utf-8 %> + +<%= form_for(@writing_patent_category, :remote => true, :url => @url) do |f| %> + +
<%= t('writing_patent_category.key') %> | + <% @site_valid_locales.each do |locale| %> +<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> | + <% end %> +
---|
File | +File Name | ++ |
---|---|---|
+
+ <%= hidden_field_tag 'plugin_file_field_count', @writing_patent.writing_patent_files.count %>
+ ADD/新增
+
+ |
+
+ | + | + | + | + |
---|
+ <%= t('add')%> + 專利類別 +
++ + 領域 +
+ +File | +File Name | ++ |
---|---|---|
+
+ <%= hidden_field_tag 'plugin_file_field_count', @writing_patent.writing_patent_files.count %>
+ ADD/新增
+
+ |
+
+ | + | + | + | + |
---|