diff --git a/app/controllers/admin/researchs_controller.rb b/app/controllers/admin/researchs_controller.rb
new file mode 100644
index 0000000..d2dfd53
--- /dev/null
+++ b/app/controllers/admin/researchs_controller.rb
@@ -0,0 +1,88 @@
+class Admin::ResearchsController < OrbitMemberController
+ layout "member_plugin"
+
+ before_action :set_plugin
+ before_action :get_settings,:only => [:new, :edit, :setting]
+
+ def index
+ @researchs = Research.all
+ end
+
+ def new
+ @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
+ @research = Research.new
+ end
+
+ def create
+ @member = MemberProfile.find(research_params['member_profile_id']) rescue nil
+ @research = Research.new(research_params)
+ @research.save
+ redirect_to '/admin/members/'+@member.to_param+'/Research'
+ end
+
+ def edit
+ @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
+ @research = Research.find(params[:id])
+ end
+
+ def update
+ @member = MemberProfile.find(research_params['member_profile_id']) rescue nil
+ @research = Research.find(params[:id])
+ @research.update_attributes(research_params)
+ @research.save
+ redirect_to '/admin/members/'+@member.to_param+'/Research'
+ end
+
+ def destroy
+ @research = Research.find(params[:id])
+ @research.destroy
+ end
+
+ def toggle_hide
+ if params[:ids]
+ @researchs = Research.any_in(_id: params[:ids])
+
+ @researchs.each do |research|
+ research.is_hidden = params[:disable]
+ research.save
+ end
+ end
+
+ render json: {"success"=>true}
+ end
+
+ def setting
+ end
+
+ def frontend_setting
+ @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
+ @intro = ResearchIntro.find_by(:member_profile_id=>@member.id) rescue nil
+ @intro = @intro.nil? ? ResearchIntro.new({:member_profile_id=>@member.id}) : @intro
+ end
+
+ def update_frontend_setting
+ @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
+ @intro = ResearchIntro.find_by(:member_profile_id=>@member.id) rescue nil
+ @intro = @intro.nil? ? ResearchIntro.new({:member_profile_id=>@member.id}) : @intro
+ @intro.update_attributes(intro_params)
+ @intro.save
+ redirect_to '/admin/members/'+@member.to_param+'/Research'
+ end
+
+ def get_settings
+ end
+
+ def set_plugin
+ @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Research'}.first
+ end
+
+ private
+
+ def research_params
+ params.require(:research).permit! rescue nil
+ end
+
+ def intro_params
+ params.require(:research_intro).permit! rescue nil
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/personal_researches_controller.rb b/app/controllers/personal_researches_controller.rb
new file mode 100644
index 0000000..efc91cf
--- /dev/null
+++ b/app/controllers/personal_researches_controller.rb
@@ -0,0 +1,65 @@
+class PersonalResearchesController < ApplicationController
+ def index
+ researchs = Research.where(:is_hidden=>false).all
+ research_list = researchs.collect do |research|
+ {
+ "member" => research.member_profile.name,
+ "year" => research.year,
+ "publication_date" => research.publish_date.strftime("%Y.%m"),
+ "research_title" => research.research_title,
+ "link_to_show" => OrbitHelper.url_to_show(research.to_param)
+ }
+ end
+ {
+ "researchs" => research_list,
+ "extras" => {
+ "widget-title" => t("module_name.personal_research"),
+ "th_member" => t('users.name'),
+ "th_year" => t('personal_research.year'),
+ "th_publication_date" => t('personal_research.publication_date'),
+ "th_research_title" => t('personal_research.research_title'),
+ "th_detail" => t('detail')
+ }
+ }
+ end
+
+ def show
+ params = OrbitHelper.params
+ research = Research.where(:is_hidden=>false).find_by(uid: params[:uid])
+
+ files = research.research_files.map do |file|
+ {
+ "file_url" => file.file.url,
+ "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title),
+ "file_ext" => File.extname(file.file.path).sub('.',''),
+ "file_description" => file.description
+ }
+ end
+
+ {
+ "files" => files,
+ "data" => {
+ "research_title" => research.research_title,
+ "authors" => research.authors,
+ "extracted_chapters" => research.extracted_chapters,
+ "year" => research.year,
+ "language" => t(research.language),
+ "publish_date" => research.publish_date.strftime("%Y.%m"),
+ "keywords" => research.keywords,
+ "url" => research.url,
+ "note" => research.note,
+
+ "th_research_title" => t("personal_research.research_title"),
+ "th_authors" => t("personal_research.authors"),
+ "th_extracted_chapters" => t("personal_research.extracted_chapters"),
+ "th_year" => t("personal_research.year"),
+ "th_language" => t("personal_research.language"),
+ "th_publish_date" => t("personal_research.publication_date"),
+ "th_keywords" => t("personal_research.keywords"),
+ "th_url" => t("personal_research.url"),
+ "th_note" => t("personal_research.note"),
+ "th_files" => t(:file_)
+ }
+ }
+ end
+end
\ No newline at end of file
diff --git a/app/models/research.rb b/app/models/research.rb
new file mode 100644
index 0000000..1fcb1da
--- /dev/null
+++ b/app/models/research.rb
@@ -0,0 +1,38 @@
+class Research
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include OrbitModel::Status
+ include Slug
+
+ belongs_to :member_profile
+
+ field :research_title, as: :slug_title, localize: true
+ field :authors, localize: true
+ field :extracted_chapters, localize: true
+
+ field :year
+ field :language
+ field :publish_date , :type => Date
+ field :keywords
+ field :url
+ field :note
+ field :create_user_id, :type => BSON::ObjectId
+ field :update_user_id, :type => BSON::ObjectId
+
+ paginates_per 10
+
+ has_many :research_files, :autosave => true, :dependent => :destroy
+
+ accepts_nested_attributes_for :research_files, :allow_destroy => true
+
+ before_validation :add_http
+
+ 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/research_file.rb b/app/models/research_file.rb
new file mode 100644
index 0000000..408f09d
--- /dev/null
+++ b/app/models/research_file.rb
@@ -0,0 +1,14 @@
+class ResearchFile
+
+ 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 :research
+
+end
diff --git a/app/models/research_intro.rb b/app/models/research_intro.rb
new file mode 100644
index 0000000..2079831
--- /dev/null
+++ b/app/models/research_intro.rb
@@ -0,0 +1,4 @@
+class ResearchIntro < PersonalPluginIntro
+
+
+end
diff --git a/app/views/admin/researchs/_form.html.erb b/app/views/admin/researchs/_form.html.erb
new file mode 100644
index 0000000..d80b3e2
--- /dev/null
+++ b/app/views/admin/researchs/_form.html.erb
@@ -0,0 +1,228 @@
+<% # 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 %>
+
+
+
+
+
+
+ <%= 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 %>
\ No newline at end of file
diff --git a/app/views/admin/researchs/_form_file.html.erb b/app/views/admin/researchs/_form_file.html.erb
new file mode 100644
index 0000000..8628623
--- /dev/null
+++ b/app/views/admin/researchs/_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 %>
+
+
\ No newline at end of file
diff --git a/app/views/admin/researchs/_research.html.erb b/app/views/admin/researchs/_research.html.erb
new file mode 100644
index 0000000..2f1c540
--- /dev/null
+++ b/app/views/admin/researchs/_research.html.erb
@@ -0,0 +1,16 @@
+<% @researchs.each do |research| %>
+
">
+ <%= research.year %>
+ <%= research.publish_date.strftime("%Y.%m") %>
+
+ <%= link_to research.research_title, OrbitHelper.url_to_plugin_show(research.to_param,'personal_research'), target: "blank"%>
+
+
+ <%= link_to t('edit'), '/admin/members/'+research.member_profile.to_param+'/researchs/'+research.id+'/edit' %>
+ <%= link_to t(:delete_), admin_research_path(id: research.id, member_profile_id: research.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %>
+
+
+
+ <%= research.member_profile.name %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/researchs/destroy.js.erb b/app/views/admin/researchs/destroy.js.erb
new file mode 100644
index 0000000..ea17c3a
--- /dev/null
+++ b/app/views/admin/researchs/destroy.js.erb
@@ -0,0 +1 @@
+$('#research_<%= @research.id.to_s%>').remove();
\ No newline at end of file
diff --git a/app/views/admin/researchs/edit.html.erb b/app/views/admin/researchs/edit.html.erb
new file mode 100644
index 0000000..9a86c4e
--- /dev/null
+++ b/app/views/admin/researchs/edit.html.erb
@@ -0,0 +1,5 @@
+<%= form_for @research, url:'/admin/researchs/'+@research.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/researchs/frontend_setting.html.erb b/app/views/admin/researchs/frontend_setting.html.erb
new file mode 100644
index 0000000..f1c84b0
--- /dev/null
+++ b/app/views/admin/researchs/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(:research_intro, :url => update_frontend_setting_admin_researchs_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
+
+
+
+
+
+
+ <%= 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/researchs/index.html.erb b/app/views/admin/researchs/index.html.erb
new file mode 100644
index 0000000..6bf58a7
--- /dev/null
+++ b/app/views/admin/researchs/index.html.erb
@@ -0,0 +1,13 @@
+
+
+
+ <%= t('personal_research.year') %>
+ <%= t('personal_research.publication_date') %>
+ <%= t('personal_research.research_title') %>
+ <%= t('users.name') %>
+
+
+
+ <%= render :partial => 'research', :collection => @researchs %>
+
+
\ No newline at end of file
diff --git a/app/views/admin/researchs/new.html.erb b/app/views/admin/researchs/new.html.erb
new file mode 100644
index 0000000..a39eb92
--- /dev/null
+++ b/app/views/admin/researchs/new.html.erb
@@ -0,0 +1,5 @@
+<%= form_for @research, url: admin_researchs_path, 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/researchs/setting.html.erb b/app/views/admin/researchs/setting.html.erb
new file mode 100644
index 0000000..7a3fa96
--- /dev/null
+++ b/app/views/admin/researchs/setting.html.erb
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/app/views/personal_researches/index.html.erb b/app/views/personal_researches/index.html.erb
new file mode 100644
index 0000000..648b75c
--- /dev/null
+++ b/app/views/personal_researches/index.html.erb
@@ -0,0 +1 @@
+<%= render_view %>
\ No newline at end of file
diff --git a/app/views/personal_researches/show.html.erb b/app/views/personal_researches/show.html.erb
new file mode 100644
index 0000000..648b75c
--- /dev/null
+++ b/app/views/personal_researches/show.html.erb
@@ -0,0 +1 @@
+<%= render_view %>
\ No newline at end of file
diff --git a/app/views/plugin/personal_research/_profile.html.erb b/app/views/plugin/personal_research/_profile.html.erb
new file mode 100644
index 0000000..08f23d7
--- /dev/null
+++ b/app/views/plugin/personal_research/_profile.html.erb
@@ -0,0 +1,84 @@
+<% 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
+ @researchs = Research.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
+ else
+ @researchs = Research.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_researchs_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_researchs_path(member_profile_id: params[:id], disable: 'false') ) %>
+
+
+<% end -%>
+
+
+
+
+ <% if is_autorized_user %>
+
+ <% end -%>
+ <%= t('personal_research.year') %>
+ <%= t('personal_research.publication_date') %>
+ <%= t('personal_research.research_title') %>
+
+
+
+ <% @researchs.each do |research| %>
+ ">
+ <% if is_autorized_user %>
+
+ <%= check_box_tag 'to_change[]', research.id.to_s, false, :class => "list-check" %>
+
+ <% end %>
+ <%= research.year %>
+ <%= research.publish_date.strftime("%Y.%m") %>
+
+ <%= link_to research.research_title, OrbitHelper.url_to_plugin_show(research.to_param,'personal_research'), target: "blank"%>
+
+
+ <%= link_to t('edit'), '/admin/members/'+@member.to_param+'/researchs/'+research.id+'/edit' %>
+ <%= link_to t(:delete_), admin_research_path(id: research.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %>
+
+
+
+
+ <% end %>
+
+
+
+
+
+ <% if is_autorized_user %>
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/researchs/frontend_setting', :class => 'btn btn-primary' %>
+ <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
+ '/admin/members/'+@member.to_param+'/researchs/new', :class => 'btn btn-primary' %>
+
+ <% end %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index d96d9d4..3f5f0ba 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,6 +2,27 @@ 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 'research_setting' => "researchs#setting"
+
+ resources :researchs do
+ collection do
+ get 'toggle_hide' => 'researchs#toggle_hide'
+ end
+ end
+
+ resources :members do
+ collection do
+ scope '(:name-:uid)' do
+ resources :researchs do
+ collection do
+ get 'frontend_setting' => 'researchs#frontend_setting'
+ post 'update_frontend_setting' => 'researchs#update_frontend_setting'
+ end
+ end
+ end
+ end
+ end
+
end
end
end
diff --git a/lib/personal_research/engine.rb b/lib/personal_research/engine.rb
index cdaa870..4b97c44 100644
--- a/lib/personal_research/engine.rb
+++ b/lib/personal_research/engine.rb
@@ -4,13 +4,15 @@ module PersonalResearch
OrbitApp.registration "PersonalResearch",:type=> 'ModuleApp' do
module_label 'module_name.personal_research'
base_url File.expand_path File.dirname(__FILE__)
- personal_plugin :enable => true, :sort_number => '20', :app_name=>"Research", :intro_app_name=>"PersonalResearchIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/researches",:i18n=>'module_name.personal_research'
+ personal_plugin :enable => true, :sort_number => '20', :app_name=>"Research", :intro_app_name=>"PersonalResearchIntro",:path=>"/plugin/personal_research/profile",:front_path=>"/profile",:admin_path=>"/admin/researchs",:i18n=>'module_name.personal_research', :module_app_name=>"PersonalResearch"
version "0.1"
organization "Rulingcom"
author "RD dep"
intro "I am intro"
update_info 'some update_info'
+ frontend_enabled
+ icon_class_no_sidebar "icons-user"
end
end
end