finished some method of list and journal

This commit is contained in:
Rueshyna 2012-11-18 03:07:50 +08:00 committed by chris
parent 7e9b60a527
commit 5eb8cc4063
20 changed files with 306 additions and 316 deletions

View File

@ -586,7 +586,7 @@ var orbitDesktop = function(dom){
$(this).val(sectionnames[i]); $(this).val(sectionnames[i]);
}) })
bindHandlers(); bindHandlers();
}) })
} }

View File

@ -0,0 +1,54 @@
class Desktop::JournalPagesController < ApplicationController
def index
@writing_journal = WritingJournal.where(create_user_id: current_user.id)
@level_types = JournalLevelType.all
respond_to do |format|
format.html { render :layout => false}
end
end
def new
@writing_journal = WritingJournal.new
@level_types = JournalLevelType.all
@author_types = JournalAuthorType.all
@paper_types= JournalPaperType.all
respond_to do |format|
format.html { render :layout => false}
end
end
def edit
end
def create
if params[:commit].eql?"Save"
if not params[:writing_journal][:publication_date].nil?
params[:writing_journal][:publication_date] = \
Date.new *(params[:writing_journal][:publication_date].split("/").map{|s| s.to_i})
end
params[:writing_journal][:create_user_id] = current_user.id
@writing_journal = WritingJournal.new(params[:writing_journal])
if @writing_journal.save
respond_to do |format|
format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully created.'}
# format.json { render json: @writing_journal, status: :created, location: @writing_journal}
# format.js
end
else
end
end
end
def show
end
def update
if params[:commit].eql?"Edit"
params[:writing_journal][:update_user_id] = current_user.id
end
end
end

View File

@ -4,21 +4,29 @@ class DesktopPublicationsController< ApplicationController
def journal_p def journal_p
render "desktop/journal_p", :layout => false render "desktop/journal_p", :layout => false
end end
#
# def journal_p_list
# render "desktop/journal_pages/list", :layout => false
# end
def journal_p_list # def journal_p_add
render "desktop/journal_pages/list", :layout => false # @writing_journal = WritingJournal.new
end # @level_types = JournalLevelType.all
#
def journal_p_add
@writing_journal = WritingJournal.new
@level_types = JournalLevelType.all
# respond_to do |format| # respond_to do |format|
# format.html # new.html.erb # format.html { render "desktop/journal_pages/add", :layout => false}
# format.xml { render :xml => @writing_journal }
# end # end
render "desktop/journal_pages/add", :layout => false # end
end #
# def journal_p_create
# @writing_journal = WritingJournal.all.first
# @level_types = JournalLevelType.all
# respond_to do |format|
# format.html { render "desktop/journal_pages/list", :layout => false}
# #format.js
# end
#
# end
def books def books
render "desktop/books", :layout => false render "desktop/books", :layout => false
@ -75,8 +83,6 @@ class DesktopPublicationsController< ApplicationController
def getjournals def getjournals
publications = WritingJournal.where(create_user_id: current_user.id) publications = WritingJournal.where(create_user_id: current_user.id)
p current_user.id
p "======="
sort_publications= Hash.new sort_publications= Hash.new
data = Array.new data = Array.new

View File

