# HG changeset patch # User Chris Cannam # Date 1315582527 -3600 # Node ID ad6874c5c651442e6a4d5f2b7e244da25b4d68d6 # Parent 3c49c63173efa89a1a99f9327e000ec2f9fa0004# Parent 6246ad0f9e98b79d58d209233b4ddc886253dca0 Merge from branch "feature_36" diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Sep 09 16:35:27 2011 +0100 @@ -17,7 +17,7 @@ # and at least one author # @publication.authorships.build.build_author - @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] + @author_options = [["#{User.current.name} (@#{User.current.mail.partition('@')[2]})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] end @@ -25,7 +25,7 @@ def create @project = Project.find(params[:project_id]) - @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] + @author_options = [] @publication = Publication.new(params[:publication]) @publication.projects << @project unless @project.nil? @@ -75,19 +75,16 @@ @edit_view = true; - @options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] @publication = Publication.find(params[:id]) @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type - # todo: should be removed? - @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] + @author_options = [] end def update @publication = Publication.find(params[:id]) - # todo: should be removed? - @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] + @author_options = [] logger.error { "INSIDE THE UPDATE ACTION IN THE PUBLICATION CONTROLLER" } diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb Fri Sep 09 16:35:27 2011 +0100 @@ -13,14 +13,10 @@ projs = [] publication.projects.each do |proj| - projs << link_to(proj.name, proj) + projs << link_to(proj.name, proj) end - if projs.size < 3 - s << '' << projs.join(', ') << '' - else - s << projs.join(', ') - end + s << projs.join(', ') s end @@ -33,11 +29,8 @@ auths << h(auth.name_on_paper) end - if auths.size < 3 - s << '' << auths.join(', ') << '' - else - s << auths.join(', ') - end + s << auths.join(', ') + s end diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Sep 09 16:35:27 2011 +0100 @@ -23,7 +23,11 @@ @author_options = [] @results.each do |result| - @author_options << ["#{result.name} (#{result.mail})", "#{result.class.to_s}_#{result.id.to_s}"] + email_bit = result.mail.partition('@')[2] + if email_bit != "": + email_bit = "(@#{email_bit})" + end + @author_options << ["#{result.name} #{email_bit}", "#{result.class.to_s}_#{result.id.to_s}"] end if @results.size > 0 diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Sep 09 16:35:27 2011 +0100 @@ -17,6 +17,29 @@ has_and_belongs_to_many :projects, :uniq => true before_save :set_initial_author_order + after_save :notify_authors + + # Ensure error message uses proper text instead of + # bibtex_entry.entry_type (#268). There has to be a better way to + # do this! + def self.human_attribute_name(k) + if k == 'bibtex_entry.entry_type' + l(:field_entry_type) + else + super + end + end + + # Returns the mail adresses of users that should be notified + def notify_authors + + self.authors.each do |author| + Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." } + Mailer.deliver_publication_added(author.user, self) unless author.user.nil? + end + + end + def set_initial_author_order authorships = self.authorships diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.html.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.html.rhtml Fri Sep 09 16:35:27 2011 +0100 @@ -0,0 +1,3 @@ +<%= link_to(h(@publication.title), @publication_url) %>
+
+<%= textilizable(@publication, :title, :only_path => false) %> diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.plain.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.plain.rhtml Fri Sep 09 16:35:27 2011 +0100 @@ -0,0 +1,3 @@ +<%= @publication.title %> +<%= @publication_url %> + diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Fri Sep 09 16:35:27 2011 +0100 @@ -1,8 +1,26 @@ <% if @project.publications.any? %> -
-

<%=l(:label_publications_plural)%>

-

<% @project.publications.each do |publication| %> - <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication, :project_id => @project %>
- <% end %>

+<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> +
+
+

<%=l(:label_related_publication_plural)%>

+ +
+ <% @project.publications.each do |publication| %> +
+ <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication, :project_id => @project %> +
+
+ + <%= publication.authorships.map { |a| h a.name_on_paper }.join(', ') %> + + <% if publication.bibtex_entry.year.to_s != "" %> + + <%= publication.bibtex_entry.year %> + + <% end %> +
+ <% end -%> +
+
<% end %> diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Sep 09 16:35:27 2011 +0100 @@ -2,7 +2,7 @@
-

<%= l("label_author_1") %>

+
>

@@ -44,7 +44,14 @@

