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..b63cf62 --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +source "http://rubygems.org" + +# Declare your gem's dependencies in personal_conference.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..d918a8f --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += PersonalSeminar + +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..ea0eb18 --- /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 = 'PersonalConference' + 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_conference/.gitkeep b/app/assets/images/personal_conference/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/personal_conference.js b/app/assets/javascripts/personal_conference.js new file mode 100644 index 0000000..20daf27 --- /dev/null +++ b/app/assets/javascripts/personal_conference.js @@ -0,0 +1 @@ +//= require_tree ./personal_conference/desktop diff --git a/app/assets/javascripts/personal_conference/.gitkeep b/app/assets/javascripts/personal_conference/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/personal_conference/desktop/.gitkeep b/app/assets/javascripts/personal_conference/desktop/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/personal_conference/desktop/conference_pages.js b/app/assets/javascripts/personal_conference/desktop/conference_pages.js new file mode 100644 index 0000000..613a9dd --- /dev/null +++ b/app/assets/javascripts/personal_conference/desktop/conference_pages.js @@ -0,0 +1,155 @@ +orbitDesktop.prototype.initializeConferencePapers = function(target,url,cache){ // this init conference papers + this.initializeConferencePapers.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.initializeConferencePapers.list = function(){ // to open list part in conference papers page + var conferenceData; + var bindHandlers = function(){ // to bind handlers for list page + + } + bindHandlers(); + + var bindSecondaryHandlers = function(){ + $("#conference_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.initializeConferencePapers.paperDelete = function(data,dom){ + var parent = dom.parent().parent().parent(); + if(data.success){ + parent.hide("slide",function(){parent.remove();}); + o.notify(data.msg,"success"); + } + } + + this.initializeConferencePapers.cancelpaper = 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.initializeConferencePapers.editpaper = function(){ + o.highlight_sub_menu_item(1); + uploadFiles(); + languageSelect(); + } + + this.initializeConferencePapers.addpaper = function(){ // to open add pages in journal papers page + uploadFiles(); + languageSelect(); + } + this.initializeConferencePapers.brief = function(){ + o.enablelanguageSelect(); + $("textarea.editor").ckeditor({ + height: 300, + width: $(".overview").width() - 20 + }); + } + + this.initializeConferencePapers.conference = function(){ // to open add pages in conference papers page + var bindHandlers = function(){ // to bind handlers for add page + + } + bindHandlers(); + } + + this.initializeConferencePapers.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.initializeConferencePapers.coauthor = function(){ // to open add pages in coauthor page + var bindHandlers = function(){ // to bind handlers for add page + + } + bindHandlers(); + } + this.initializeConferencePapers.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.initializeConferencePapers.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.initializeConferencePapers.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.initializeConferencePapers.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_conference/.gitkeep b/app/assets/stylesheets/personal_conference/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/personal_conference/desktop/personal_conference.css b/app/assets/stylesheets/personal_conference/desktop/personal_conference.css new file mode 100644 index 0000000..7ecd9d3 --- /dev/null +++ b/app/assets/stylesheets/personal_conference/desktop/personal_conference.css @@ -0,0 +1,109 @@ +/* Conference Papers */ +[page-name="conference_p_list"] .list_t_item .inner { + padding-left: 30px; } +[page-name="conference_p_list"] .list_item_action { + font-size: 12px; + float: left; + margin-left: -30px; } + [page-name="conference_p_list"] .list_item_action a { + display: block; + width: 20px; + height: 20px; + line-height: 20px; + margin: 1px 1px 6px 1px; + font-size: 20px; } + [page-name="conference_p_list"] .list_item_action .icon-star-empty, [page-name="conference_p_list"] .list_item_action .icon-check-empty { + color: #dddddd; + -webkit-transition: color 0.3s ease; + -moz-transition: color 0.3s ease; + transition: color 0.3s ease; } + [page-name="conference_p_list"] .list_item_action .icon-star-empty:hover, [page-name="conference_p_list"] .list_item_action .icon-check-empty:hover { + color: #aaaaaa; } + [page-name="conference_p_list"] .list_item_action .icon-star { + color: #faa732; } + [page-name="conference_p_list"] .list_item_action .icon-check { + color: #333; } +[page-name="conference_p_list"] .file_view .list_t_des { + overflow: hidden; } +[page-name="conference_p_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="conference_p_list"] .file_view .file:hover { + background-color: #f7f7f7; } + [page-name="conference_p_list"] .file_view .file img { + width: 38px; + height: 38px; + position: absolute; + left: 6px; + top: 6px; } + [page-name="conference_p_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 */ } + +/* Conference Conference list */ +[page-name="conference_p_conference"] .datalist_item .inner { + padding-left: 30px; } +[page-name="conference_p_conference"] .list_item_action { + font-size: 12px; + float: left; + margin-left: -30px; } +[page-name="conference_p_conference"] .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="conference_p_conference"] .list_t_desc { + font-family: Arial, sans-serif; + font-size: 12px; + color: #999; } + +/* Conference Co-Author */ +[page-name="conference_p_coauthor"] .list_t_item { + height: 110px; } +[page-name="conference_p_coauthor"] .info { + font-family: Arial, sans-serif; } +[page-name="conference_p_coauthor"] .info li { + margin-bottom: 8px; + color: #999; } +[page-name="conference_p_coauthor"] .info .name { + font-size: 18px; + line-height: 24px; + color: #333; } + +/* Conference Co-Author Relationship*/ +[page-name="conference_p_coauthor_relation"] .edit_co_author_relation { + /*margin-left: -10px;*/ } +[page-name="conference_p_coauthor_relation"] .form_space { + margin-bottom: 10px; + font-size: 18px; + font-family: Arial, sans-serif; } diff --git a/app/assets/stylesheets/personal_conference/desktop/personal_conference.scss b/app/assets/stylesheets/personal_conference/desktop/personal_conference.scss new file mode 100644 index 0000000..3fcc2d3 --- /dev/null +++ b/app/assets/stylesheets/personal_conference/desktop/personal_conference.scss @@ -0,0 +1,124 @@ +@import "desktop-helper"; + +/* Conference Papers */ +[page-name="conference_p_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; + font-size: 20px; + } + .icon-star-empty, .icon-check-empty { + color: $gray; + @include transition-type(color,0.3); + + &:hover { + color: darken($gray, 20%); + } + } + .icon-star { color: #faa732; } + .icon-check { color: #333; } + } + + .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; + } + } + } +} + +/* Conference Conference list */ +[page-name="conference_p_conference"] { + + .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; + } +} + +/* Conference Co-Author */ +[page-name="conference_p_coauthor"] { + .list_t_item { + height: 110px; + } + .list_item_function {} + .list_item_function a {} + .info { + font-family: Arial, sans-serif; + } + .info li { + margin-bottom: 8px; + color: #999; + } + .info .name { + font-size: 18px; + line-height: 24px; + color: #333; + } +} + +/* Conference Co-Author Relationship*/ +[page-name="conference_p_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_conference/back_end/conference_author_types_controller.rb b/app/controllers/panel/personal_conference/back_end/conference_author_types_controller.rb new file mode 100644 index 0000000..8fc2290 --- /dev/null +++ b/app/controllers/panel/personal_conference/back_end/conference_author_types_controller.rb @@ -0,0 +1,8 @@ +class Panel::PersonalConference::BackEnd::ConferenceAuthorTypesController < Panel::PersonalConference::BackEnd::WritingConferenceCategorysController + + def initialize + super + @app_type = 'conference_author_type' + end + +end diff --git a/app/controllers/panel/personal_conference/back_end/conference_paper_types_controller.rb b/app/controllers/panel/personal_conference/back_end/conference_paper_types_controller.rb new file mode 100644 index 0000000..c251c25 --- /dev/null +++ b/app/controllers/panel/personal_conference/back_end/conference_paper_types_controller.rb @@ -0,0 +1,8 @@ +class Panel::PersonalConference::BackEnd::ConferencePaperTypesController < Panel::PersonalConference::BackEnd::WritingConferenceCategorysController + + def initialize + super + @app_type = 'conference_paper_type' + end + +end diff --git a/app/controllers/panel/personal_conference/back_end/personal_conference_intros_controller.rb b/app/controllers/panel/personal_conference/back_end/personal_conference_intros_controller.rb new file mode 100644 index 0000000..bb7b75e --- /dev/null +++ b/app/controllers/panel/personal_conference/back_end/personal_conference_intros_controller.rb @@ -0,0 +1,10 @@ +class Panel::PersonalConference::BackEnd::PersonalConferenceIntrosController < Admin::PersonalPluginIntrosController + + def initialize + super + @app_type = 'personal_conference_intro' + @app_type_name = 'personal_conference' + @reback_name = 'WritingConference' + end + +end diff --git a/app/controllers/panel/personal_conference/back_end/writing_conference_categorys_controller.rb b/app/controllers/panel/personal_conference/back_end/writing_conference_categorys_controller.rb new file mode 100644 index 0000000..f8fdbfe --- /dev/null +++ b/app/controllers/panel/personal_conference/back_end/writing_conference_categorys_controller.rb @@ -0,0 +1,143 @@ +class Panel::PersonalConference::BackEnd::WritingConferenceCategorysController < OrbitBackendController + + include OrbitControllerLib::DivisionForDisable + + open_for_manager :except => [:index] + + def index + + get_types + + @writing_conference_categorys = @types.all + @writing_conference_category = @types.new(:display => 'List') + + # @url = panel_personal_conference_back_end_writing_conference_categorys_path + @url = eval("panel_personal_conference_back_end_#{@app_type}s_path") + + respond_to do |format| + format.html # index.html.erb + format.js + end + end + + # GET /writing_conferences/1 + # GET /writing_conferences/1.xml + def show + + get_types + + @writing_conference_category = @types.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.js + end + end + + # GET /writing_conferences/new + # GET /writing_conferences/new.xml + def new + + get_types + + @writing_conference_category = @types.new(:display => 'List') + + @verb = :post + + respond_to do |format| + format.html # new.html.erb + format.js + end + end + + # GET /writing_conferences/1/edit + def edit + + get_types + + @writing_conference_category = @types.find(params[:id]) + + # @url = panel_personal_conference_back_end_writing_conference_category_path(@writing_conference_category) + # @url = eval("panel_personal_conference_back_end_#{@app_type}_path(@writing_conference_category)") + @url = polymorphic_path([:panel, :personal_conference, :back_end, @writing_conference_category]) + + @verb = :put + + respond_to do |format| + format.html + format.js + end + end + + # POST /writing_conferences + # POST /writing_conferences.xml + def create + + get_types + + @writing_conference_category = @types.new(params[:writing_conference_category]) + + respond_to do |format| + if @writing_conference_category.save + format.html { redirect_to(panel_personal_conference_back_end_writing_conference_categorys_url, :notice => t('writing_conference_category.create_writing_conference_category_success')) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /writing_conferences/1 + # PUT /writing_conferences/1.xml + def update + + get_types + + @writing_conference_category = @types.find(params[:id]) + # debugger + # @url = panel_personal_conference_back_end_writing_conference_category_path(@writing_conference_category) + # @url = eval("panel_personal_conference_back_end_#{@app_type}_path(#{@writing_conference_category})") + @url = polymorphic_path([:panel, :personal_conference, :back_end, @writing_conference_category]) + + respond_to do |format| + if @writing_conference_category.update_attributes(params[:writing_conference_category]) + format.html { redirect_to(panel_personal_conference_back_end_writing_conference_categorys_url, :notice => t('writing_conference_category.update_writing_conference_category_success')) } + # format.xml { head :ok } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + + # DELETE /writing_conferences/1 + # DELETE /writing_conferences/1.xml + def destroy + + get_types + + @writing_conference_category = @types.find(params[:id]) + @writing_conference_category.disable = @writing_conference_category.disable ? false : true + + if @writing_conference_category.save! + respond_to do |format| + format.html { redirect_to(panel_personal_conference_back_end_writing_conference_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("writing_conference_category.update_failed") + format.html { render :action => "index" } + end + + end + + protected + + def get_types + @types = @app_type.classify.constantize + end + +end diff --git a/app/controllers/panel/personal_conference/back_end/writing_conferences_controller.rb b/app/controllers/panel/personal_conference/back_end/writing_conferences_controller.rb new file mode 100644 index 0000000..0ef42ba --- /dev/null +++ b/app/controllers/panel/personal_conference/back_end/writing_conferences_controller.rb @@ -0,0 +1,317 @@ +class Panel::PersonalConference::BackEnd::WritingConferencesController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + + before_filter :only => [ :new,:edit,:update] do |controller| + controller.get_categorys('WritingConferenceCategory') + end + + def index + get_plugins + + # @tags = get_tags + # @categories = get_categories_for_index + # @statuses = get_statuses + # category_ids = @categories.collect{|t| t.id} + @paper_type_ids = ConferencePaperType.all.collect{|t| t.id.to_s} + [nil] + + @writing_conferences = get_sorted_and_filtered("writing_conference", :conference_paper_type_id.in => @paper_type_ids) + respond_to do |format| + format.html # index.html.erb + format.js { } + format.xml { render :xml => @writing_conferences } + end + end + + def writing_conference_setting + + get_plugins + + @author_types = ConferenceAuthorType.all + @paper_types = ConferencePaperType.all + + @tags = get_tags + + @set_author_type = ConferenceAuthorType.new(:display => 'List') + @author_type_url = panel_personal_conference_back_end_writing_conferences_path + + @set_paper_type = ConferencePaperType.new(:display => 'List') + @paper_type_url = panel_personal_conference_back_end_writing_conferences_path + + + end + + def paper_type_quick_add + @set_paper_type = ConferencePaperType.new(:display => 'List') + @paper_type_url = panel_personal_conference_back_end_writing_conferences_path + @set_paper_type.id = params[:id] + + respond_to do |format| + format.js + end + + end + + def paper_type_quick_edit + + @set_paper_type = ConferencePaperType.find(params[:writing_conference_id]) + @paper_type_url = panel_personal_conference_back_end_writing_conference_path(@set_paper_type) + + respond_to do |format| + format.js + end + end + + def author_type_quick_add + @set_author_type = ConferenceAuthorType.new(:display => 'List') + @author_type_url = panel_personal_conference_back_end_writing_conferences_path + @set_author_type.id = params[:id] + + respond_to do |format| + format.js + end + + end + + def author_type_quick_edit + + @set_author_type = ConferenceAuthorType.find(params[:writing_conference_id]) + @author_type_url = panel_personal_conference_back_end_writing_conference_path(@set_author_type) + + respond_to do |format| + format.js + end + end + + # GET /writing_conferences/1 + # GET /writing_conferences/1.xml + def show + @writing_conference = WritingConference.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @writing_conference } + end + end + + # GET /writing_conferences/new + # GET /writing_conferences/new.xml + def new + + get_plugins + + @writing_conference = WritingConference.new + # @writing_conference_files = WritingConferenceFile.all + # @paper_types = ConferenceLevelType.all + @author_types = ConferenceAuthorType.all + @paper_types = ConferencePaperType.all + @tags = get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @writing_conference } + end + end + + # GET /writing_conferences/1/edit + def edit + + get_plugins + + @writing_conference = WritingConference.find(params[:id]) + + # @paper_types = ConferenceLevelType.all + @author_types = ConferenceAuthorType.all + @paper_types = ConferencePaperType.all + + @tags = get_tags + end + + # POST /writing_conferences + # POST /writing_conferences.xml + def create + + if params[:conference_paper_type] + + @conference_paper_type = ConferencePaperType.new(params[:conference_paper_type]) + + respond_to do |format| + if @conference_paper_type.save + format.js { render 'create_writing_conference_setting' } + end + end + + elsif params[:conference_author_type] + + @conference_author_type = ConferenceAuthorType.new(params[:conference_author_type]) + + respond_to do |format| + if @conference_author_type.save + format.js { render 'create_writing_conference_setting' } + end + end + + else + + # @paper_types = ConferenceLevelType.all + @author_types = ConferenceAuthorType.all + @paper_types = ConferencePaperType.all + @tags = get_tags + + @writing_conference = WritingConference.new(params[:writing_conference]) + + if params[:writing_conference][:user_id] + @writing_conference.create_user_id = params[:writing_conference][:user_id] + @writing_conference.update_user_id = params[:writing_conference][:user_id] + else + @writing_conference.create_user_id = current_user.id + @writing_conference.update_user_id = current_user.id + end + + respond_to do |format| + if @writing_conference.save + + if params[:writing_conference][:user_id] + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:writing_conference][:user_id],:show_plugin_profile=>'WritingConference')) } + else + format.html { redirect_to(panel_personal_conference_back_end_writing_conferences_url) } + end + + format.xml { render :xml => @writing_conference, :status => :created, :location => @writing_conference } + else + format.html { render :action => "new" } + format.xml { render :xml => @writing_conference.errors, :status => :unprocessable_entity } + end + end + end + + end + + # PUT /writing_conferences/1 + # PUT /writing_conferences/1.xml + def update + + if params[:conference_paper_type] + + @conference_paper_type = ConferencePaperType.find(params[:id]) + + respond_to do |format| + + if @conference_paper_type.update_attributes(params[:conference_paper_type]) + # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js { render 'update_writing_conference_setting' } + end + end + + elsif params[:conference_author_type] + + @conference_author_type = ConferenceAuthorType.find(params[:id]) + + respond_to do |format| + + if @conference_author_type.update_attributes(params[:conference_author_type]) + # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js { render 'update_writing_conference_setting' } + end + end + + else + + @writing_conference = WritingConference.find(params[:id]) + + @writing_conference.update_user_id = current_user.id + + params[:writing_conference][:tag_ids] ||=[] + + respond_to do |format| + if @writing_conference.update_attributes(params[:writing_conference]) + format.html { redirect_to(panel_personal_conference_back_end_writing_conferences_url) } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @writing_conference.errors, :status => :unprocessable_entity } + end + end + + end + + end + + # DELETE /writing_conferences/1 + # DELETE /writing_conferences/1.xml + def destroy + @writing_conference = WritingConference.find(params[:id]) + @writing_conference.destroy + + respond_to do |format| + format.html { redirect_to(panel_personal_conference_back_end_writing_conferences_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + writing_conferences = WritingConference.any_in(:_id => params[:ids]).destroy_all + end + redirect_to panel_personal_conference_back_end_writing_conferences_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + def data_share + + if params[:ids] + + @writing_conferences = WritingConference.any_in(:_id => params[:ids]) + + @writing_conferences.each do |writing_conference| + + writing_conference.is_hidden = params[:disable] + + writing_conference.save + end + + end + + respond_to do |format| + + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:user_id],:show_plugin_profile=>"WritingConference")) } + 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) + # @writing_conference_categorys = [] + # if(is_manager? || is_admin?) + # @writing_conference_categorys = (id ? WritingConferenceCategory.admin_manager_all.find(id).to_a : WritingConferenceCategory.admin_manager_all)) + # elsif is_sub_manager? + # @writing_conference_categorys = WritingConferenceCategory.all.authed_for_user(current_user,'edit') + # end + # if @writing_conference_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_conference/desktop/conference_co_author_relations_controller.rb b/app/controllers/panel/personal_conference/desktop/conference_co_author_relations_controller.rb new file mode 100644 index 0000000..696cc49 --- /dev/null +++ b/app/controllers/panel/personal_conference/desktop/conference_co_author_relations_controller.rb @@ -0,0 +1,67 @@ +class Panel::PersonalConference::Desktop::ConferenceCoAuthorRelationsController < ApplicationController + def index + page = params[:page] + page ||= 1 + @conference_co_author_relations = ConferenceCoAuthorRelation.all + new + + @conference_co_author_relations = @conference_co_author_relations.page(page).per(50) + respond_to do |format| + format.html {render layout: false } + end + end + + def edit + @conference_co_author_relation = ConferenceCoAuthorRelation.find(params[:id]) + respond_to do |format| + format.html { render :layout => false} + end + end + + def new + @conference_co_author_relation = ConferenceCoAuthorRelation.new + end + + def create + @conference_co_author_relation = ConferenceCoAuthorRelation.new(params[:conference_co_author_relation]) + @conference_co_author_relations = ConferenceCoAuthorRelation.all + + if @conference_co_author_relation.save + newv = render_to_string partial: "show_form", object: @conference_co_author_relations + render json: {success: true, msg: t('create_success') , newvalue: newv}.to_json + else + error_msg = @conference_co_author_relation.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def update + @conference_co_author_relation = ConferenceCoAuthorRelation.find(params[:id]) + if @conference_co_author_relation.update_attributes(params[:conference_co_author_relation]) + @conference_co_author_relations = ConferenceCoAuthorRelation.all + newv = render_to_string partial: "show_form", object: @conference_co_author_relations + newv = '
' + newv + '
' + render json: {success: true, msg: t('update_success'), newvalue: newv}.to_json + else + error_msg = @conference_co_author.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def destroy + @conference_co_author_relation = ConferenceCoAuthorRelation.find(params[:id]) + @conference_co_author_relation.destroy + reset_co_author_relation + + render :json => {success: true, msg: t("delete_success")} + end + + private + + def reset_co_author_relation + co_author = ConferenceCoAuthor.where(conference_co_author_relations_id: @conference_co_author_relation.id) + co_author.map do |c| + c.update_attributes(conference_co_author_relations_id: nil) + end + end +end diff --git a/app/controllers/panel/personal_conference/desktop/conference_co_authors_controller.rb b/app/controllers/panel/personal_conference/desktop/conference_co_authors_controller.rb new file mode 100644 index 0000000..7248798 --- /dev/null +++ b/app/controllers/panel/personal_conference/desktop/conference_co_authors_controller.rb @@ -0,0 +1,61 @@ +class Panel::PersonalConference::Desktop::ConferenceCoAuthorsController < ApplicationController + def index + page = params[:page] + page ||= 1 + @conference_co_authors = ConferenceCoAuthor.where(name_id: current_user.id).asc(:co_author) + @conference_co_author_relations = ConferenceCoAuthorRelation.all + + @conference_co_authors = @conference_co_authors.page(page).per(40) + + respond_to do |format| + format.html { render :layout => false} + end + end + + def new + @conference_co_author = ConferenceCoAuthor.new + @conference_co_author_relations = ConferenceCoAuthorRelation.all + + respond_to do |format| + format.html { render :layout => false} + end + end + + def edit + @conference_co_author = ConferenceCoAuthor.find(params[:id]) + @conference_co_author_relations = ConferenceCoAuthorRelation.all + respond_to do |format| + format.html { render :layout => false} + end + end + + def create + @conference_co_author = ConferenceCoAuthor.new(params[:conference_co_author]) + @conference_co_author.name_id= current_user.id + + if @conference_co_author.save + render json: {success:true, msg: t('create_success')}.to_json + else + error_msg = @conference_co_author.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def update + @conference_co_author = ConferenceCoAuthor.find(params[:id]) + + if @conference_co_author.update_attributes(params[:conference_co_author]) + render json: {success:true, msg: t('update_success')}.to_json + else + error_msg = @conference_co_author.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def destroy + @conference_co_author = ConferenceCoAuthor.find(params[:id]) + @conference_co_author.destroy + + render :json => {success: true, msg: "delete_success"} + end +end diff --git a/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb b/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb new file mode 100644 index 0000000..7f3603a --- /dev/null +++ b/app/controllers/panel/personal_conference/desktop/conference_pages_controller.rb @@ -0,0 +1,114 @@ +class Panel::PersonalConference::Desktop::ConferencePagesController < ApplicationController + def index + @view_by = params[:view] + @writing_conferences = WritingConference.where(create_user_id: current_user.id) + page = params[:page] + page ||= 1 + + if @view_by.nil? + @writing_conferences = @writing_conferences.asc(:paper_title) + else + @writing_conferences = @writing_conferences.asc(@view_by).asc(:paper_title) + end + + @level_types = ConferencePaperType.all + + @writing_conferences = @writing_conferences.page(page).per(50) + + respond_to do |format| + format.html { render :layout => false} + end + end + + def show + end + + def new + @writing_conference = WritingConference.new + @paper_types = ConferencePaperType.all + @author_types = ConferenceAuthorType.all + + @conference_candidate = + WritingConference.where(create_user_id: current_user.id).map{|j|j.conference_title}.uniq + + if (not params[:q].nil?) and (current_user.name.include?params[:q]) + @user = [{ :id => 0, :text => current_user.name, :email => current_user.email}] # self account name + else + @user = [] + end + + @co_authors = ConferenceCoAuthor.where(name_id: current_user.id, :co_author => /#{params[:q]}/).asc(:co_author) + # search string + self account name + match pattern + @co_authors = [{ :id => params[:q], :text => params[:q], :email => "#{t("add")} #{t("author")}" }] + + @user + + @co_authors.map{|m| { :id => m.id, :text => m.co_author, :email => m.email } } + + respond_to do |format| + format.html { render :layout => false} + format.json { render :json => {:results => @co_authors}.to_json } + end + end + + def edit + @writing_conference = WritingConference.find(params[:id]) + @paper_types = ConferencePaperType.all + @author_types = ConferenceAuthorType.all + respond_to do |format| + format.html { render :layout => false} + end + end + + def create + params[:writing_conference][:create_user_id] = current_user.id + @writing_conference = WritingConference.new(params[:writing_conference]) + + if @writing_conference.save + render json: {success: true, msg: t('create_success')}.to_json + else + error_msg = @writing_conference.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def update + params[:writing_conference][:update_user_id] = current_user.id + @writing_conference= WritingConference.find(params[:id]) + + if @writing_conference.update_attributes(params[:writing_conference]) + render json: {success: true, msg: t('update_success')}.to_json + else + error_msg = @writing_conference.errors.full_messages.join("
") + render json: {success: false, msg: error_msg}.to_json + end + end + + def destroy + @writing_conference = WritingConference.find(params[:id]) + @writing_conference.destroy + render :json => {success: true, msg: t('delete_success')} + end + + def conference_type + page = params[:page] + page ||= 1 + + conference_types = ConferencePaperType.all + all_conference_lists = WritingConference.where(create_user_id: current_user.id) + all_conference_lists = all_conference_lists.asc(:conference_title) + all_conference_lists = all_conference_lists.page(page).per(50) + all_conference_lists = all_conference_lists.map do |j| + [ j.conference_title, + j.conference_paper_type_ids.map do |type| + conference_types.find(type).title + end + ] + end + + @conference_lists = all_conference_lists + + respond_to do |format| + format.html { render :layout => false} + end + end +end + diff --git a/app/controllers/panel/personal_conference/desktop/conference_windows_controller.rb b/app/controllers/panel/personal_conference/desktop/conference_windows_controller.rb new file mode 100644 index 0000000..216448c --- /dev/null +++ b/app/controllers/panel/personal_conference/desktop/conference_windows_controller.rb @@ -0,0 +1,5 @@ +class Panel::PersonalConference::Desktop::ConferenceWindowsController < ApplicationController + def conference_window + render panel_personal_conference_desktop_conference_window_path, :layout => false + end +end diff --git a/app/controllers/panel/personal_conference/desktop/plugin_intros_controller.rb b/app/controllers/panel/personal_conference/desktop/plugin_intros_controller.rb new file mode 100644 index 0000000..e8c105c --- /dev/null +++ b/app/controllers/panel/personal_conference/desktop/plugin_intros_controller.rb @@ -0,0 +1,32 @@ +class Panel::PersonalConference::Desktop::PluginIntrosController < ApplicationController + + def index + @intro = PersonalConferenceIntro.where(:user_id => current_user.id.to_s).first + if @intro.blank? + @intro = PersonalConferenceIntro.new + render "new", :layout => false + else + render "edit", :layout => false + end + end + + def create + @intro = PersonalConferenceIntro.new(params[:personal_conference_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 = PersonalConferenceIntro.find(params[:id]) + if @intro.update_attributes(params[:personal_conference_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_conference/front_end/writing_conferences_controller.rb b/app/controllers/panel/personal_conference/front_end/writing_conferences_controller.rb new file mode 100644 index 0000000..3e8350c --- /dev/null +++ b/app/controllers/panel/personal_conference/front_end/writing_conferences_controller.rb @@ -0,0 +1,26 @@ +class Panel::PersonalConference::FrontEnd::WritingConferencesController < OrbitWidgetController + + def initialize + super + @app_title = 'personal_conference' + end + + + def index + + @writing_conferences = WritingConference.where(:is_hidden => false).desc(:year,:period_start_date).page(params[:page]).per(10) + + end + + # GET /writing_conferences/1 + # GET /writing_conferences/1.xml + def show + @writing_conference = WritingConference.find(params[:id]) + + @conference_paper_types = ( !@writing_conference.conference_paper_types.blank? ? @writing_conference.conference_paper_types.collect{|x| x.title}.join(', ') : nil) + @conference_author_types = ( !@writing_conference.conference_author_types.blank? ? @writing_conference.conference_author_types.collect{|x| x.title}.join(', ') : nil) + + end + + +end diff --git a/app/controllers/panel/personal_conference/plugin/writing_conferences_controller.rb b/app/controllers/panel/personal_conference/plugin/writing_conferences_controller.rb new file mode 100644 index 0000000..5bb6443 --- /dev/null +++ b/app/controllers/panel/personal_conference/plugin/writing_conferences_controller.rb @@ -0,0 +1,180 @@ +class Panel::PersonalConference::Plugin::WritingConferencesController < OrbitBackendController + include AdminHelper + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + + before_filter :only => [ :new,:edit,:update] do |controller| + controller.get_categorys('WritingConferenceCategory') + end + + + def index + + get_categorys("ConferencePaperType",params[:conference_paper_type_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 + @paper_types = ConferencePaperType.all + @paper_type_ids = @paper_types.collect{|t| t.id.to_s} + [nil] + + + # @writing_conferences = WritingConference.search(params[:category_id]) + #@writing_conferences = (params[:sort] || @filter) ? get_sorted_and_filtered_writing_conferences : WritingConference.all.page(params[:page]).per(10) + @writing_conferences = (params[:sort] || @filter) ? get_sorted_and_filtered("writing_conference",:create_user_id => current_user.id) : get_viewable("writing_conference", :create_user_id => current_user.id) + + @tags = get_tags + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @writing_conferences } + format.js + end + end + + # GET /writing_conferences/1 + # GET /writing_conferences/1.xml + def show + @writing_conference = WritingConference.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @writing_conference } + end + end + + # GET /writing_conferences/new + # GET /writing_conferences/new.xml + def new + + @writing_conference = WritingConference.new + # @writing_conference_files = WritingConferenceFile.all + # @level_types = ConferenceLevelType.all + @author_types = ConferenceAuthorType.all + @paper_types = ConferencePaperType.all + + @tags = get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @writing_conference } + end + end + + # GET /writing_conferences/1/edit + def edit + @writing_conference = WritingConference.find(params[:id]) + + # @level_types = ConferenceLevelType.all + @author_types = ConferenceAuthorType.all + @paper_types = ConferencePaperType.all + + @tags = get_tags + end + + # POST /writing_conferences + # POST /writing_conferences.xml + def create + + # @level_types = ConferenceLevelType.all + @author_types = ConferenceAuthorType.all + @paper_types = ConferencePaperType.all + @tags = get_tags + + @writing_conference = WritingConference.new(params[:writing_conference]) + + @writing_conference.create_user_id = current_user.id + @writing_conference.update_user_id = current_user.id + + respond_to do |format| + if @writing_conference.save + format.html { redirect_to(panel_personal_conference_plugin_writing_conferences_url) } + format.xml { render :xml => @writing_conference, :status => :created, :location => @writing_conference } + else + format.html { render :action => "new" } + format.xml { render :xml => @writing_conference.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /writing_conferences/1 + # PUT /writing_conferences/1.xml + def update + @writing_conference = WritingConference.find(params[:id]) + + @writing_conference.update_user_id = current_user.id + + params[:writing_conference][:tag_ids] ||=[] + + respond_to do |format| + if @writing_conference.update_attributes(params[:writing_conference]) + format.html { redirect_to(panel_personal_conference_plugin_writing_conferences_url) } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @writing_conference.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /writing_conferences/1 + # DELETE /writing_conferences/1.xml + def destroy + @writing_conference = WritingConference.find(params[:id]) + @writing_conference.destroy + + respond_to do |format| + format.html { redirect_to(panel_personal_conference_plugin_writing_conferences_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + writing_conferences = WritingConference.any_in(:_id => params[:ids]).destroy_all + end + redirect_to panel_personal_conference_plugin_writing_conferences_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_conference_categorys = [] + # if(is_manager? || is_admin?) + # @writing_conference_categorys = (id ? WritingConferenceCategory.admin_manager_all.find(id).to_a : WritingConferenceCategory.admin_manager_all)) + # elsif is_sub_manager? + # @writing_conference_categorys = WritingConferenceCategory.all.authed_for_user(current_user,'edit') + # end + # if @writing_conference_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/.gitkeep b/app/helpers/panel/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/panel/personal_conference/.gitkeep b/app/helpers/panel/personal_conference/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/panel/personal_conference/desktop/.gitkeep b/app/helpers/panel/personal_conference/desktop/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb b/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb new file mode 100644 index 0000000..c1afa89 --- /dev/null +++ b/app/helpers/panel/personal_conference/desktop/conference_pages_helper.rb @@ -0,0 +1,103 @@ +module Panel::PersonalConference::Desktop::ConferencePagesHelper + 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 "conference_title" + des = content_tag(:div, publication.conference_title, + :class => "list_t_des") + when "keywords" + des = content_tag(:div, publication.keywords, + :class => "list_t_des") + when "abstract" + des = content_tag(:div, publication.abstract, + :class => "list_t_des") + when "file" + des = content_tag(:div, link_publication_file(publication), + :class => "list_t_des") + else + end + + content_tag(:div, publication.paper_title, + :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_conference_desktop_conference_page_path(publication), + "callback-method" => "editpaper", + "ajax-remote" => "get") + \ + content_tag(:a, t(:delete_), + "ajax-remote" => "delete", + "confirm-message" => t("sure?"), + "callback-method" => "paperDelete", + :class => "journal_paper_delete admbg2 admtxt", + :href => panel_personal_conference_desktop_conference_page_path(publication)) + end + end + + def link_publication_file publication + publication.writing_conference_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/conference_author_type.rb b/app/models/conference_author_type.rb new file mode 100644 index 0000000..1614cdf --- /dev/null +++ b/app/models/conference_author_type.rb @@ -0,0 +1,9 @@ +# encoding: utf-8 + +class ConferenceAuthorType < WritingConferenceCategory + + field :title, localize: true + + has_and_belongs_to_many :writing_conferences + +end diff --git a/app/models/conference_co_author.rb b/app/models/conference_co_author.rb new file mode 100644 index 0000000..1f0db88 --- /dev/null +++ b/app/models/conference_co_author.rb @@ -0,0 +1,21 @@ +class ConferenceCoAuthor + include Mongoid::Document + + LANGUAGE_TYPES = [ "English", "Chinese" ] + + field :name_id, type: BSON::ObjectId # this is author + field :co_author, localize: true + field :email + + belongs_to :conference_co_author_relations + has_and_belongs_to_many :writing_conferences + + VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/ + validates :email, format: { with: VALID_EMAIL_REGEX }, + allow_blank: true, + uniqueness: { case_sensitive: false } + + validates :co_author, presence: true + before_save { |coauthor| coauthor.email = email.downcase if not coauthor.email.nil?} +end + diff --git a/app/models/conference_co_author_relation.rb b/app/models/conference_co_author_relation.rb new file mode 100644 index 0000000..f36e513 --- /dev/null +++ b/app/models/conference_co_author_relation.rb @@ -0,0 +1,11 @@ +class ConferenceCoAuthorRelation + include Mongoid::Document + include Mongoid::Timestamps + + field :relation, localize: true + + has_and_belongs_to_many :conference_co_authors + + validates :relation, presence: true, + uniqueness: { case_sensitive: false } +end diff --git a/app/models/conference_paper_type.rb b/app/models/conference_paper_type.rb new file mode 100644 index 0000000..b0f27e2 --- /dev/null +++ b/app/models/conference_paper_type.rb @@ -0,0 +1,9 @@ +# encoding: utf-8 + +class ConferencePaperType < WritingConferenceCategory + + field :title, localize: true + + has_and_belongs_to_many :writing_conferences + +end diff --git a/app/models/personal_conference_intro.rb b/app/models/personal_conference_intro.rb new file mode 100644 index 0000000..b977dfc --- /dev/null +++ b/app/models/personal_conference_intro.rb @@ -0,0 +1,4 @@ +class PersonalConferenceIntro < PersonalPluginIntro + + +end diff --git a/app/models/writing_conference.rb b/app/models/writing_conference.rb new file mode 100644 index 0000000..8b5ab9e --- /dev/null +++ b/app/models/writing_conference.rb @@ -0,0 +1,118 @@ +class WritingConference + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes + + include OrbitModel::LanguageRestrict + include OrbitModel::Status + include OrbitTag::Taggable + + LANGUAGE_TYPES = [ "English", "Chinese" ] + + field :paper_title, localize: true + field :conference_title, localize: true + field :authors, localize: true + field :location, localize: true + field :sponsor, localize: true + + # has_and_belongs_to_many :tags, :class_name => "PersonalConferenceTag" + has_and_belongs_to_many :conference_author_types + has_and_belongs_to_many :conference_paper_types + has_and_belongs_to_many :conference_co_authors + + field :year + field :language + field :period_start_date, :type => Date + field :period_end_date, :type => Date + field :keywords + field :abstract + field :publication_date, :type => Date + field :url + field :note + field :create_user_id, :type => BSON::ObjectId + field :update_user_id, :type => BSON::ObjectId + + paginates_per 10 + + has_many :writing_conference_files, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :writing_conference_files, :allow_destroy => true + + # before_save :clean_checkboxs + + validates :paper_title, :at_least_one => true + before_validation :add_http + after_save :save_writing_conference_files + 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?} + + attr_reader :author_tokens + + def author_tokens=(ids) + authors_ids = ids.split(",").map{|id| + begin + ConferenceCoAuthor.find(id).id + rescue + if id != "0" + new_co_author = ConferenceCoAuthor.new(:co_author => id) + new_co_author.save + new_co_author.id + else + id + end + end + } + self.conference_co_author_ids = authors_ids + end + + def self.search( category_id = nil ) + if category_id.to_s.size > 0 + find(:all, :conditions => {writing_conference_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 save_writing_conference_files + self.writing_conference_files.each do |t| + if t.should_destroy + t.destroy + end + end + end + + def create_link + title = [] + + title << self.authors if self.authors.present? + + if !self.publication_date.nil? + pd = self.publication_date.strftime("%Y-%m-%d").split('-') + title << pd[0] + end + + title << self.paper_title if self.paper_title.present? + title << self.conference_title if self.conference_title.present? + title << self.location if self.location.present? + title << "#{period_start_date}-#{period_end_date}" if (self.period_start_date.present? && self.period_end_date.present?) + # title << "(#{self.conference_paper_types.collect{|x| x.title}.join(', ')})" + title.join(', ') + 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('') + self.conference_author_type_ids.delete('') + self.conference_level_type_ids.delete('') + end + +end diff --git a/app/models/writing_conference_category.rb b/app/models/writing_conference_category.rb new file mode 100644 index 0000000..435daf8 --- /dev/null +++ b/app/models/writing_conference_category.rb @@ -0,0 +1,30 @@ +# encoding: utf-8 + +class WritingConferenceCategory + include Mongoid::Document + include Mongoid::Timestamps + include OrbitCoreLib::ObjectAuthable + include OrbitCoreLib::ObjectDisable + # include Mongoid::MultiParameterAttributes + AfterObjectAuthUrl = '/panel/personal_conference/back_end/writing_conference_categorys' + APP_NAME = 'writing_conference' + # ObjectAuthTitlesOptions = %W{edit} + ObjectAuthTitlesOptions = %W{submit_new fact_check} + + field :key + + has_many :writing_conferences + + def pp_object + title + end + + def self.from_id(id) + WritingConferenceCategory.find(id) rescue nil + end + + def self.is_localized?(field_name) + self.fields[field_name.to_s].localized? + end + +end diff --git a/app/models/writing_conference_file.rb b/app/models/writing_conference_file.rb new file mode 100644 index 0000000..5fdca8e --- /dev/null +++ b/app/models/writing_conference_file.rb @@ -0,0 +1,14 @@ +class WritingConferenceFile + + 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_conference + +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_conference/back_end/writing_conference_categorys/_form.html.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/_form.html.erb new file mode 100644 index 0000000..7835731 --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/_form.html.erb @@ -0,0 +1,44 @@ +<% # encoding: utf-8 %> + +<%= form_for(:writing_conference_category, :remote => true, :url => @url, :method => @verb, :html => { :id => 'form_writing_conference_category' } ) do |f| %> + +