@ -1,33 +1,33 @@
<div id="journal_p"> <div id="journal_p">
<div id="content"> <div id="content">
<div id="header" class="hh3"> <div id="header" class="hh3">
<div class="dtitle w2 hh3 hp"> <div class="dtitle w2 hh3 hp">
<span class="thmtxth">Journal Papers</span> <span class="thmtxth">Journal Papers</span>
</div> </div>
<div id="search_app" class="hfn w2 hh2 hp thmc3"> <div id="search_app" class="hfn w2 hh2 hp thmc3">
<input type="text" class="ini_input form" value="Search" id="searchbox" /> <input type="text" class="ini_input form" value="Search" id="searchbox" />
<input type="submit" class="ini_input submit thmc1" value="Submit"/> <input type="submit" class="ini_input submit thmc1" value="Submit"/>
</div> </div>
</div> </div>
<div id="holder"> <div id="holder">
<div id="panel_l" class="ph"> <div id="panel_l" class="ph">
<div class="s_menu sm_v"> <div class="s_menu sm_v">
<ul id='setting_left_nav'> <ul id='setting_left_nav'>
<li><a href="<%= desktop_publications_journal_p_list_path %>" data-method="list" class="hh2 w2 hp active thmc1 thmtxt xx" onclick='return false;'>List</a></li> <li><a href="<%= desktop_journal_pages_path %>" data-method="list" class="hh2 w2 hp active thmc1 thmtxt xx" onclick='return false;'>List</a></li>
<li><a href="<%= desktop_publications_journal_p_add_path %>" data-method="addpaper" class="admtxt hh2 w2 hp xx" onclick='return false;'>Add/Edit</a></li> <li><a href="<%= new_desktop_journal_page_path %>" data-method="addpaper" class="admtxt hh2 w2 hp xx" onclick='return false;'>Add/Edit</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Journals</a></li> <li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Journals</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Co-Authors</a></li> <li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Co-Authors</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Tags &amp; Keywords</a></li> <li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Tags &amp; Keywords</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Analysis</a></li> <li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Analysis</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Import</a></li> <li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Import</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Export</a></li> <li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Export</a></li>
</ul> </ul>
</div> </div>
</div> </div>
<div id="panel_r" class="ph pw admbg hp"> <div id="panel_r" class="ph pw admbg hp">
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -60,7 +60,7 @@
<ul> <ul>
<% @level_types.each_with_index do |level_type, i| %> <% @level_types.each_with_index do |level_type, i| %>
<li> <li>
<%= check_box_tag "field-#{i}", <%= check_box_tag "writing_journal[journal_level_type_ids][]",
level_type.id, level_type.id,
@writing_journal.journal_level_type_ids.include?(level_type.id) @writing_journal.journal_level_type_ids.include?(level_type.id)
%><%= label_tag("field-#{i}", level_type.title) %> %><%= label_tag("field-#{i}", level_type.title) %>
@ -117,22 +117,22 @@
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<select name="" id="" class="s_grid s_grid_4"> <select name="writing_journal[journal_author_type_ids][]" id="" class="s_grid s_grid_4">
<%= options_for_select([["Author Type", 1], <%= options_for_select(
["First Author", 2], @author_types.map do |author_type|
["Corresponding Author", 3], [author_type.title, author_type.id]
["Second Author", 4], end
["Third Author", 5], )
["Fourth Author", 6]], 1)
%> %>
</select> </select>
<select name="" id="" class="s_grid s_grid_2"> <select name="writing_journal[journal_paper_type_ids][]" id="" class="s_grid s_grid_2">
<%= options_for_select([['Status', 1], <%= options_for_select(
['Published', 2], @paper_types.map do |paper_type|
['Pending', 3], [paper_type.title, paper_type.id]
['Writing', 4]], 1) end
%> )
%>
</select> </select>
</li> </li>

View File

@ -1,3 +0,0 @@
<%= form_for @writing_journal, url: desktop_publications_journal_p_add_path do |f| %>
<%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %>
<%end%>

View File

@ -0,0 +1,2 @@
<h1>Desktop::JournalPages#edit</h1>
<p>Find me in app/views/desktop/journal_pages/edit.html.erb</p>

View File

@ -0,0 +1,88 @@
<div class="toolbar hh2">
<div class="hh2 hp sdm">
<div class="sdm_t hh2"><span class="icon-check"></span></div>
<div class="admbg sdm_o">
<ul id="journal_selection_options">
<li><a class="hp hh2 admtxt" href="all">All</a></li>
<li><a class="hp hh2 admtxt" href="none">None</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">More</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">Delete</a></li>
<li><a class="hp hh2 admtxt" href="">Tag</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Tag</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">All</a></li>
<li><a class="hp hh2 admtxt" href="">Starred</a></li>
<li><a class="hp hh2 admtxt" href="">MIT</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Status</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">All</a></li>
<li><a class="hp hh2 admtxt" href="">Published</a></li>
<li><a class="hp hh2 admtxt" href="">Pending</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">View</div>
<div class="admbg sdm_o">
<ul id="journal_view_selection">
<li><a class="hp hh2 admtxt" href="journal">Journal</a></li>
<li><a class="hp hh2 admtxt" href="title">Title</a></li>
<li><a class="hp hh2 admtxt" href="file">File</a></li>
<li><a class="hp hh2 admtxt" href="keywords">Keywords</a></li>
<li><a class="hp hh2 admtxt" href="abstract">Abstract</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Share</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">Full</a></li>
<li><a class="hp hh2 admtxt" href="">Abstract</a></li>
<li><a class="hp hh2 admtxt" href="">Friends</a></li>
<li><a class="hp hh2 admtxt" href="">Private</a></li>
<li><a class="hp hh2 admtxt" href="">Group</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2" id='ns'>New Share</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt remote_url" href="<%= panel_personal_journal_plugin_writing_journals_path %>">Full</a></li>
<li><a class="hp hh2 admtxt" href="">Abstract</a></li>
<li><a class="hp hh2 admtxt" href="">Friends</a></li>
<li><a class="hp hh2 admtxt" href="">Private</a></li>
<li><a class="hp hh2 admtxt" href="">Group</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2"><span class="icon-question-sign"></span></div>
</div>
</div>
<div id="paper_list" class="tinycanvas vp">
<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>
<div class="viewport">
<div class="overview">
</div>
</div>
</div>

