Mercurial > hg > soundsoftware-site
changeset 471:49fb7a9ef79c feature_36
Using Authorships instead of Authors in the new/show actions of the publication controller.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 24 Jun 2011 15:11:30 +0100 |
parents | 30b36ab6f15a |
children | 0ce4139187fa |
files | vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/_author_fields.rhtml vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb vendor/plugins/redmine_bibliography/config/locales/en.yml vendor/plugins/redmine_bibliography/config/routes.rb |
diffstat | 7 files changed, 46 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jun 24 15:11:30 2011 +0100 @@ -3,7 +3,7 @@ class PublicationsController < ApplicationController unloadable - before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author] + before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author, :sort_authors] def new @@ -13,7 +13,7 @@ @publication.build_bibtex_entry # and at least one author - 3.times {@publication.authors.build} + @publication.authorships.build.build_author @project_id = params[:project_id] @current_user = User.current @@ -52,16 +52,6 @@ if bibtex_entry parse_bibtex_list bibtex_entry end - - # form's flow control - if params[:back_button] - @publication.previous_step - else - @publication.next_step - end - - session[:publication_step] = @publication.current_step - end def add_author @@ -186,7 +176,6 @@ end - def add_project @projects = Project.find(params[:publication][:project_ids]) @@ -209,6 +198,15 @@ logger.debug "Query for \"#{params[:q]}\" returned \"#{@projects.size}\" results" render :layout => false end + + + def sort_authors + params[:authors].each_with_index do |id, index| + Author.update_all(['order=?', index+1], ['id=?', id]) + end + render :nothing => true + end + private
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_author_fields.rhtml Fri Jun 24 11:41:01 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<div class="fields"> - <p> - <%= f.label :name, l("name") %> - <%= f.text_field :name %> - <%= f.hidden_field :_destroy %> - <%= link_to_remove_fields "remove", f %><br /> - </p> -</div> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Jun 24 15:11:30 2011 +0100 @@ -0,0 +1,12 @@ +<div class="fields"> + <p> + <%= f.label :name_on_paper, l("name") %> + <%= f.text_field :name_on_paper %><br /> + <em><%= h l("text_name_on_paper") %></em><br /> + <%= f.label :institution, l("institution") %> + <%= f.text_field :institution %><br /> + <em><%= h l("text_institution") %></em><br /> + <%= f.hidden_field :_destroy %> + <%= link_to_remove_fields l("remove_author"), f %> + </p> +</div> \ No newline at end of file
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Fri Jun 24 15:11:30 2011 +0100 @@ -11,15 +11,12 @@ </p> <h3><%= l(:authors) %></h3> - <%= link_to_remote l(:add_me_as_author), {:url => { :controller => 'publications', :action => 'add_author', :user_id => @current_user}, :update => 'users_div' }, { :id => 'add_me_as_an_author', :class => 'icon icon-add' } %> - - <% f.fields_for :authors do |builder| %> - <%= render "author_fields", :f => builder %> + <% f.fields_for :authorships do |builder| %> + <%= render "authorship_fields", :f => builder %> <% end %> - <p><%= link_to_add_fields l(:add_another_author), f, :authors %></p> + <p><%= link_to_add_fields l(:add_another_author), f, :authorships %></p> <h3>Other Details</h3> - <% f.fields_for :bibtex_entry do |builder| -%> <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> <%- end -%>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Jun 24 15:11:30 2011 +0100 @@ -4,10 +4,17 @@ <h4>Title</h4> <%= h @publication.title %> -<h4>Authors</h4> - <% for author in @publication.authors %> - <%= h author.name %> <br /> +<h4><%= l(:authors) %></h4> +<ul id="authorships"> + <% for authorship in @publication.authorships %> + <% content_tag_for :li, authorship do %> + <%= h authorship.name_on_paper %> <br /> + <%= h authorship.institution %> <br /> + <% end %> <% end %> +</ul> +<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_authors }) %> + <br /> <%- if @publication.bibtex_entry != nil -%>
--- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Jun 24 15:11:30 2011 +0100 @@ -8,15 +8,22 @@ add_me_as_author: "Add me as an author" add_another_author: "Add another author" - remove: "Remove" + remove_author: "Remove this author" label_publications_plural: "Publications" label_publication_new: "Add Publication" label_add_project_to_publication: "Add Project to Publication" label_project_search: "Search by name: " + text_institution: "Please insert the institution as it appears on the paper." + text_name_on_paper: "Please insert the name of the author as it appears on the paper." + + # authorships model + institution: "Institution" + naem_on_paper: "Name" + - # bibtex_entries strings + # bibtex_entries model id: "id" publication_id: "Publication_id" entry_type: "Entry Type"
--- a/vendor/plugins/redmine_bibliography/config/routes.rb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/routes.rb Fri Jun 24 15:11:30 2011 +0100 @@ -1,3 +1,3 @@ ActionController::Routing::Routes.draw do |map| - map.resources :publications + map.resources :publications, :collection => { :sort_authors => :post } end \ No newline at end of file