From 49cef0ab7ab784977c70602444e888433ac904e6 Mon Sep 17 00:00:00 2001 From: manson Date: Tue, 1 Jul 2014 18:19:07 +0800 Subject: [PATCH] Backend finished --- .../conference_author_types_controller.rb | 41 +++ .../conference_paper_levels_controller.rb | 41 +++ .../conference_paper_types_controller.rb | 41 +++ .../admin/writing_conferences_controller.rb | 86 +++++ .../writing_conferences_controller.rb | 6 + app/models/conference_author_type.rb | 11 + app/models/conference_paper_level.rb | 11 + app/models/conference_paper_type.rb | 11 + app/models/writing_conference.rb | 95 +++++ app/models/writing_conference_file.rb | 14 + app/models/writing_conference_intro.rb | 10 + .../conference_author_types/_form.html.erb | 24 ++ .../conference_author_types/_list.js.erb | 2 + .../admin/conference_author_types/edit.js.erb | 1 + .../admin/conference_author_types/new.js.erb | 1 + .../conference_paper_levels/_form.html.erb | 24 ++ .../conference_paper_levels/_index.js.erb | 2 + .../admin/conference_paper_levels/edit.js.erb | 1 + .../admin/conference_paper_levels/new.js.erb | 1 + .../conference_paper_types/_form.html.erb | 24 ++ .../conference_paper_types/_index.js.erb | 2 + .../admin/conference_paper_types/edit.js.erb | 1 + .../admin/conference_paper_types/new.js.erb | 1 + .../admin/writing_conferences/_form.html.erb | 339 ++++++++++++++++++ .../writing_conferences/_form_file.html.erb | 55 +++ .../_list_author_type.html.erb | 8 + .../_list_paper_level.html.erb | 8 + .../_list_paper_type.html.erb | 8 + .../_writing_conference.html.erb | 15 + .../admin/writing_conferences/edit.html.erb | 5 + .../frontend_setting.html.erb | 93 +++++ .../admin/writing_conferences/index.html.erb | 21 ++ .../admin/writing_conferences/new.html.erb | 5 + .../writing_conferences/setting.html.erb | 116 ++++++ .../personal_conference/_profile.html.erb | 86 +++++ config/locales/en.yml | 7 +- config/locales/zh_tw.yml | 11 +- config/routes.rb | 25 ++ lib/personal_conference/engine.rb | 2 +- 39 files changed, 1250 insertions(+), 5 deletions(-) create mode 100644 app/controllers/admin/conference_author_types_controller.rb create mode 100644 app/controllers/admin/conference_paper_levels_controller.rb create mode 100644 app/controllers/admin/conference_paper_types_controller.rb create mode 100644 app/controllers/admin/writing_conferences_controller.rb create mode 100644 app/controllers/writing_conferences_controller.rb create mode 100644 app/models/conference_author_type.rb create mode 100644 app/models/conference_paper_level.rb create mode 100644 app/models/conference_paper_type.rb create mode 100644 app/models/writing_conference.rb create mode 100644 app/models/writing_conference_file.rb create mode 100644 app/models/writing_conference_intro.rb create mode 100644 app/views/admin/conference_author_types/_form.html.erb create mode 100644 app/views/admin/conference_author_types/_list.js.erb create mode 100644 app/views/admin/conference_author_types/edit.js.erb create mode 100644 app/views/admin/conference_author_types/new.js.erb create mode 100644 app/views/admin/conference_paper_levels/_form.html.erb create mode 100644 app/views/admin/conference_paper_levels/_index.js.erb create mode 100644 app/views/admin/conference_paper_levels/edit.js.erb create mode 100644 app/views/admin/conference_paper_levels/new.js.erb create mode 100644 app/views/admin/conference_paper_types/_form.html.erb create mode 100644 app/views/admin/conference_paper_types/_index.js.erb create mode 100644 app/views/admin/conference_paper_types/edit.js.erb create mode 100644 app/views/admin/conference_paper_types/new.js.erb create mode 100644 app/views/admin/writing_conferences/_form.html.erb create mode 100644 app/views/admin/writing_conferences/_form_file.html.erb create mode 100644 app/views/admin/writing_conferences/_list_author_type.html.erb create mode 100644 app/views/admin/writing_conferences/_list_paper_level.html.erb create mode 100644 app/views/admin/writing_conferences/_list_paper_type.html.erb create mode 100644 app/views/admin/writing_conferences/_writing_conference.html.erb create mode 100644 app/views/admin/writing_conferences/edit.html.erb create mode 100644 app/views/admin/writing_conferences/frontend_setting.html.erb create mode 100644 app/views/admin/writing_conferences/index.html.erb create mode 100644 app/views/admin/writing_conferences/new.html.erb create mode 100644 app/views/admin/writing_conferences/setting.html.erb create mode 100644 app/views/plugin/personal_conference/_profile.html.erb diff --git a/app/controllers/admin/conference_author_types_controller.rb b/app/controllers/admin/conference_author_types_controller.rb new file mode 100644 index 0000000..12cd592 --- /dev/null +++ b/app/controllers/admin/conference_author_types_controller.rb @@ -0,0 +1,41 @@ +class Admin::ConferenceAuthorTypesController < OrbitAdminController + def new + @author_type = ConferenceAuthorType.new + @url = admin_conference_author_types_path(@author_type) + render :layout=>false + end + + def create + @author_type = ConferenceAuthorType.new(author_type_params) + @author_type.save + @author_types = ConferenceAuthorType.all + render :partial=>'list', :layout=>false + end + + def edit + @author_type = ConferenceAuthorType.find(params[:id]) + @url = admin_conference_author_type_path(@author_type) + render :layout=>false + end + + def update + @author_type = ConferenceAuthorType.find(params[:id]) + @author_type.update_attributes(author_type_params) + @author_type.save + @author_types = ConferenceAuthorType.all + render :partial=>'list', :layout=>false + end + + def destroy + author_type = ConferenceAuthorType.find(params[:id]) + author_type.destroy + @author_types = ConferenceAuthorType.all + render :partial=>'list', :layout=>false + end + + private + + def author_type_params + params.require(:conference_author_type).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/admin/conference_paper_levels_controller.rb b/app/controllers/admin/conference_paper_levels_controller.rb new file mode 100644 index 0000000..acd4551 --- /dev/null +++ b/app/controllers/admin/conference_paper_levels_controller.rb @@ -0,0 +1,41 @@ +class Admin::ConferencePaperLevelsController < OrbitAdminController + def new + @paper_level = ConferencePaperLevel.new + @url = admin_conference_paper_levels_path(@paper_level) + render :layout=>false + end + + def create + @paper_level = ConferencePaperLevel.new(paper_level_params) + @paper_level.save + @paper_levels = ConferencePaperLevel.all + render :partial=>'index', :layout=>false + end + + def edit + @paper_level = ConferencePaperLevel.find(params[:id]) + @url = admin_conference_paper_level_path(@paper_level) + render :layout=>false + end + + def update + @paper_level = ConferencePaperLevel.find(params[:id]) + @paper_level.update_attributes(paper_level_params) + @paper_level.save + @paper_levels = ConferencePaperLevel.all + render :partial=>'index', :layout=>false + end + + def destroy + paper_level = ConferencePaperLevel.find(params[:id]) + paper_level.destroy + @paper_levels = ConferencePaperLevel.all + render :partial=>'index', :layout=>false + end + + private + + def paper_level_params + params.require(:conference_paper_level).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/admin/conference_paper_types_controller.rb b/app/controllers/admin/conference_paper_types_controller.rb new file mode 100644 index 0000000..0d34e2c --- /dev/null +++ b/app/controllers/admin/conference_paper_types_controller.rb @@ -0,0 +1,41 @@ +class Admin::ConferencePaperTypesController < OrbitAdminController + def new + @paper_type = ConferencePaperType.new + @url = admin_conference_paper_types_path(@paper_type) + render :layout=>false + end + + def create + @paper_type = ConferencePaperType.new(paper_type_params) + @paper_type.save + @paper_types = ConferencePaperType.all + render :partial=>'index', :layout=>false + end + + def edit + @paper_type = ConferencePaperType.find(params[:id]) + @url = admin_conference_paper_type_path(@paper_type) + render :layout=>false + end + + def update + @paper_type = ConferencePaperType.find(params[:id]) + @paper_type.update_attributes(paper_type_params) + @paper_type.save + @paper_types = ConferencePaperType.all + render :partial=>'index', :layout=>false + end + + def destroy + paper_type = ConferencePaperType.find(params[:id]) + paper_type.destroy + @paper_types = ConferencePaperType.all + render :partial=>'index', :layout=>false + end + + private + + def paper_type_params + params.require(:conference_paper_type).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/admin/writing_conferences_controller.rb b/app/controllers/admin/writing_conferences_controller.rb new file mode 100644 index 0000000..0bad96e --- /dev/null +++ b/app/controllers/admin/writing_conferences_controller.rb @@ -0,0 +1,86 @@ +class Admin::WritingConferencesController < OrbitMemberController + layout "member_plugin" + + before_action :set_plugin + before_action :get_settings,:only => [:new, :edit, :setting] + + def index + @writing_conferences = WritingConference.all + end + + def new + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @writing_conference = WritingConference.new + end + + def create + @member = MemberProfile.find(conference_params['member_profile_id']) rescue nil + @writing_conference = WritingConference.new(conference_params) + @writing_conference.save + redirect_to '/admin/members/'+@member.to_param+'/WritingConference' + end + + def edit + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @writing_conference = WritingConference.find(params[:id]) + end + + def update + @member = MemberProfile.find(conference_params['member_profile_id']) rescue nil + @writing_conference = WritingConference.find(params[:id]) + @writing_conference.update_attributes(conference_params) + @writing_conference.save + redirect_to '/admin/members/'+@member.to_param+'/WritingConference' + end + + def toggle_hide + 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 + + render json: {"success"=>true} + end + + def setting + end + + def frontend_setting + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @intro = WritingConferenceIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? WritingConferenceIntro.new({:member_profile_id=>@member.id}) : @intro + end + + def update_frontend_setting + @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil + @intro = WritingConferenceIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? WritingConferenceIntro.new({:member_profile_id=>@member.id}) : @intro + @intro.update_attributes(intro_params) + @intro.save + redirect_to '/admin/members/'+@member.to_param+'/WritingConference' + end + + def get_settings + @paper_types = ConferencePaperType.all + @paper_levels = ConferencePaperLevel.all + @author_types = ConferenceAuthorType.all + end + + def set_plugin + @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'WritingConference'}.first + end + + private + + def conference_params + params.require(:writing_conference).permit! rescue nil + end + + def intro_params + params.require(:writing_conference_intro).permit! rescue nil + end +end \ No newline at end of file diff --git a/app/controllers/writing_conferences_controller.rb b/app/controllers/writing_conferences_controller.rb new file mode 100644 index 0000000..939f5c9 --- /dev/null +++ b/app/controllers/writing_conferences_controller.rb @@ -0,0 +1,6 @@ +class WritingConferencesController + def show + writing_conference = WritingConference.find_by(:uid=>param[:uid]) + + end +end \ No newline at end of file diff --git a/app/models/conference_author_type.rb b/app/models/conference_author_type.rb new file mode 100644 index 0000000..22d5a01 --- /dev/null +++ b/app/models/conference_author_type.rb @@ -0,0 +1,11 @@ +# encoding: utf-8 + +class ConferenceAuthorType + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + has_and_belongs_to_many :writing_conferences + +end diff --git a/app/models/conference_paper_level.rb b/app/models/conference_paper_level.rb new file mode 100644 index 0000000..ed0a0f4 --- /dev/null +++ b/app/models/conference_paper_level.rb @@ -0,0 +1,11 @@ +# encoding: utf-8 + +class ConferencePaperLevel + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + has_and_belongs_to_many :writing_conferences + +end \ No newline at end of file diff --git a/app/models/conference_paper_type.rb b/app/models/conference_paper_type.rb new file mode 100644 index 0000000..6b15634 --- /dev/null +++ b/app/models/conference_paper_type.rb @@ -0,0 +1,11 @@ +# encoding: utf-8 + +class ConferencePaperType + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + has_and_belongs_to_many :writing_conferences + +end diff --git a/app/models/writing_conference.rb b/app/models/writing_conference.rb new file mode 100644 index 0000000..a3ebbf6 --- /dev/null +++ b/app/models/writing_conference.rb @@ -0,0 +1,95 @@ +class WritingConference + include Mongoid::Document + include Mongoid::Timestamps + + include OrbitModel::Status + include OrbitTag::Taggable + include Slug + + field :paper_title, as: :slug_title, localize: true + field :conference_title, localize: true + field :authors, localize: true + field :location, localize: true + field :sponsor, localize: true + + 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 + field :isbn + field :isi_number + + belongs_to :member_profile + + has_and_belongs_to_many :conference_author_types + has_and_belongs_to_many :conference_paper_types + has_and_belongs_to_many :conference_paper_levels + + has_many :writing_conference_files, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :writing_conference_files, :allow_destroy => true + + before_validation :add_http + + 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.join(', ') + end + + def values_for_view + attribute_values = self.attributes.select{|k,v| v if (k.in?( + [ "year", + "language", + "period_start_date", + "period_end_date", + "publication_date", + "keywords", + "abstract", + "url", + "note", + "isbn", + "isi_number"]) && v.present?)} + + localized_fields = { + "paper_title" => self.paper_title, + "conference_title" => self.conference_title, + "location"=>self.location, + "sponsor"=>self.sponsor} + + authors = {"authors" => self.authors} + + files = Hash.new + # self.writing_conference_files.each do |f, index| + # title = f.title.blank? ? File.basename(f.file.path) : f.title + # end + values = [localized_fields, attribute_values, authors,files] + values.inject(&:merge) + end + + protected + + def add_http + unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//] + self.url = 'http://' + self.url + end + end + +end \ No newline at end of file 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/models/writing_conference_intro.rb b/app/models/writing_conference_intro.rb new file mode 100644 index 0000000..4a1bd75 --- /dev/null +++ b/app/models/writing_conference_intro.rb @@ -0,0 +1,10 @@ +class WritingConferenceIntro + include Mongoid::Document + include Mongoid::Timestamps + + belongs_to :member_profile + + field :text, localize: true + field :display_intro, :type => Boolean, :default => true + field :display_conference_list, :type => Boolean, :default => true +end diff --git a/app/views/admin/conference_author_types/_form.html.erb b/app/views/admin/conference_author_types/_form.html.erb new file mode 100644 index 0000000..45905fa --- /dev/null +++ b/app/views/admin/conference_author_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@author_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/conference_author_types/_list.js.erb b/app/views/admin/conference_author_types/_list.js.erb new file mode 100644 index 0000000..1c173db --- /dev/null +++ b/app/views/admin/conference_author_types/_list.js.erb @@ -0,0 +1,2 @@ +$('#author_types tbody').html("<%= j render :partial => '/admin/writing_conferences/list_author_type', :collection => @author_types %>"); +$('#author_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/conference_author_types/edit.js.erb b/app/views/admin/conference_author_types/edit.js.erb new file mode 100644 index 0000000..3ac7380 --- /dev/null +++ b/app/views/admin/conference_author_types/edit.js.erb @@ -0,0 +1 @@ +$('#author_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/conference_author_types/new.js.erb b/app/views/admin/conference_author_types/new.js.erb new file mode 100644 index 0000000..3ac7380 --- /dev/null +++ b/app/views/admin/conference_author_types/new.js.erb @@ -0,0 +1 @@ +$('#author_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/conference_paper_levels/_form.html.erb b/app/views/admin/conference_paper_levels/_form.html.erb new file mode 100644 index 0000000..6ca8cf1 --- /dev/null +++ b/app/views/admin/conference_paper_levels/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@paper_level, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/conference_paper_levels/_index.js.erb b/app/views/admin/conference_paper_levels/_index.js.erb new file mode 100644 index 0000000..eb3450f --- /dev/null +++ b/app/views/admin/conference_paper_levels/_index.js.erb @@ -0,0 +1,2 @@ +$('#paper_levels tbody').html("<%= j render :partial => '/admin/writing_conferences/list_paper_level', :collection => @paper_levels %>"); +$('#paper_level_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/conference_paper_levels/edit.js.erb b/app/views/admin/conference_paper_levels/edit.js.erb new file mode 100644 index 0000000..baee16d --- /dev/null +++ b/app/views/admin/conference_paper_levels/edit.js.erb @@ -0,0 +1 @@ +$('#paper_level_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/conference_paper_levels/new.js.erb b/app/views/admin/conference_paper_levels/new.js.erb new file mode 100644 index 0000000..baee16d --- /dev/null +++ b/app/views/admin/conference_paper_levels/new.js.erb @@ -0,0 +1 @@ +$('#paper_level_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/conference_paper_types/_form.html.erb b/app/views/admin/conference_paper_types/_form.html.erb new file mode 100644 index 0000000..14612ca --- /dev/null +++ b/app/views/admin/conference_paper_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@paper_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/conference_paper_types/_index.js.erb b/app/views/admin/conference_paper_types/_index.js.erb new file mode 100644 index 0000000..6432e72 --- /dev/null +++ b/app/views/admin/conference_paper_types/_index.js.erb @@ -0,0 +1,2 @@ +$('#paper_types tbody').html("<%= j render :partial => '/admin/writing_conferences/list_paper_type', :collection => @paper_types %>"); +$('#paper_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/conference_paper_types/edit.js.erb b/app/views/admin/conference_paper_types/edit.js.erb new file mode 100644 index 0000000..e738913 --- /dev/null +++ b/app/views/admin/conference_paper_types/edit.js.erb @@ -0,0 +1 @@ +$('#paper_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/conference_paper_types/new.js.erb b/app/views/admin/conference_paper_types/new.js.erb new file mode 100644 index 0000000..e738913 --- /dev/null +++ b/app/views/admin/conference_paper_types/new.js.erb @@ -0,0 +1 @@ +$('#paper_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/writing_conferences/_form.html.erb b/app/views/admin/writing_conferences/_form.html.erb new file mode 100644 index 0000000..3ed9fba --- /dev/null +++ b/app/views/admin/writing_conferences/_form.html.erb @@ -0,0 +1,339 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + +
+ + + + + + +
+ + +
+ +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id %> +
+
+ + +
+ +
+ <%= select_year((@writing_conference.year ? @writing_conference.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'writing_conference[year]',:class => 'span1'} ) %> +
+
+ + +
+ +
+ <% @paper_types.each do |paper_type| %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= check_box_tag 'writing_conference[conference_paper_type_ids][]', paper_type.id, @writing_conference.conference_paper_type_ids.include?(paper_type.id)%> + <%= paper_type.title %> + <%= hidden_field_tag 'writing_conference[conference_paper_type_ids][]', '' %> + <% end %> + <% end %> +
+
+ + +
+ +
+ <% @paper_levels.each do |paper_level| %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= check_box_tag 'writing_conference[conference_paper_level_ids][]', paper_level.id, @writing_conference.conference_paper_level_ids.include?(paper_level.id)%> + <%= paper_level.title %> + <%= hidden_field_tag 'writing_conference[conference_paper_level_ids][]', '' %> + <% end %> + <% end %> +
+
+ + +
+ +
+ <% @author_types.each do |author_type| %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= check_box_tag 'writing_conference[conference_author_type_ids][]', author_type.id, @writing_conference.conference_author_type_ids.include?(author_type.id)%> + <%= author_type.title %> + <%= hidden_field_tag 'writing_conference[conference_author_type_ids][]', '' %> + <% end %> + <% end %> +
+
+ + +
+ +
+ <%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM/dd" %> +
+
+ + +
+ +
+ <%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM/dd" %> +
+
+ + +
+ +
+ <%= f.datetime_picker :publication_date, :no_label => true, :format=>"yyyy/MM/dd" %> +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ <%= f.text_field :isbn %> +
+
+ + +
+ +
+ <%= f.text_field :isi_number %> +
+
+ + +
+ +
+ <%= f.text_field :url , :class => "span6" %> +
+
+ + +
+ +
+ <%= f.text_field :keywords, :class => "span6" %> +
+
+ + +
+ +
+ <%= f.text_area :abstract, rows: 2, class: "input-block-level" %> +
+
+ + +
+ +
+ <%= f.text_area :note, rows: 2, class: "input-block-level" %> +
+
+ +
+ + +
+ + +
+ +
+ +
+
+ +
+ +
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+ <%= f.fields_for :paper_title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.paper_title"), value: (@writing_conference.paper_title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :conference_title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.conference_title"), value: (@writing_conference.conference_title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :location_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.location"), value: (@writing_conference.location_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :sponsor_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.sponsor"), value: (@writing_conference.sponsor_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :authors_translations do |f| %> + <%= f.text_area locale, class: "input-block-level", placeholder: t("personal_conference.authors"), value: (@writing_conference.authors_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ + <% end %> + + +
+ +
+ + + <% if @writing_conference && !@writing_conference.writing_conference_files.blank? %> +
+ <% @writing_conference.writing_conference_files.each_with_index do |archive_file_multiple, i| %> + <%= f.fields_for :writing_conference_files, archive_file_multiple do |f| %> + <%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> +
+
+ <% end %> + + +
+
+

+ <%= hidden_field_tag 'plugin_file_field_count', @writing_conference.writing_conference_files.count %> + <%= t(:add) %> +

+ +
+
+
+ +
+ + +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + + +<% content_for :page_specific_javascript do %> + +<% end %> + + + diff --git a/app/views/admin/writing_conferences/_form_file.html.erb b/app/views/admin/writing_conferences/_form_file.html.erb new file mode 100644 index 0000000..8628623 --- /dev/null +++ b/app/views/admin/writing_conferences/_form_file.html.erb @@ -0,0 +1,55 @@ +<% if form_file.new_record? %> +
+<% else %> +
+ <% if form_file.file.blank? %> + <%= t(:no_file) %> + <% else %> + <%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %> + <% end %> +<% end %> +
+ + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :description_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + <% if form_file.new_record? %> + + + + <% else %> + + <%= f.hidden_field :id %> + + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + + <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/writing_conferences/_list_author_type.html.erb b/app/views/admin/writing_conferences/_list_author_type.html.erb new file mode 100644 index 0000000..9082e00 --- /dev/null +++ b/app/views/admin/writing_conferences/_list_author_type.html.erb @@ -0,0 +1,8 @@ + + <%= list_author_type.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_conference_author_type_path(list_author_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/writing_conferences/_list_paper_level.html.erb b/app/views/admin/writing_conferences/_list_paper_level.html.erb new file mode 100644 index 0000000..e5e0755 --- /dev/null +++ b/app/views/admin/writing_conferences/_list_paper_level.html.erb @@ -0,0 +1,8 @@ + + <%= list_paper_level.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_conference_paper_level_path(list_paper_level), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/writing_conferences/_list_paper_type.html.erb b/app/views/admin/writing_conferences/_list_paper_type.html.erb new file mode 100644 index 0000000..653b811 --- /dev/null +++ b/app/views/admin/writing_conferences/_list_paper_type.html.erb @@ -0,0 +1,8 @@ + + <%= list_paper_type.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_conference_paper_type_path(list_paper_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/writing_conferences/_writing_conference.html.erb b/app/views/admin/writing_conferences/_writing_conference.html.erb new file mode 100644 index 0000000..86f610a --- /dev/null +++ b/app/views/admin/writing_conferences/_writing_conference.html.erb @@ -0,0 +1,15 @@ +<% @writing_conferences.each do |writing_conference| %> + "> + <%= writing_conference.year %> + + <%= link_to writing_conference.create_link, '', target: "blank"%> +
+ +
+ + <%= writing_conference.member_profile.name %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/writing_conferences/edit.html.erb b/app/views/admin/writing_conferences/edit.html.erb new file mode 100644 index 0000000..cebd024 --- /dev/null +++ b/app/views/admin/writing_conferences/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @writing_conference, url:'/admin/writing_conferences/'+@writing_conference.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/writing_conferences/frontend_setting.html.erb b/app/views/admin/writing_conferences/frontend_setting.html.erb new file mode 100644 index 0000000..6e99d0f --- /dev/null +++ b/app/views/admin/writing_conferences/frontend_setting.html.erb @@ -0,0 +1,93 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> + +<%= form_for(:writing_conference_intro, :url => update_frontend_setting_admin_writing_conferences_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %> +
+ +
+ + + + + + +
+ +
+ <% if !@member.blank? %> +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id %> +
+
+ <% end %> + +
+ +
+ <%= f.check_box :display_intro, :checked => @intro.display_intro %> <%= t("personal_plugins.brief_intro") %> + <%= f.check_box :display_conference_list, :checked => @intro.display_conference_list %> <%= t("personal_plugins.complete_list") %> +
+
+
+
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+
+ <%= f.fields_for :text_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@intro.text_translations[locale] rescue nil) %> + <% end %> +
+
+
+ + +
+ + <% end %> + + + +
+ + + +
+ + +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/writing_conferences/index.html.erb b/app/views/admin/writing_conferences/index.html.erb new file mode 100644 index 0000000..23a92ab --- /dev/null +++ b/app/views/admin/writing_conferences/index.html.erb @@ -0,0 +1,21 @@ + + + + + + + + + + <%= render :partial => 'writing_conference', :collection => @writing_conferences %> + +
<%= t('personal_plugins.year') %><%= t('module_name.personal_conference') %><%= t('personal_plugins.author') %>
+ +
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_writing_conference_setting_path, :class => 'btn btn-primary pull-right' %> + <%#= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('new_'), new_admin_writing_conference_path, :class => 'btn btn-primary pull-right' %> +
+ +
\ No newline at end of file diff --git a/app/views/admin/writing_conferences/new.html.erb b/app/views/admin/writing_conferences/new.html.erb new file mode 100644 index 0000000..896cf60 --- /dev/null +++ b/app/views/admin/writing_conferences/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @writing_conference, url: admin_writing_conferences_path(@writing_conference), html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/writing_conferences/setting.html.erb b/app/views/admin/writing_conferences/setting.html.erb new file mode 100644 index 0000000..b82115a --- /dev/null +++ b/app/views/admin/writing_conferences/setting.html.erb @@ -0,0 +1,116 @@ + + +
+
+
+

+ <%= t('add')%> + <%= t("personal_conference.paper_type") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'list_paper_type', :collection => @paper_types %> + +
+
+
+
+
+
+ +
+
+

+ <%= t('add')%> + <%= t("personal_conference.paper_level") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'list_paper_level', :collection => @paper_levels %> + +
+
+
+
+
+
+ +
+
+

+ <%= t('add')%> + <%= t("personal_conference.author_type") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'list_author_type', :collection => @author_types %> + +
+
+
+
+
+
+
+ +
+ +
+ +
+ +
+ +
+ +
\ No newline at end of file diff --git a/app/views/plugin/personal_conference/_profile.html.erb b/app/views/plugin/personal_conference/_profile.html.erb new file mode 100644 index 0000000..4d0a3bc --- /dev/null +++ b/app/views/plugin/personal_conference/_profile.html.erb @@ -0,0 +1,86 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/list-check" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/list-check" %> +<% end %> + +<% + is_autorized_user = (current_user==@member.user || current_user.is_admin?) + if is_autorized_user + @writing_conferences = WritingConference.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) + else + @writing_conferences = WritingConference.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) + end +%> + +<% if is_autorized_user %> +
+
+ <%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_writing_conferences_path(member_profile_id: params[:id], disable: 'true') ) %> + <%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_writing_conferences_path(member_profile_id: params[:id], disable: 'false') ) %> +
+
+<% end -%> + + + + + <% if is_autorized_user %> + + <% end -%> + + + <% if not @user%> + + <% end %> + + + + <% @writing_conferences.each do |writing_conference| %> + "> + <% if is_autorized_user %> + + <% end %> + + + + + <% end %> + +
<%= t('personal_plugins.year') %><%= t('module_name.personal_conference') %><%= t('personal_plugins.author') %>
+ <%= check_box_tag 'to_change[]', writing_conference.id.to_s, false, :class => "list-check" %> + <%= writing_conference.year %> + <%= link_to writing_conference.create_link, '', target: "blank"%> +
+ +
+
<%= writing_conference.authors %>
+ + +
+ <% if is_autorized_user %> +
+ <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/writing_conferences/frontend_setting', :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'), + '/admin/members/'+@member.to_param+'/writing_conferences/new', :class => 'btn btn-primary' %> +
+ <% end %> + +
+ + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 85fb579..15b20a2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -8,6 +8,7 @@ en: language : "Language" paper_title : "Paper Title" paper_type : "Paper Type" + paper_level : "Paper Level" conference_title : "Conference Name" conference_time: "Conference Time" period_start_date : "Start Date" @@ -17,6 +18,8 @@ en: authors : "Authors" tags : "Tags" keywords : "Keywords" + isbn: "ISSN (ISBN)" + isi_number: "ISI Number" # total_pages : "Total Pages" # form_to_start : "From" # form_to_end : "To" @@ -33,6 +36,7 @@ en: frontend: writing_conferences: "Conference Paper Front-end" + frontend_setting: "Frontend Setting" create_success : "Successfully Create" update_success : "Successfully Update" delete_success : "Successfully Delete" @@ -50,4 +54,5 @@ en: save: "save" hintText: "Type in a search term" noResultsText: "No results" - searchingText: "Searching…" \ No newline at end of file + searchingText: "Searching…" + setting: "Setting" \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 2f7e445..02dd173 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -6,16 +6,19 @@ zh_tw: year : "年度" language : "語言" paper_title : "論文名稱" - paper_type : "論文型態" + paper_type : "論文類型" + paper_level: "論文等級" conference_title : "會議名稱" conference_time: "會議時間" period_start_date : "起" period_end_date : "訖" location : "地點" sponsor : "主辦單位" - authors : "作者" + authors : "全部作者" tags : "領域" keywords : "關鍵字" + isbn: "ISSN (ISBN)" + isi_number: "ISI Number" # total_pages : "總頁數" # form_to_start : "From" # form_to_end : "To" @@ -32,6 +35,7 @@ zh_tw: frontend: writing_conferences: "研討會論文前台" + frontend_setting: "前台設定" create_success : "新增完成!!" update_success : "更新完成!!" add: "新增" @@ -48,4 +52,5 @@ zh_tw: save: "儲存" hintText: "請輸入搜尋關鍵字" noResultsText: "沒有相關的比對結果" - searchingText: "搜尋中…" \ No newline at end of file + searchingText: "搜尋中…" + setting: "設定" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d96d9d4..647f0be 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,31 @@ Rails.application.routes.draw do locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do + get 'writing_conference_setting' => "writing_conferences#setting" + + resources :writing_conferences do + collection do + get 'toggle_hide' => 'writing_conferences#toggle_hide' + end + end + + resources :members do + collection do + scope '(:name-:uid)' do + resources :writing_conferences do + collection do + get 'frontend_setting' => 'writing_conferences#frontend_setting' + post 'update_frontend_setting' => 'writing_conferences#update_frontend_setting' + end + end + end + end + end + + resources :conference_paper_types + resources :conference_paper_levels + resources :conference_author_types + resources :tags end end end diff --git a/lib/personal_conference/engine.rb b/lib/personal_conference/engine.rb index 22b59af..5a201cb 100644 --- a/lib/personal_conference/engine.rb +++ b/lib/personal_conference/engine.rb @@ -4,7 +4,7 @@ module PersonalConference OrbitApp.registration "PersonalConference",:type=> 'ModuleApp' do module_label 'module_name.personal_conference' base_url File.expand_path File.dirname(__FILE__) - personal_plugin :enable => true, :sort_number => '10', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference' + personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference' version "0.1" organization "Rulingcom"