View File

@ -1,87 +0,0 @@
<div class="toolbar hh2">
<div class="hh2 hp sdm">
<div class="sdm_t hh2"><span class="icon-check"></span></div>
<div class="admbg sdm_o">
<ul id="journal_selection_options">
<li><a class="hp hh2 admtxt" href="all">All</a></li>
<li><a class="hp hh2 admtxt" href="none">None</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">More</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">Delete</a></li>
<li><a class="hp hh2 admtxt" href="">Tag</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Tag</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">All</a></li>
<li><a class="hp hh2 admtxt" href="">Starred</a></li>
<li><a class="hp hh2 admtxt" href="">MIT</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Status</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">All</a></li>
<li><a class="hp hh2 admtxt" href="">Published</a></li>
<li><a class="hp hh2 admtxt" href="">Pending</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">View</div>
<div class="admbg sdm_o">
<ul id="journal_view_selection">
<li><a class="hp hh2 admtxt" href="journal">Journal</a></li>
<li><a class="hp hh2 admtxt" href="title">Title</a></li>
<li><a class="hp hh2 admtxt" href="file">File</a></li>
<li><a class="hp hh2 admtxt" href="keywords">Keywords</a></li>
<li><a class="hp hh2 admtxt" href="abstract">Abstract</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2">Share</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt" href="">Full</a></li>
<li><a class="hp hh2 admtxt" href="">Abstract</a></li>
<li><a class="hp hh2 admtxt" href="">Friends</a></li>
<li><a class="hp hh2 admtxt" href="">Private</a></li>
<li><a class="hp hh2 admtxt" href="">Group</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2" id='ns'>New Share</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh2 admtxt remote_url" href="<%= panel_personal_journal_plugin_writing_journals_path %>">Full</a></li>
<li><a class="hp hh2 admtxt" href="">Abstract</a></li>
<li><a class="hp hh2 admtxt" href="">Friends</a></li>
<li><a class="hp hh2 admtxt" href="">Private</a></li>
<li><a class="hp hh2 admtxt" href="">Group</a></li>
</ul>
</div>
</div>
<div class="hh2 hp sdm">
<div class="sdm_t hh2"><span class="icon-question-sign"></span></div>
</div>
</div>
<div id="paper_list" class="tinycanvas vp">
<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>
<div class="viewport">
<div class="overview">
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
<%= form_for @writing_journal, url: desktop_journal_pages_path do |f| %>
<%= render partial: 'desktop/journal_pages/form', locals: {:f => f} %>
<%end%>

View File

@ -0,0 +1,2 @@
<h1>Desktop::JournalPages#show</h1>
<p>Find me in app/views/desktop/journal_pages/show.html.erb</p>

View File

