diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index cf63cfbf8..ed9c4638f 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -169,6 +169,7 @@ class VersionsController < ApplicationController attributes = params[:version].dup attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) @version.safe_attributes = attributes + @version.user_id = User.current.id end if request.post? if @version.save diff --git a/app/models/user.rb b/app/models/user.rb index 35d0e7a6b..9c0b89b7a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -124,6 +124,7 @@ class User < Principal has_one :api_token, :class_name => 'Token', :conditions => "action='api'" belongs_to :auth_source has_many :org_members + has_many :versions, :dependent => :destroy has_many :organizations, :through => :org_members belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang ## added by xianbo for delete diff --git a/app/models/version.rb b/app/models/version.rb index 0e11371ad..4b6b5f98e 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -19,6 +19,7 @@ class Version < ActiveRecord::Base include Redmine::SafeAttributes after_update :update_issues_from_sharing_change belongs_to :project + belongs_to :user has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify acts_as_customizable acts_as_attachable :view_permission => :view_files, @@ -47,7 +48,8 @@ class Version < ActiveRecord::Base 'wiki_page_title', 'status', 'sharing', - 'custom_field_values' + 'custom_field_values', + 'user_id' # Returns true if +user+ or current user is allowed to view the version def visible?(user=User.current) diff --git a/app/views/layouts/_base_project_top.html.erb b/app/views/layouts/_base_project_top.html.erb index 18943e844..abb5fa291 100644 --- a/app/views/layouts/_base_project_top.html.erb +++ b/app/views/layouts/_base_project_top.html.erb @@ -8,7 +8,7 @@
- + <% unless @project.is_public? %><% end %> <%=link_to "#{@project.owner.try(:show_name)}/".html_safe, user_path(@project.owner), :class => "pro_new_username" %> <%=link_to @project.name, project_path(@project), :class => "pro_new_proname" %>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 90ad0e7f4..f7f0f8f81 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -80,7 +80,7 @@ <% memo = Memo.where(:id => 1232).first %> <% unless memo.nil? %> - <%=Setting.host_name %>/forums/1/memos/1232" >如何提交代码 + <%=Setting.host_name %>/forums/1/memos/1232" class="linkBlue2">如何提交代码 <% end %> <% unless @entries.blank? %>
diff --git a/app/views/versions/_list.html.erb b/app/views/versions/_list.html.erb index 55cc53f3b..9ad6f5648 100644 --- a/app/views/versions/_list.html.erb +++ b/app/views/versions/_list.html.erb @@ -25,6 +25,15 @@

<%= version.description %>

+
+ <% if version.user_id.nil? %> +

创建时间:<%= format_time(version.updated_on) %>

+ 更新时间:<%= format_time(version.created_on) %> + <% else %> +

由 <%= link_to version.user.show_name, user_path(version.user), :class => "linkBlue2" %>于 <%= format_time(version.updated_on) %> 创建

+ 最近更新:<%= format_time(version.created_on) %> + <% end %> +
<% end %> diff --git a/app/views/versions/_overview.html.erb b/app/views/versions/_overview.html.erb index 302cdbab9..792a6fcd6 100644 --- a/app/views/versions/_overview.html.erb +++ b/app/views/versions/_overview.html.erb @@ -13,12 +13,9 @@ { :onchange =>"remote_function('#version-#{@version.id}-status-form');", :id =>"status", :name => "status",:class=>"fr new_roadmap_select"}) %> <% end %> <%#= link_to "", {:controller => "versions", :action => "destroy", :project_id => @version.project_id}, :data => {:confirm => l(:text_are_you_sure_version)}, :class => "roadmap_icons_del fr mt5 mr5" if User.current.allowed_to?(:manage_versions, version.project) %> -<%= link_to "", version_path(version, :is_show => true), :method => "delete", :data => {:confirm => l(:text_are_you_sure_version)},:onclick => "confirm_can_delte", :class => "roadmap_icons_del fr mt5 mr5" if User.current.allowed_to?(:manage_versions, version.project) %> -<% if params[:action] == "index" %> - <%= link_to( "", edit_version_path(@version, :is_index => true), :class => 'roadmap_icons_edit fr mt5', :remote => true) if User.current.allowed_to?(:manage_versions, @version.project) %> -<% else %> - <%= link_to( "", edit_version_path(@version, :is_create => true), :class => 'roadmap_icons_edit fr mt5', :remote => true) if User.current.allowed_to?(:manage_versions, @version.project) %> -<% end %> +<%= link_to "", version_path(version, :is_show => true), :method => "delete", :data => {:confirm => l(:text_are_you_sure_version)}, :onclick => "confirm_can_delte", :class => "roadmap_icons_del_show fr mt5 mr5" if User.current.allowed_to?(:manage_versions, version.project) %> +<%= link_to( "", edit_version_path(@version, :is_create => true), :class => 'roadmap_icons_edit_show fr mt5', :remote => true) if User.current.allowed_to?(:manage_versions, @version.project) %> + <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %> diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb index 3313585ab..beafc0456 100644 --- a/app/views/versions/show.html.erb +++ b/app/views/versions/show.html.erb @@ -27,6 +27,15 @@

