finished some method of list and journal

This commit is contained in:
Rueshyna 2012-11-18 03:07:50 +08:00
parent 024b331cf3
commit 26436395f5
20 changed files with 306 additions and 316 deletions

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 # def journal_p_list
render "desktop/journal_pages/list", :layout => false # render "desktop/journal_pages/list", :layout => false
end # end
def journal_p_add # def journal_p_add
@writing_journal = WritingJournal.new # @writing_journal = WritingJournal.new
@level_types = JournalLevelType.all # @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
#
# 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 # end
render "desktop/journal_pages/add", :layout => false
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

@ -13,8 +13,8 @@
<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>

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,21 +117,21 @@
</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

@ -153,39 +153,6 @@ namespace :desktop do
match "/" => "desktop#index" match "/" => "desktop#index"
# Sinatra Routes start
# match '/desktop/desktop', :to => Desktopapp::DesktopApp
# match '/desktop/app_manager', :to => Desktopapp::DesktopApp
# match '/desktop/sections', :to => Desktopapp::DesktopApp
# match '/desktop/settings', :to => Desktopapp::DesktopApp
# match '/desktop/get_desktop_settings/', :to => Desktopapp::DesktopApp
# match '/desktop/save_desktop_settings/', :to => Desktopapp::DesktopApp
# match '/desktop/getgroups/', :to => Desktopapp::DesktopApp
# match '/desktop/getsectionlist/', :to => Desktopapp::DesktopApp
# match '/desktop/settingthemes/', :to => Desktopapp::DesktopApp
# match '/desktop/settingsections/', :to => Desktopapp::DesktopApp
# match '/desktop/getapplist/', :to => Desktopapp::DesktopApp
# match '/desktop/newpositions/', :to => Desktopapp::DesktopApp
# match '/desktop/settingconnection/', :to => Desktopapp::DesktopApp
# match '/desktop/journal_p/', :to => Desktopapp::DesktopAppPublications
# match '/desktop/journal_p_list/', :to => Desktopapp::DesktopAppPublications
# match '/desktop/journal_p_add/', :to => Desktopapp::DesktopAppPublications
# match '/desktop_publications/getjournals', :to => Desktopapp::DesktopAppPublications
# match '/desktop/twitter/', :to => Desktopapp::Otheraccounts
# match '/desktop/forgmail/', :to => Desktopapp::Otheraccounts
# match '/desktop/getaccounts', :to => Desktopapp::Otheraccounts
# match '/desktop/save_account_info/', :to => Desktopapp::Otheraccounts
# 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 '/desktop'=>'desktop#desktop'
match '/app_manager'=>'desktop#app_manager' match '/app_manager'=>'desktop#app_manager'
match '/sections'=>'desktop#sections' match '/sections'=>'desktop#sections'
@ -202,12 +169,14 @@ namespace :desktop do
match '/widget_layout' => 'desktop#widget_layout' match '/widget_layout' => 'desktop#widget_layout'
match '/temp_func/'=>'desktop#temp_func' match '/temp_func/'=>'desktop#temp_func'
resources :journal_pages
end end
# namespace :desktop_publications do # namespace :desktop_publications do
match 'desktop_publications/journal_p'=>'desktop_publications#journal_p' 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_list'=>'desktop_publications#journal_p_list'
match 'desktop_publications/journal_p_add'=>'desktop_publications#journal_p_add' # 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_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'

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) def get_visible_links(sort = :title)
self.writing_journals.where(:is_hidden => false).desc(:is_top, sort) self.writing_journals.where(:is_hidden => false).desc(:is_top, sort)
end end
end end

View File

@ -1,21 +1,15 @@
# 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
@ -37,43 +31,25 @@ class WritingJournal
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 ) find(:all, :conditions => {writing_journal_category_id: category_id}).desc( :is_top, :title )
else else
find(:all).desc( :is_top, :title) find(:all).desc( :is_top, :title)
end 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?
@ -103,7 +79,6 @@ class WritingJournal
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(', ')
@ -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,18 +1,15 @@
# 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
@ -26,5 +23,4 @@ class WritingJournalCategory
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