@ -2,7 +2,7 @@ Orbit::Application.routes.draw do
devise_for :users devise_for :users
mount Resque::Server, :at => "/admin/resque" mount Resque::Server, :at => "/admin/resque"
# routes for sinatra app # routes for sinatra app
match '/site/set_registered', :to => CentralServerExchangeApp match '/site/set_registered', :to => CentralServerExchangeApp
match '/site/public_key', :to => CentralServerExchangeApp match '/site/public_key', :to => CentralServerExchangeApp
@ -28,7 +28,7 @@ Orbit::Application.routes.draw do
match 'new_interface' => "object_auths_new_interface#setting" ,:as => :ob_auth,:via => :get match 'new_interface' => "object_auths_new_interface#setting" ,:as => :ob_auth,:via => :get
match 'new_interface' => "object_auths_new_interface#update_setting" ,:as => :ob_auth,:via => :post match 'new_interface' => "object_auths_new_interface#update_setting" ,:as => :ob_auth,:via => :post
match 'new_interface' => "object_auths_new_interface#user_list" ,:as => :ob_auth_show,:via => :put match 'new_interface' => "object_auths_new_interface#user_list" ,:as => :ob_auth_show,:via => :put
collection do collection do
match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init
end end
@ -43,11 +43,11 @@ Orbit::Application.routes.draw do
match 'ad_banners/:id/rename' => 'ad_banners#rename',:as => :rename_ad_banner,:via => :post match 'ad_banners/:id/rename' => 'ad_banners#rename',:as => :rename_ad_banner,:via => :post
resources :ad_banners do resources :ad_banners do
collection do collection do
match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get
match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
end end
resources :ad_images ,:except => [:show,:index] resources :ad_images ,:except => [:show,:index]
end end
resources :dashboards resources :dashboards
resources :designs do resources :designs do
@ -87,7 +87,7 @@ Orbit::Application.routes.draw do
match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove
end end
end end
member do member do
match 'assign_manager' ,:action=> 'assign_manager',:via => "post",:as =>:assign_manager match 'assign_manager' ,:action=> 'assign_manager',:via => "post",:as =>:assign_manager
match 'assign_sub_manager' ,:action=> 'assign_sub_manager',:via => "post",:as =>:assign_sub_manager match 'assign_sub_manager' ,:action=> 'assign_sub_manager',:via => "post",:as =>:assign_sub_manager
@ -136,78 +136,47 @@ Orbit::Application.routes.draw do
end end
# end admin # end admin
namespace :panel do namespace :panel do
resources :users resources :users
end end
resources :desktop_widgets do resources :desktop_widgets do
collection do collection do
get 'upload' get 'upload'
get 'delete' get 'delete'
post 'upload' post 'upload'
end end
end end
namespace :desktop do namespace :desktop do
match "/"=>"desktop#index"
# Sinatra Routes start match "/" => "desktop#index"
# match '/desktop/desktop', :to => Desktopapp::DesktopApp match '/desktop'=>'desktop#desktop'
# match '/desktop/app_manager', :to => Desktopapp::DesktopApp match '/app_manager'=>'desktop#app_manager'
# match '/desktop/sections', :to => Desktopapp::DesktopApp match '/sections'=>'desktop#sections'
# match '/desktop/settings', :to => Desktopapp::DesktopApp match '/settings'=>'desktop#settings'
# match '/desktop/get_desktop_settings/', :to => Desktopapp::DesktopApp match '/get_desktop_settings/'=>'desktop#get_desktop_settings'
# match '/desktop/save_desktop_settings/', :to => Desktopapp::DesktopApp match '/save_desktop_settings/'=>'desktop#save_desktop_settings'
# match '/desktop/getgroups/', :to => Desktopapp::DesktopApp match '/getgroups/'=>'desktop#getgroups'
# match '/desktop/getsectionlist/', :to => Desktopapp::DesktopApp match '/getsectionlist/'=>'desktop#getsectionlist'
# match '/desktop/settingthemes/', :to => Desktopapp::DesktopApp match '/themes/'=>'desktop#themes'
# match '/desktop/settingsections/', :to => Desktopapp::DesktopApp match '/sections/'=>'desktop#sections'
# match '/desktop/getapplist/', :to => Desktopapp::DesktopApp match '/getapplist/'=>'desktop#getapplist'
# match '/desktop/newpositions/', :to => Desktopapp::DesktopApp match '/newpositions/'=>'desktop#newpositions'
# match '/desktop/settingconnection/', :to => Desktopapp::DesktopApp match '/connections/'=>'desktop#connections'
match '/widget_layout' => 'desktop#widget_layout'
# match '/desktop/journal_p/', :to => Desktopapp::DesktopAppPublications match '/temp_func/'=>'desktop#temp_func'
# match '/desktop/journal_p_list/', :to => Desktopapp::DesktopAppPublications resources :journal_pages
# match '/desktop/journal_p_add/', :to => Desktopapp::DesktopAppPublications end
# match '/desktop_publications/getjournals', :to => Desktopapp::DesktopAppPublications
# match '/desktop/twitter/', :to => Desktopapp::Otheraccounts # namespace :desktop_publications do
# match '/desktop/forgmail/', :to => Desktopapp::Otheraccounts match 'desktop_publications/journal_p'=>'desktop_publications#journal_p'
# match '/desktop/getaccounts', :to => Desktopapp::Otheraccounts # match 'desktop_publications/journal_p_list'=>'desktop_publications#journal_p_list'
# match '/desktop/save_account_info/', :to => Desktopapp::Otheraccounts # match 'desktop_publications/journal_p_add'=>'desktop_publications#journal_p_add'
# match 'desktop_publications/journal_p_create'=>'desktop_publications#journal_p_create' , :via => :post
# match '/desktop_appstore/appstore', :to => Desktopapp::DesktopAppAppstore
# match '/desktop_appstore/widgets', :to => Desktopapp::DesktopAppAppstore
# match '/desktop_appstore/getuserwidgets', :to => Desktopapp::DesktopAppAppstore
# match '/desktop_appstore/widgets_settings', :to => Desktopapp::DesktopAppAppstore
# Sinatra Routes end
match '/desktop'=>'desktop#desktop'
match '/app_manager'=>'desktop#app_manager'
match '/sections'=>'desktop#sections'
match '/settings'=>'desktop#settings'
match '/get_desktop_settings/'=>'desktop#get_desktop_settings'
match '/save_desktop_settings/'=>'desktop#save_desktop_settings'
match '/getgroups/'=>'desktop#getgroups'
match '/getsectionlist/'=>'desktop#getsectionlist'
match '/themes/'=>'desktop#themes'
match '/sections/'=>'desktop#sections'
match '/getapplist/'=>'desktop#getapplist'
match '/newpositions/'=>'desktop#newpositions'
match '/connections/'=>'desktop#connections'
match '/widget_layout' => 'desktop#widget_layout'
match '/temp_func/'=>'desktop#temp_func'
end
# namespace :desktop_publications do
match 'desktop_publications/journal_p'=>'desktop_publications#journal_p'
match 'desktop_publications/journal_p_list'=>'desktop_publications#journal_p_list'
match 'desktop_publications/journal_p_add'=>'desktop_publications#journal_p_add'
match 'desktop_publications/books' => 'desktop_publications#books' match 'desktop_publications/books' => 'desktop_publications#books'
match 'desktop_publications/books_list'=>'desktop_publications#books_list' match 'desktop_publications/books_list'=>'desktop_publications#books_list'
match 'desktop_publications/books_add'=>'desktop_publications#books_add' match 'desktop_publications/books_add'=>'desktop_publications#books_add'
@ -216,9 +185,9 @@ end
match 'desktop_publications/seminar_p_list/'=>'desktop_publications#seminar_p_list' match 'desktop_publications/seminar_p_list/'=>'desktop_publications#seminar_p_list'
match 'desktop_publications/seminar_p_add/'=>'desktop_publications#seminar_p_add' match 'desktop_publications/seminar_p_add/'=>'desktop_publications#seminar_p_add'
match 'desktop_publications/getjournals' => 'desktop_publications#getjournals' match 'desktop_publications/getjournals' => 'desktop_publications#getjournals'
# end # end
# namespace :desktop_research do # namespace :desktop_research do
match 'desktop_research/research_d' => 'desktop_research#research_d' match 'desktop_research/research_d' => 'desktop_research#research_d'
match 'desktop_research/research_d_list/' => 'desktop_research#research_d_list' match 'desktop_research/research_d_list/' => 'desktop_research#research_d_list'
match 'desktop_research/research_d_add' => 'desktop_research#research_d_add' match 'desktop_research/research_d_add' => 'desktop_research#research_d_add'
@ -226,7 +195,7 @@ end
match 'desktop_research/research_p' => 'desktop_research#research_p' match 'desktop_research/research_p' => 'desktop_research#research_p'
match 'desktop_research/research_p_list/' => 'desktop_research#research_p_list' match 'desktop_research/research_p_list/' => 'desktop_research#research_p_list'
match 'desktop_research/research_p_add' => 'desktop_research#research_p_add' match 'desktop_research/research_p_add' => 'desktop_research#research_p_add'
# end # end
match '/twitter/'=>'otheraccounts#twitter' match '/twitter/'=>'otheraccounts#twitter'
match '/forgmail/'=>'otheraccounts#gmail' match '/forgmail/'=>'otheraccounts#gmail'
@ -243,36 +212,36 @@ end
match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload' match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload'
match '/desktop_orbit/gettimelinespan' => 'desktop_orbit#gettimelinespan' match '/desktop_orbit/gettimelinespan' => 'desktop_orbit#gettimelinespan'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal'
# match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal' # match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal'
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request| match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
!request.query_string.include?("inner=true") !request.query_string.include?("inner=true")
} }
match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request| match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request|
!request.query_string.include?("inner=true") !request.query_string.include?("inner=true")
} }
match '/share/:model/:id' => 'application#render_share' match '/share/:model/:id' => 'application#render_share'
# routes for gridfs files # routes for gridfs files
match "/gridfs/*path" => "gridfs#serve" match "/gridfs/*path" => "gridfs#serve"
# match "/images/*path" => "gridfs#serve_images" # match "/images/*path" => "gridfs#serve_images"
# match "/admin/pages/images/*path" => "gridfs#serve_images" # match "/admin/pages/images/*path" => "gridfs#serve_images"
# routes for pages to generate # routes for pages to generate
match '*page_name' => 'pages#show', :as => :page, :constraints => lambda{|request| match '*page_name' => 'pages#show', :as => :page, :constraints => lambda{|request|
!request.path.starts_with?("/panel") !request.path.starts_with?("/panel")
} }
root :to => 'pages#index' root :to => 'pages#index'
end end

