里程碑中增加创建者、项目私有公开显示特性

This commit is contained in:
huang 2016-10-28 14:20:00 +08:00
parent 58da3924ab
commit d2138dd872
11 changed files with 38 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -8,7 +8,7 @@
<div class="pro_new_top clear mb10">
<div class="fl pro_new_name ml15">
<span class="icons_newpro_lock"></span>
<% unless @project.is_public? %><span class="icons_newpro_lock"></span><% end %>
<%=link_to "#{@project.owner.try(:show_name)}<span class='ml5 mr5'>/</span>".html_safe, user_path(@project.owner), :class => "pro_new_username" %>
<%=link_to @project.name, project_path(@project), :class => "pro_new_proname" %>
</div>

View File

@ -80,7 +80,7 @@
<% memo = Memo.where(:id => 1232).first %>
<% unless memo.nil? %>
<a href="<%= Setting.protocol + "://" %><%=Setting.host_name %>/forums/1/memos/1232" >如何提交代码</a>
<a href="<%= Setting.protocol + "://" %><%=Setting.host_name %>/forums/1/memos/1232" class="linkBlue2">如何提交代码</a>
<% end %>
<% unless @entries.blank? %>
<div class="fr">

View File

@ -25,6 +25,15 @@
<div class="c_grey">
<p><%= version.description %></p>
</div>
<div class="c_grey clear mt5">
<% if version.user_id.nil? %>
<p class="fl">创建时间:<%= format_time(version.updated_on) %> </p>
<span class="fl ml10">更新时间:<%= format_time(version.created_on) %></span>
<% else %>
<p class="fl">由 <%= link_to version.user.show_name, user_path(version.user), :class => "linkBlue2" %>于 <%= format_time(version.updated_on) %> 创建</p>
<span class="fl ml10">最近更新:<%= format_time(version.created_on) %></span>
<% end %>
</div>
</div>
<% end %>

View File

@ -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 }) %>

View File

@ -27,6 +27,15 @@
<div class="c_grey02">
<p><%= @version.description %></p>
</div>
<div class="c_grey clear mt5">
<% if @version.user_id.nil? %>
<p class="fl">创建时间:<%= format_time(@version.updated_on) %> </p>
<span class="fl ml10">更新时间:<%= format_time(@version.created_on) %></span>
<% else %>
<p class="fl">由 <%= link_to @version.user.show_name, user_path(@version.user), :class => "linkBlue2" %>于 <%= format_time(@version.updated_on) %> 创建</p>
<span class="fl ml10">最近更新:<%= format_time(@version.created_on) %></span>
<% end %>
</div>
</div>
</div>
<div class="new_roadmap_conbox mb10" >

View File

@ -0,0 +1,5 @@
class AddUserIdToVersions < ActiveRecord::Migration
def change
add_column :versions, :user_id, :integer
end
end

View File

@ -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"

View File

@ -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;}