<%= (@writing_conference_category.new_record? ? 'Add' : 'Edit') %>

+ +
+ <%= f.label :key %> + <%= f.text_field :key %> +
+ +
+ <% if @types.is_localized?(:title) %> + <%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
+ <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
+ <%= f.text_field locale, :class => 'input-xxlarge', :value => (@writing_conference_category.title_translations[locale] rescue nil) %> +
+
+ <% end %> + <% end %> + <% else %> +
+ <%= f.label :title %> + <%= f.text_field :title %> +
+ <% end %> +
+ +
+ <%#= f.label :display %> + <%#= f.radio_button :display, "List" List%> + <%#= f.radio_button :display, "Picture" Picture%> + <%#
顯示方式是設定在前台頁面時,資訊所呈現的樣式 %> +
+ +
+ <%= f.submit t('submit'), :class=>'btn btn-primary' %> +
+ +<% end %> + diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/_quick_edit_qe.html.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/_quick_edit_qe.html.erb new file mode 100644 index 0000000..cc537cb --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/_quick_edit_qe.html.erb @@ -0,0 +1,28 @@ +<% # encoding: utf-8 %> + +
+ +
+ <%= f.label :key %> + <%= f.text_field :key %> +
+
+ <%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
+ <%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
+ <%= f.text_field locale, :class => 'input-xxlarge', :value => (news_bulletin_category.title_translations[locale] rescue nil) %> +
+
+ <% end %> + <% end %> +
+ +
+ <%= f.label :display %> + <%= f.radio_button :display, "List" %>List + <%= f.radio_button :display, "Picture" %>Picture +
顯示方式是設定在前台頁面時,資訊所呈現的樣式 +
+
diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/_writing_conference_category.html.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/_writing_conference_category.html.erb new file mode 100644 index 0000000..24ae0ee --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/_writing_conference_category.html.erb @@ -0,0 +1,22 @@ + + + + <%= writing_conference_category.key %> +
+ +
+ + <% if @types.is_localized?(:title) %> + <% @site_in_use_locales.each do |locale| %> + <%= writing_conference_category.title_translations[locale] rescue nil %> + <% end %> + <% else %> + <%= writing_conference_category.title %> + <% end %> + diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/create.js.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/create.js.erb new file mode 100644 index 0000000..b17a94f --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/create.js.erb @@ -0,0 +1,2 @@ +$('<%= j render :partial => 'writing_conference_category', :collection => [@writing_conference_category] %>').appendTo('#writing_conference_categorys').hide().fadeIn(); +$("#form_writing_conference_category")[0].reset(); diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/destroy.js.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/destroy.js.erb new file mode 100644 index 0000000..27eacba --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/destroy.js.erb @@ -0,0 +1 @@ +$("#<%= dom_id @writing_conference_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@writing_conference_category) %> "); diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/edit.html.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/edit.html.erb new file mode 100644 index 0000000..c7b89db --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/edit.html.erb @@ -0,0 +1,7 @@ +