<%= @version.description %>

+
+ <% if @version.user_id.nil? %> +

创建时间:<%= format_time(@version.updated_on) %>

+ 更新时间:<%= format_time(@version.created_on) %> + <% else %> +

由 <%= link_to @version.user.show_name, user_path(@version.user), :class => "linkBlue2" %>于 <%= format_time(@version.updated_on) %> 创建

+ 最近更新:<%= format_time(@version.created_on) %> + <% end %> +
diff --git a/db/migrate/20161028053000_add_user_id_to_versions.rb b/db/migrate/20161028053000_add_user_id_to_versions.rb new file mode 100644 index 000000000..8c0c28b69 --- /dev/null +++ b/db/migrate/20161028053000_add_user_id_to_versions.rb @@ -0,0 +1,5 @@ +class AddUserIdToVersions < ActiveRecord::Migration + def change + add_column :versions, :user_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 65ec42b02..ffb4cc9a8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20161019020422) do +ActiveRecord::Schema.define(:version => 20161028053000) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -2248,6 +2248,7 @@ ActiveRecord::Schema.define(:version => 20161019020422) do t.string "wiki_page_title" t.string "status", :default => "open" t.string "sharing", :default => "none", :null => false + t.integer "user_id" end add_index "versions", ["project_id"], :name => "versions_project_id" diff --git a/public/stylesheets/css/project.css b/public/stylesheets/css/project.css index 2d0c14fb5..477cc6fcd 100644 --- a/public/stylesheets/css/project.css +++ b/public/stylesheets/css/project.css @@ -853,7 +853,7 @@ input.pro_newissue_con_check{ width: 15px; height: 15px;} /* 新版项目头部*/ .pro_new_top {padding-top:15px; border:1px solid #ddd; background-color:#fff; width: 998px;} -.icons_newpro_lock{width: 22px; height: 23px; display: inline-block; background: url("../images/project/icons_issue.png") 0 -113px no-repeat;} +.icons_newpro_lock{width: 22px; height: 23px; display: inline-block; background: url("/images/new_project/icons_issue.png") 0 -113px no-repeat;} .pro_new_name{width: 600px; } .pro_new_name a { font-size: 24px; color: #3b94d6; line-height: 24px;} .pro_new_name a:hover{ color: #2783c7;} @@ -952,6 +952,8 @@ p.pro_new_grey{ line-height: 1.9; } .roadmap_greyicon{ background: url(/images/new_project/icons_issue.png) 0 -198px no-repeat; display: inline-block; width: 32px; height: 16px;} .roadmap_icons_edit{ display: inline-block; padding:9px;} .roadmap_icons_del{ display: inline-block;padding:9px;} +.roadmap_icons_edit_show{ display: inline-block; padding:9px;background:url(/images/new_project/icons_issue.png) -29px -227px no-repeat; } +.roadmap_icons_del_show{ display: inline-block;padding:9px;background:url(/images/new_project/icons_issue.png) -29px -249px no-repeat;} .roadmap_icons_edit:hover{ background:url(/images/new_project/icons_issue.png) -29px -227px no-repeat; } .roadmap_icons_del:hover{ background:url(/images/new_project/icons_issue.png) -29px -249px no-repeat;} select.new_roadmap_select{border:1px solid #dbdbdb; color: #666;}