- <%= button_to_function l(:label_save_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> + + <% if params[:action] == 'new' %> + <%= button_to_function l(:label_save_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> + <% else %> +<%= button_to_function l(:label_edit_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> + + <% end %> + <%= link_to_remove_fields l("remove_author"), f %>

diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Fri Sep 09 16:35:27 2011 +0100 @@ -8,6 +8,13 @@ <% f.fields_for :bibtex_entry do |builder| -%> <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> <%- end -%> + +

+ <%= f.text_field :external_url, :size => 70 %> +
+ <%= l(:text_external_url) %> +

+
diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Fri Sep 09 16:35:27 2011 +0100 @@ -1,5 +1,7 @@ -
- <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> +
+ <% if User.current.allowed_to?(:add_publication, @project) %> + <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> + <% end %>
<% if @project %> diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Sep 09 16:35:27 2011 +0100 @@ -26,13 +26,23 @@ <%= show_bibtex_fields(@publication.bibtex_entry) %> <%- end -%> + +<% unless @publication.external_url.blank? %> +

+ <%= l(:field_external_url) %> +

+

+ <%= link_to h(@publication.external_url), @publication.external_url, {:target => "_blank"} %> +

+<% end %> +
<% if User.current.allowed_to?(:add_publication, @project) %> <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> | <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project }, :confirm => l(:text_are_you_sure), :method => :delete, :title => l(:button_delete) %> | <% end %> - <%= link_to l(:view_all_publications), publications_path %> + <%= link_to l(:view_all_publications), {:controller => 'publications', :action => 'index', :project_id => @project } %>
<% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %> diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/assets/stylesheets/bibliography.css --- a/vendor/plugins/redmine_bibliography/assets/stylesheets/bibliography.css Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/stylesheets/bibliography.css Fri Sep 09 16:35:27 2011 +0100 @@ -27,3 +27,19 @@ .publication_project { margin-right: 18px; } + +#authors select { + min-width: 150px; +} + +div#bibliography dl { margin-left: 2em; } +div#bibliography .box dl { margin-left: 0; } +div#bibliography dt { margin-bottom: 0px; padding-left: 20px } +div#bibliography .box dt { margin-bottom: 0px; padding-left: 10px } +div#bibliography dd { margin-bottom: 1em; padding-left: 18px; font-size: 0.9em; } +div#bibliography .box dd { margin-bottom: 0.6em; padding-left: 0; } +div#bibliography dd .authors { font-style: italic; } +div#bibliography dd span.authors { color: #808080; } +div#bibliography dd span.year { padding-left: 0.6em; } + +div#bibliography h3 { background: url(../../../images/table_multiple.png) no-repeat 0% 50%; padding-left: 20px; } diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/config/locales/en.yml --- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Sep 09 16:35:27 2011 +0100 @@ -24,17 +24,17 @@ field_authorship_email: "Email Address" field_authorship_institution: "Institution" + field_external_url: "External URL" field_publication_title: Title field_publication_authors: Authors - field_publication_projects: "Associated Projects" + field_publication_projects: "Associated projects" field_author_name: Author field_author_user: User Name - field_author_username: "Associated User" + field_author_username: "Associated user" field_author_publications: "Publications by this Author" field_identify_author_yes: "Yes" field_identify_author_correct: "Corrections" field_identify_author_no: "No" - entry_type: "Bibtex Entry Type" label_author_is_me: "(I am this author)" label_add_me_as_author: "Add me as an author" @@ -43,11 +43,13 @@ field_search_name: "Search by name" field_search_results: "" label_save_author: "Save author" + label_edit_author: "Edit author" label_author_information: "Author Information" remove_author: "Remove this author" - label_publications_plural: "Publications" + label_publication_plural: "Publications" + label_related_publication_plural: "Related publications" label_publication_new: "Create New Publication" label_publication_index: "List of Publication" label_add_publication_to_project: "Add publication to this project" @@ -59,6 +61,7 @@ label_publication_index: "View all publications" label_publication_other_details: "Details" + text_external_url: "Link to the publication or to an external page about it." text_author_name_on_paper: "Author's name as it appears on the paper." text_author_institution: "Author's institution as on the paper." text_author_email: "Author's email address as on the paper." diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/db/migrate/007_add_external_url_column_to_publications.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/007_add_external_url_column_to_publications.rb Fri Sep 09 16:35:27 2011 +0100 @@ -0,0 +1,9 @@ +class AddExternalUrlColumnToPublications < ActiveRecord::Migration + def self.up + add_column :publications, :external_url, :string + end + + def self.down + remove_column :publications, :external_url + end +end diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/init.rb --- a/vendor/plugins/redmine_bibliography/init.rb Fri Sep 09 16:35:12 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/init.rb Fri Sep 09 16:35:27 2011 +0100 @@ -7,6 +7,7 @@ Dispatcher.to_prepare :redmine_model_dependencies do require_dependency 'project' require_dependency 'user' + require_dependency 'mailer' unless Project.included_modules.include? Bibliography::ProjectPublicationsPatch Project.send(:include, Bibliography::ProjectPublicationsPatch) @@ -15,6 +16,12 @@ unless User.included_modules.include? Bibliography::UserAuthorPatch User.send(:include, Bibliography::UserAuthorPatch) end + + unless Mailer.included_modules.include? Bibliography::MailerPatch + Mailer.send(:include, Bibliography::MailerPatch) + end + + end diff -r 3c49c63173ef -r ad6874c5c651 vendor/plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb Fri Sep 09 16:35:27 2011 +0100 @@ -0,0 +1,28 @@ +require_dependency 'mailer' + +module Bibliography + module MailerPatch + def self.included(base) # :nodoc: + + # Builds a tmail object used to email the specified user that a publication was created and the user is + # an author of that publication + # + # Example: + # publication_added(user) => tmail object + # Mailer.deliver_add_to_project(user) => sends an email to the registered user + def publication_added(user, publication) + + @publication = publication + + set_language_if_valid user.language + recipients user.mail + subject l(:mail_subject_publication_added, Setting.app_title) + body :publication_url => url_for( :controller => 'publications', :action => 'show', :id => publication.id ), + :publication_title => publication.title + render_multipart('publication_added', body) + end + + + end + end +end