Mercurial > hg > soundsoftware-site
changeset 1080:5bd8c86cfa6a issue_540
Makes the Publication model act as an activity; overloading the default ActivitiesController#index view in the Bibliography Plugin in order to differentiate Publications from the other event types.
* Known issues:
** route to /activities is not working (only to /activity);
** publication cache needs to be implemented in the model, not in the helper;
** when a publication is added to n projects, n events are created (all with the same content).
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Thu, 22 Nov 2012 16:51:23 +0000 |
parents | 3af6f66496a5 |
children | 74407a04925c |
files | vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/app/views/activities/index.html.erb vendor/plugins/redmine_bibliography/init.rb |
diffstat | 3 files changed, 111 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Wed Nov 21 15:58:12 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Thu Nov 22 16:51:23 2012 +0000 @@ -19,6 +19,21 @@ before_save :set_initial_author_order + acts_as_activity_provider :type => 'publication', + :timestamp => "#{Publication.table_name}.created_at", + :author_key => "#{Publication.table_name}.builder_id", + :find_options => {:joins => "INNER JOIN projects_publications ON #{Publication.table_name}.id = projects_publications.publication_id JOIN #{Project.table_name} ON #{Project.table_name}.id = projects_publications.project_id"} + + acts_as_event :title => Proc.new {|o| o.title }, + :datetime => :created_at, + :author => nil, + :type => 'publications', + #todo - need too move the cache from the helper to the model + :description => Proc.new {|o| o.print_entry(:ieee)}, + :project => Project.first + # :url => Proc.new {|o| {:controller => 'publications', :action => 'show', :id => o.id }} + + # Ensure error message uses proper text instead of # bibtex_entry.entry_type (#268). There has to be a better way to # do this!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/activities/index.html.erb Thu Nov 22 16:51:23 2012 +0000 @@ -0,0 +1,91 @@ +<h2><%= + if @author.nil? + if @institution_name.blank? + l(:label_activity) + else + l(:label_institution_activity, h(@institution_name)) + end + else + l(:label_user_activity, link_to_user(@author)) + end + %></h2> +<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p> + +<div id="activity"> +<% @events_by_day.keys.sort.reverse.each do |day| %> +<h3><%= format_activity_day(day) %></h3> +<dl> +<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> + <%- if e.class != Publication -%> + <dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>"> + <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %> + <span class="time"><%= format_time(e.event_datetime, false) %></span> + <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> + <%= link_to format_activity_title(e.event_title), e.event_url %> + </dt> + <dd> + <span class="description"><%= format_activity_description(e.event_description) %></span> + <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span> + </dd> + <%- else -%> + <dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>"> + <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %> + <span class="time"><%= format_time(e.event_datetime, false) %></span> + <%= link_to format_activity_title(e.event_title), e.event_url %> + was added to the following + <% if e.projects.count > 1 %> + projects: + <%- else -%> + project: + <%- end -%> + <%= content_tag('span', e.projects.join(', ')) -%> + </dt> + <dd> + <span class="description"><%= e.event_description -%></span> + <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span> + </dd> + <% end -%> +<%- end -%> +</dl> +<% end -%> +</div> + +<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %> + +<div style="float:left;"> +<%= link_to_content_update("\xc2\xab " + l(:label_previous), + params.merge(:from => @date_to - @days - 1), + :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))) %> +</div> +<div style="float:right;"> +<%= link_to_content_update(l(:label_next) + " \xc2\xbb", + params.merge(:from => @date_to + @days - 1), + :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to >= Date.today %> +</div> + +<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %> +<% end %> + +<% content_for :header_tags do %> +<%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %> +<% end %> + +<% content_for :sidebar do %> +<% form_tag({}, :method => :get) do %> +<h3><%= l(:label_activity) %></h3> +<p><% @activity.event_types.each do |t| %> +<%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> +<label for="show_<%=t%>"><%= link_to(l("label_#{t.singularize}_plural"), {"show_#{t}" => 1, :user_id => params[:user_id]})%></label> +<br /> +<% end %></p> +<% if @project && @project.descendants.active.any? %> + <%= hidden_field_tag 'with_subprojects', 0 %> + <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p> +<% end %> +<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %> +<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> +<% end %> +<% end %> + +<% html_title(l(:label_activity), @author) -%>
--- a/vendor/plugins/redmine_bibliography/init.rb Wed Nov 21 15:58:12 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/init.rb Thu Nov 22 16:51:23 2012 +0000 @@ -51,4 +51,9 @@ menu :project_menu, :publications, { :controller => 'publications', :action => 'index', :path => nil }, :after => :activity, :param => :project_id, :caption => Proc.new { Setting.plugin_redmine_bibliography['menu'] }, :if => Proc.new { !Setting.plugin_redmine_bibliography['menu'].blank? } + activity_provider :publication, :class_name => 'Publication', :default => true + end + + +