# HG changeset patch # User Chris Cannam # Date 1311685698 -3600 # Node ID 0058debf7871ce6d5240d057b9b2323e4c0e2f4a # Parent 7c7199e1f1744d4b8ee41fc816566d650a78bd49# Parent 76d064830472d12b55876e0a9bbf60c858296126 Merge from branch "feature_36" diff -r 7c7199e1f174 -r 0058debf7871 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Jul 25 15:00:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Jul 26 14:08:18 2011 +0100 @@ -21,14 +21,16 @@ def create @publication = Publication.new(params[:publication]) + + logger.error { "PUBLICATION CREATE ACTION" } + logger.error { params[:publication] } + + @project = Project.find(params[:project_id]) logger.error { "PARAMS publication" } logger.error { params[:publication] } - - # array with the user ids - @users = [] - + @publication.projects << @project if @publication.save diff -r 7c7199e1f174 -r 0058debf7871 vendor/plugins/redmine_bibliography/app/models/authorship.rb --- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb Mon Jul 25 15:00:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Tue Jul 26 14:08:18 2011 +0100 @@ -5,21 +5,23 @@ accepts_nested_attributes_for :author accepts_nested_attributes_for :publication - - # setter and getter for virtual attribute :author search - def author_search - end - def author_search=(string) - end - # setter and getter for virtual attribute :user_id def user_id end - def user_id=(uid) - if User.find(uid).author.nil? - User.find(uid).author = Author.new :name => User.find(uid).name + def user_id=(uid) + unless uid.blank? + user = User.find(uid) + if user.author.nil? + # TODO: should reflect the name_on_paper parameter + author = Author.new :name => user.name + author.save! + user.author = author + user.save! + end + + self.author_id = user.author.id end end end diff -r 7c7199e1f174 -r 0058debf7871 vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Mon Jul 25 15:00:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Tue Jul 26 14:08:18 2011 +0100 @@ -16,26 +16,4 @@ has_and_belongs_to_many :projects, :uniq => true - attr_writer :current_step - - def current_step - @current_step || steps.first - end - - def steps - %w[new review] - end - - def next_step - self.current_step = steps[steps.index(current_step)+1] - end - - def previous_step - self.current_step = steps[steps.index(current_step)-1] - end - - def first_step? - current_step == steps.first - end - end diff -r 7c7199e1f174 -r 0058debf7871 vendor/plugins/redmine_bibliography/app/views/my/blocks/_publications_box.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/my/blocks/_publications_box.html.erb Tue Jul 26 14:08:18 2011 +0100 @@ -0,0 +1,14 @@ +

<%=l(:label_my_publications_box)%> <%= "(" + User.current.author.authorships.count.to_s + ")" unless User.current.author.nil? %>

+ +<% Publication.find(:all).each do |pub|%> +
+

<%= link_to pub.title, pub %>

+ + <% pub.projects.each do |proj| %> + <%= link_to proj.name, proj %> + <% end %> + +
+<% end %> + + diff -r 7c7199e1f174 -r 0058debf7871 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Mon Jul 25 15:00:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Jul 26 14:08:18 2011 +0100 @@ -4,16 +4,9 @@ <%= f.text_field :name_on_paper %>
<%= h l("text_author_name_on_paper") %>
- <%= "Identify Authors in the system…" %> - <%= link_to_function "Add Me as Author", "update_author_info(this," + User.current.get_author_info.to_json + ")", :class => 'icon icon-add', :id => "add_me_as_author" %> -

- <%= f.label :author_search, l(:label_project_search) %> - <%= f.text_field :author_search %> -

- - <%= observe_field( form_tag_id(f.object_name, :author_search), :frequency => 0.5, :update => form_tag_id(f.object_name, :identify_author), :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, :with => 'q') + <%= observe_field( form_tag_id(f.object_name, :name_on_paper), :frequency => 0.5, :update => form_tag_id(f.object_name, :identify_author), :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, :with => 'q') %>
diff -r 7c7199e1f174 -r 0058debf7871 vendor/plugins/redmine_bibliography/config/locales/en.yml --- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Mon Jul 25 15:00:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Tue Jul 26 14:08:18 2011 +0100 @@ -4,6 +4,8 @@ authors: "Authors" author: "Author" name: "Name" + publications_box: "My Publications" + label_my_publications_box: "My Publications" label_add_me_as_author: "Add me as an author" label_add_another_author: "Add another author" @@ -17,7 +19,7 @@ text_author_email: "Author's email address as on the paper." text_author_institution: "Author's institution name as on paper." - text_author_name_on_paper: "Name of the author as it appears on paper." + text_author_name_on_paper: "Name of the author as it appears on paper. (In case it applies, please use the autocomplete suggestions.)" # authorships model institution: "Institution"