<%= t('personal_conference.editing_personal_conference_class') %>

+ +<%= form_for @writing_conference_category, :url => panel_personal_conference_back_end_writing_conference_category_path(@writing_conference_category) do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> + +<%= link_back %> diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/edit.js.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/edit.js.erb new file mode 100644 index 0000000..eaff01f --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/edit.js.erb @@ -0,0 +1 @@ +$("#form > form").replaceWith("<%= j render "form" %>"); \ No newline at end of file diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/index.html.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/index.html.erb new file mode 100644 index 0000000..16411a1 --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/index.html.erb @@ -0,0 +1,29 @@ + +<%= flash_messages %> + +<%= @types %> + + + + + + <% if @types.is_localized?(:title) %> + <% @site_in_use_locales.each do |locale| %> + + <% end %> + <% else %> + + <% end %> + + + + + <%= render :partial => 'writing_conference_category', :collection => @writing_conference_categorys %> + + +
<%= t('writing_conference_category.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('writing_conference_category.title') %>
+ +
<%= render :partial => "form" if is_manager? %>
+ + + diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/new.html.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/new.html.erb new file mode 100644 index 0000000..46d1994 --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/new.html.erb @@ -0,0 +1,19 @@ +<% content_for :secondary do %> +<%= render :partial => '/panel/personal_conference/back_end/personal_conference_secondary' %> +<% end -%> + +<%= flash_messages %> + +
+
+
+
+
+ +

<%= t('writing_conference_category.new_personal_conference_class') %>

+<%= form_for @writing_conference_category, :url => panel_personal_conference_back_end_writing_conference_categorys_path do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> + +<%= link_back %> + diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/new.js.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/new.js.erb new file mode 100644 index 0000000..40061b9 --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/new.js.erb @@ -0,0 +1 @@ +$("#form > form").replaceWith("<%= j render "form" %>"); diff --git a/app/views/panel/personal_conference/back_end/writing_conference_categorys/update.js.erb b/app/views/panel/personal_conference/back_end/writing_conference_categorys/update.js.erb new file mode 100644 index 0000000..58c2c0e --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conference_categorys/update.js.erb @@ -0,0 +1,4 @@ +$("#<%= dom_id @writing_conference_category %>").replaceWith("<%= j render :partial => 'writing_conference_category', :collection => [@writing_conference_category] %>"); +<% @writing_conference_category = @types.new(:display => 'List') # reset for new form %> +$("#form_writing_conference_category").replaceWith("<%= j render "form" %>") +$("#form_writing_conference_category")[0].reset(); diff --git a/app/views/panel/personal_conference/back_end/writing_conferences/_author_type_qe.html.erb b/app/views/panel/personal_conference/back_end/writing_conferences/_author_type_qe.html.erb new file mode 100644 index 0000000..76ce37b --- /dev/null +++ b/app/views/panel/personal_conference/back_end/writing_conferences/_author_type_qe.html.erb @@ -0,0 +1,34 @@ +<% # encoding: utf-8 %> + +<%= form_for(@set_author_type, :remote => true, :url => @author_type_url ) do |f| %> + + +