View File

@ -1,9 +1,5 @@
# encoding: utf-8
class JournalAuthorType < WritingJournalCategory class JournalAuthorType < WritingJournalCategory
field :title, localize: true field :title, localize: true
has_and_belongs_to_many :writing_journals has_and_belongs_to_many :writing_journals
end
end

View File

@ -1,9 +1,5 @@
# encoding: utf-8
class JournalLevelType < WritingJournalCategory class JournalLevelType < WritingJournalCategory
field :title, localize: true field :title, localize: true
has_and_belongs_to_many :writing_journals has_and_belongs_to_many :writing_journals
end
end

View File

@ -1,7 +1,3 @@
# encoding: utf-8
class JournalPaperType < WritingJournalCategory class JournalPaperType < WritingJournalCategory
field :title field :title
end
end

View File

@ -1,9 +1,7 @@
class PersonalJournalTag < Tag class PersonalJournalTag < Tag
has_and_belongs_to_many :writing_journals has_and_belongs_to_many :writing_journals
def get_visible_links(sort = :title)
self.writing_journals.where(:is_hidden => false).desc(:is_top, sort)
end
end def get_visible_links(sort = :title)
self.writing_journals.where(:is_hidden => false).desc(:is_top, sort)
end
end

View File

@ -1,26 +1,20 @@
# encoding: utf-8
class WritingJournal class WritingJournal
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
# scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
LANGUAGE_TYPES = [ "English", "Chinese" ]
LANGUAGE_TYPES = [ "English", "Chinese" ]
field :paper_title, localize: true field :paper_title, localize: true
field :journal_title, localize: true field :journal_title, localize: true
field :authors, localize: true field :authors, localize: true
has_and_belongs_to_many :tags, :class_name => "PersonalJournalTag" has_and_belongs_to_many :tags, :class_name => "PersonalJournalTag"
has_and_belongs_to_many :journal_author_types has_and_belongs_to_many :journal_author_types
has_and_belongs_to_many :journal_level_types has_and_belongs_to_many :journal_level_types
belongs_to :journal_paper_type belongs_to :journal_paper_type
field :year field :year
field :language field :language
field :isbn field :isbn
@ -36,54 +30,36 @@ class WritingJournal
field :note field :note
field :create_user_id, :type => BSON::ObjectId field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId field :update_user_id, :type => BSON::ObjectId
# field :is_top, :type => Boolean, :default => false
# field :is_hot, :type => Boolean, :default => false
# field :is_hidden, :type => Boolean, :default => false
has_many :writing_journal_files, :autosave => true, :dependent => :destroy has_many :writing_journal_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :writing_journal_files, :allow_destroy => true accepts_nested_attributes_for :writing_journal_files, :allow_destroy => true
# before_save :update_avliable_language, :clean_checkboxs
validates :paper_title, :at_least_one => true
before_validation :add_http
after_save :save_writing_journal_files after_save :save_writing_journal_files
before_validation :add_http
validates :paper_title, :at_least_one => true
validates :url, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, :unless => Proc.new{self.url.blank?} validates :url, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, :unless => Proc.new{self.url.blank?}
def self.search( category_id = nil ) def self.search( category_id = nil )
if category_id.to_s.size > 0
if category_id.to_s.size > 0 find(:all, :conditions => {writing_journal_category_id: category_id}).desc( :is_top, :title )
else
find(:all, :conditions => {writing_journal_category_id: category_id}).desc( :is_top, :title ) find(:all).desc( :is_top, :title)
end
else
find(:all).desc( :is_top, :title)
end
end end
def self.widget_datas def self.widget_datas
where( :is_hidden => false ).desc(:is_top, :created_at)
where( :is_hidden => false ).desc(:is_top, :created_at)
end end
def is_top? def is_top?
self.is_top self.is_top
end end
def sorted_tags def sorted_tags
tags.order_by(I18n.locale, :asc) tags.order_by(I18n.locale, :asc)
end end
def update_avliable_language def update_avliable_language
VALID_LOCALES.each do |locale| VALID_LOCALES.each do |locale|
if (title_translations[locale].blank? rescue true) if (title_translations[locale].blank? rescue true)
@ -93,22 +69,21 @@ class WritingJournal
end end
end end
end end
def save_writing_journal_files def save_writing_journal_files
self.writing_journal_files.each do |t| self.writing_journal_files.each do |t|
if t.should_destroy if t.should_destroy
t.destroy t.destroy
end end
end end
end end
def create_link def create_link
title = ["\"#{self.paper_title}\""]
title = ["\"#{self.paper_title}\""] title << self.journal_title
title << self.journal_title title.join(', ')
title.join(', ') title << ( !self.journal_level_types.blank? ? "(#{self.journal_level_types.collect{|x| x.title}.join(', ')})" : nil)
title << ( !self.journal_level_types.blank? ? "(#{self.journal_level_types.collect{|x| x.title}.join(', ')})" : nil) title.join(', ')
title.join(', ')
end end
protected protected
@ -124,5 +99,4 @@ class WritingJournal
self.journal_author_type_ids.delete('') self.journal_author_type_ids.delete('')
self.journal_level_type_ids.delete('') self.journal_level_type_ids.delete('')
end end
end
end

View File

@ -1,30 +1,26 @@
# encoding: utf-8
class WritingJournalCategory class WritingJournalCategory
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable include OrbitCoreLib::ObjectDisable
# include Mongoid::MultiParameterAttributes
AfterObjectAuthUrl = '/panel/personal_journal/back_end/writing_journal_categorys' AfterObjectAuthUrl = '/panel/personal_journal/back_end/writing_journal_categorys'
APP_NAME = 'writing_journal' APP_NAME = 'writing_journal'
# ObjectAuthTitlesOptions = %W{edit} # ObjectAuthTitlesOptions = %W{edit}
ObjectAuthTitlesOptions = %W{submit_new fact_check} ObjectAuthTitlesOptions = %W{submit_new fact_check}
field :key field :key
has_many :writing_journals has_many :writing_journals
def pp_object def pp_object
title title
end end
def self.from_id(id) def self.from_id(id)
WritingJournalCategory.find(id) rescue nil WritingJournalCategory.find(id) rescue nil
end end
def self.is_localized?(field_name) def self.is_localized?(field_name)
self.fields[field_name.to_s].localized? self.fields[field_name.to_s].localized?
end end
end
end

View File

@ -6,9 +6,9 @@ class WritingJournalFile
mount_uploader :file, AssetUploader mount_uploader :file, AssetUploader
# field :description, localize: true # field :description, localize: true
field :should_destroy, :type => Boolean field :should_destroy, :type => Boolean
field :title, localize: true field :title, localize: true
belongs_to :writing_journal belongs_to :writing_journal
end end