Merge branch 'dev_newproject' of https://git.trustie.net/jacknudt/trustieforge into dev_newproject

This commit is contained in:
daiao 2016-10-12 16:28:02 +08:00
commit b925ee312e
7 changed files with 178 additions and 156 deletions

View File

@ -362,9 +362,8 @@ class ProjectsController < ApplicationController
# 修改查看消息状态
applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0)
applied_messages.each do |applied_message|
applied_message.update_attributes(:viewed => true)
end
applied_messages.update_all(:viewed => true)
# end
@issue_custom_fields = IssueCustomField.sorted.all
@issue_category ||= IssueCategory.new
@ -398,6 +397,12 @@ class ProjectsController < ApplicationController
flash.now[:error] = html if !html.to_s.blank?
end
# for设置默认分支
@gitlab_repository = Repository.where(:project_id => @project, :type => "Repository::Gitlab").first
unless @gitlab_repository.nil?
gitlab_address = Redmine::Configuration['gitlab_address']
@repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git"
end
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?

View File

@ -1,8 +1,8 @@
<a href="javascript:void(0)" class="upimg fl">
<%= image_tag(url_to_avatar(source), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
<a href="javascript:void(0)">
<%= image_tag(url_to_avatar(source), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片", :class => "fl ml5 pro_new_upimg")%>
</a>
<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "upbtn fl" %>
<a href="javascript:void(0)" class="upbtn fl" onclick="$('#upload_course_logo').click();"><%= l(:button_upload_photo) %></a>
<a href="javascript:void(0)" class="sub_btn fl mt35 ml5" style="line-height: 1.5" onclick="$('#upload_course_logo').click();"><%= l(:button_upload_photo) %></a>
<%= file_field_tag 'avatar[image]',
:id => 'upload_course_logo',
:class => 'undis upload_file',

View File

@ -1,3 +1,61 @@
<div class="pro_new_setting clear mb10">
<div class="pro_new_setting_leftnav fl">
<ul>
<% show_memu = show_project_memu User.current%>
<% if User.current.allowed_to?(:edit_project, @project) %>
<li><a id="pro_st_tb_1" class="<%= show_memu == 'edit_project' ? 'active' : ''%>" onclick="project_setting(1);">信息</a></li>
<% end %>
<% if User.current.allowed_to?(:select_project_modules, @project) %>
<li><a id="pro_st_tb_2" class="<%= show_memu == 'select_project_modules' ? 'active' : ''%>" onclick="project_setting(2);">模块</a></li>
<% end %>
<% if User.current.allowed_to?(:manage_members, @project) %>
<li><a id="pro_st_tb_3" class="<%= show_memu == 'manage_members' ? 'active' : ''%>" onclick="project_setting(3);">成员</a></li>
<% end %>
<li><a id="pro_st_tb_5" class="<%= show_memu == 'join_org' ? 'active' : ''%>" onclick="project_setting(5);">组织</a></li>
<% if User.current.allowed_to?(:manage_versions, @project) %>
<li><a id="pro_st_tb_4" class="<%= show_memu == 'manage_versions' ? 'active' : ''%>" onclick="project_setting(4);"><%= l(:milestone) %></a></li>
<% end %>
<!--<li id="pro_st_tb_5" class="pro_st_normaltab" onclick="project_setting(5);">问题类别</li>-->
<% if User.current.allowed_to?(:manage_repository, @project) %>
<li><a id="pro_st_tb_6" class="<%= show_memu == 'manage_repository' ? 'active' : ''%>" onclick="project_setting(6);">版本库</a></li>
<% end %>
<!--<li id="pro_st_tb_7" class="pro_st_normaltab" onclick="project_setting(7);">活动(时间跟踪)</li>-->
<!--<li id="pro_st_tb_8" class="pro_st_normaltab" onclick="project_setting(8);">代码评审</li>-->
</ul>
</div>
<div class="pro_new_setting_conbox fl ml10">
<div class="">
<div class="<%= show_memu == 'edit_project' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_01">
<%= render :partial=>"projects/settings/new_edit" if User.current.allowed_to?(:edit_project, @project)%>
</div><!--tbc_01 end-->
<div class="<%= show_memu == 'select_project_modules' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_02">
<%= render :partial=>"projects/settings/new_modules" if User.current.allowed_to?(:select_project_modules, @project)%>
</div><!--tbc_02 end-->
<div class="<%= show_memu == 'manage_members' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_03">
<%= render :partial=>"projects/settings/new_members" if User.current.allowed_to?(:manage_members, @project)%>
</div><!--tbc_03 end-->
<div class="<%= show_memu == 'manage_versions' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_04">
<%= render :partial=>"projects/settings/new_versions" if User.current.allowed_to?(:manage_versions, @project)%>
</div><!--tbc_04 end-->
<!--<div class="pro_st_undis" id="pro_st_tbc_05">-->
<!--<%#= render :partial=>"projects/settings/new_issue_categories" %>-->
<!--</div>&lt;!&ndash;tbc_05 end&ndash;&gt;-->
<div class="<%= show_memu == 'join_org' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_05">
<%= render :partial=>"projects/settings/join_org" %>
</div>
<div class="<%= show_memu == 'manage_repository' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_06">
<%= render :partial=>"projects/settings/new_repositories" if User.current.allowed_to?(:manage_repository, @project)%>
</div><!--tbc_06 end-->
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
<%if @select_tab %>
@ -16,112 +74,12 @@
<% end%>
<% end%>
$("div[nhname='pro_setting']").show();
$(".project_r_h").parent().css({"width":"730px","background-color":"#fff","padding":"10px","margin-left":"10px","margin-bottom":"10px"});
// $(".project_r_h").parent().css({"width":"730px","background-color":"#fff","padding":"10px","margin-left":"10px","margin-bottom":"10px"});
});
var windowH = $(window).height();
var contentH = $(".pro_new_setting_conbox").height();
if(windowH >795.5) {
$(".pro_new_setting_conbox").css("margin-bottom",windowH - 329 -contentH + "px");
}
</script>
<div class="project_r_h" style="width:730px;">
<h2 class="project_h2">配置</h2>
</div>
<!--通过admin界面配置不同角色显示不同的模块-->
<div nhname="pro_setting" style="display:none; width:730px;">
<div id="pro_st_tb_" class="pro_st_tb_">
<ul>
<% show_memu = show_project_memu User.current%>
<% if User.current.allowed_to?(:edit_project, @project) %>
<li id="pro_st_tb_1" class="<%= show_memu == 'edit_project' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(1);">信息</li>
<% end %>
<% if User.current.allowed_to?(:select_project_modules, @project) %>
<li id="pro_st_tb_2" class="<%= show_memu == 'select_project_modules' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(2);">模块</li>
<% end %>
<% if User.current.allowed_to?(:manage_members, @project) %>
<li id="pro_st_tb_3" class="<%= show_memu == 'manage_members' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(3);">成员</li>
<% end %>
<li id="pro_st_tb_5" class="<%= show_memu == 'join_org' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(5);">组织</li>
<% if User.current.allowed_to?(:manage_versions, @project) %>
<li id="pro_st_tb_4" class="<%= show_memu == 'manage_versions' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(4);"><%= l(:milestone) %></li>
<% end %>
<!--<li id="pro_st_tb_5" class="pro_st_normaltab" onclick="project_setting(5);">问题类别</li>-->
<% if User.current.allowed_to?(:manage_repository, @project) %>
<li id="pro_st_tb_6" class="<%= show_memu == 'manage_repository' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(6);">版本库</li>
<% end %>
<!--<li id="pro_st_tb_7" class="pro_st_normaltab" onclick="project_setting(7);">活动(时间跟踪)</li>-->
<!--<li id="pro_st_tb_8" class="pro_st_normaltab" onclick="project_setting(8);">代码评审</li>-->
</ul>
</div><!--tb_ end-->
<div class="cl"></div>
<div class="pro_st_ctt">
<div class="<%= show_memu == 'edit_project' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_01">
<%= render :partial=>"projects/settings/new_edit" if User.current.allowed_to?(:edit_project, @project)%>
</div><!--tbc_01 end-->
<div class="<%= show_memu == 'select_project_modules' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_02">
<%= render :partial=>"projects/settings/new_modules" if User.current.allowed_to?(:select_project_modules, @project)%>
</div><!--tbc_02 end-->
<div class="<%= show_memu == 'manage_members' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_03">
<%= render :partial=>"projects/settings/new_members" if User.current.allowed_to?(:manage_members, @project)%>
</div><!--tbc_03 end-->
<div class="<%= show_memu == 'manage_versions' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_04">
<%= render :partial=>"projects/settings/new_versions" if User.current.allowed_to?(:manage_versions, @project)%>
</div><!--tbc_04 end-->
<!--<div class="pro_st_undis" id="pro_st_tbc_05">-->
<!--<%#= render :partial=>"projects/settings/new_issue_categories" %>-->
<!--</div>&lt;!&ndash;tbc_05 end&ndash;&gt;-->
<div class="<%= show_memu == 'join_org' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_05">
<%= render :partial=>"projects/settings/join_org" %>
</div>
<div class="<%= show_memu == 'manage_repository' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_06">
<%= render :partial=>"projects/settings/new_repositories" if User.current.allowed_to?(:manage_repository, @project)%>
</div><!--tbc_06 end-->
<!--<div class="pro_st_undis" id="pro_st_tbc_07">-->
<!--<%#= render :partial=>"projects/settings/new_activities" %>-->
<!--</div>&lt;!&ndash;tbc_07 end&ndash;&gt;-->
<!--代码评审先不做-->
<!--<div class="pro_st_undis" id="pro_st_tbc_08">-->
<!--<div class="box f14">-->
<!--<ul>-->
<!--<li><label for="setting_tracker_in_review_dialog">允许创建代码审查时选择跟踪者?<span class="required">&nbsp;&nbsp;</span></label></li>-->
<!--<li><b>设置代码评审的默认跟踪标签:</b></li>-->
<!--<li><label for="setting_tracker_id">跟踪<span class="c_red"> *</span></label>-->
<!--<select id="setting_tracker_id" name="setting[tracker_id]">-->
<!--<option value="1" selected="selected">缺陷</option>-->
<!--<option value="2">功能</option>-->
<!--<option value="3">支持</option>-->
<!--<option value="4">任务</option>-->
<!--</select></li>-->
<!--<li>-->
<!--<label for="setting_hide_code_review_tab">隐藏代码评审页<span class="required">&nbsp;&nbsp;</span></label>-->
<!--<input name="setting[hide_code_review_tab]" type="hidden" value="0"><input id="setting_hide_code_review_tab" name="setting[hide_code_review_tab]" type="checkbox" value="1">-->
<!--</li>-->
<!--<li>-->
<!--<label>若修订存在问题:</label>-->
<!--<input checked="checked" id="setting_auto_relation_1" name="setting[auto_relation]" type="radio" value="1">-->
<!--与之相关的评审问题-->
<!--<input id="setting_auto_relation_2" name="setting[auto_relation]" type="radio" value="2">-->
<!--与之无关的评审问题-->
<!--<input id="setting_auto_relation_0" name="setting[auto_relation]" type="radio" value="0">-->
<!--什么也不做-->
<!--</li>-->
<!--<li>-->
<!--<label>自动分派</label>-->
<!--<input id="auto_assign_enabled" name="auto_assign[enabled]" onchange="setAutoAssignSettingFormEnable();" type="checkbox" value="true">激活-->
<!--</li>-->
<!--</ul>-->
<!--<a href="javascript:viod(0)" class="blue_btn">保存</a>-->
<!--</div>-->
<!--</div>&lt;!&ndash;tbc_08 end&ndash;&gt;-->
</div><!--ctt end-->
</div><!--pro_setting end-->

View File

@ -1,49 +1,42 @@
<%= error_messages_for 'project' %>
<%= labelled_form_for @project do |f| %>
<ul class="newpro_box ">
<li class="ml45 mb10" id="project_avatar_form">
<%= render :partial=>"avatar/new_avatar_form",:locals=> {source:@project} %>
</li>
<li >
<label class="label02"><span class="c_red">*</span>&nbsp;项目名称&nbsp;&nbsp;</label>
<!--<input id="project_name" name="project[name]" class=" w543" type="text" value="<%#= @project.name%>">-->
<input type="text" name="project[name]" id="project_name" class="w543" maxlength="100" onkeyup="regex_project_name();" value="<%= @project.name %>">
<span class="c_red ml110" id="project_name_notice" style="display: none;">项目名称不能为空!</span>
</li>
<div class="cl"></div>
<li >
<label class="label02" >&nbsp;&nbsp;项目描述&nbsp;&nbsp;</label>
<textarea class="w543" id="project_description" name="project[description]" rows="8" placeholder="最多3000个汉字(或6000个英文字符)"><%= @project.description%></textarea>
<div class="cl"></div>
</li>
<% if !@project.gpid.nil? && !@gitlab_branches.blank? %>
<li>
<label class="label02">&nbsp;默认分支&nbsp;&nbsp;</label>
<%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch' %>
<ul class="pro_newsetting_con mb15">
<li class="clear mb10" id="project_avatar_form">
<label class="label fl">&nbsp;&nbsp;</label>
<%= render :partial=>"avatar/new_avatar_form",:locals=> {source:@project} %>
</li>
<li class="mb10">
<label class="label"><span class="c_red f12">*</span>&nbsp;项目名称&nbsp;&nbsp;:&nbsp;</label>
<input type="text" name="project[name]" id="project_name" class="ml5 w690" maxlength="100" onkeyup="regex_project_name();" value="<%= @project.name %>">
<span class="c_red ml5 fl" id="project_name_notice" style="display: none;">项目名称不能为空!</span>
</li>
<li class="clear mb10">
<label class="label fl">&nbsp;项目描述&nbsp;&nbsp;:&nbsp;</label>
<textarea class="fl ml5 w690" style="height:192px; padding-top:5px;" id="project_description" name="project[description]" rows="8" placeholder="项目描述作为项目的简介,将始终显示在动态页的顶部
最多3000个汉字或6000个英文字符"><%= @project.description%></textarea>
</li>
<% if !@project.gpid.nil? && !@gitlab_branches.blank? %>
<li class="clear">
<label class="fl">&nbsp;默认分支&nbsp;&nbsp;</label>
<%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch', :class => "ml5" %>
</li>
<% end %>
<li class="clear">
<label class="fl">公开&nbsp;&nbsp;</label>
<input class="fl ml5" id="project_is_public" name="project[is_public]" type="checkbox" <%= @project.is_public ? "checked" : ""%>>
<span class="fl c_grey ">(打钩为公开项目,不打钩为私有项目;私有项目仅项目成员可见。)</span>
</li>
<li class="clear mb10">
<label class="fl ">隐藏代码库&nbsp;&nbsp;</label>
<input class="fl ml5" id="project_hidden_repo" name="project[hidden_repo]" type="checkbox" <%= @project.hidden_repo ? "checked" : ""%>>
</li>
<li class="clear">
<% if Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") %>
<%= link_to(l(:button_delete_project), { :controller => 'projects', :action => 'archive', :id => @project, :status => params[:status], :type =>"project" },
:data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => "sy_btn_grey mr5 fl ml15") unless @project.archived? %>
<p class="fl c_grey">(友情提示:删除该项目后如果您想恢复该项目,请联系系统管理员!)</p>
<% end %>
<div class="cl"></div>
<li >
<label class="label02">公开&nbsp;&nbsp;</label>
<input id="project_is_public" name="project[is_public]" type="checkbox" <%= @project.is_public ? "checked" : ""%>>
<div class="cl"></div>
</li>
<li >
<label class="label02">隐藏代码库&nbsp;&nbsp;</label>
<input id="project_hidden_repo" name="project[hidden_repo]" type="checkbox" <%= @project.hidden_repo ? "checked" : ""%>>
<div class="cl"></div>
</li>
<a href="javascript:void(0)" class="sy_btn_blue mr15 fr" onclick="submit_edit_project(<%= @project.id %>);" >保存</a>
</li>
</ul>
<a href="javascript:void(0)" class="blue_btn ml110" onclick="submit_edit_project(<%= @project.id %>);" >保存</a>
<% end %>
<% if User.current.member_of?(@project) && Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") %>
<div class="mt30">
<img src="/images/pic_del.gif" class="mr5">
<%= link_to(l(:button_delete_project), { :controller => 'projects', :action => 'archive', :id => @project, :status => params[:status], :type =>"project" },
:data => {:confirm => l(:text_are_you_sure)}, :method => :post) unless @project.archived? %>
<%#=link_to "删除该课程", course_path(@course), :method => :delete, :confirm=>"确认要删除该课程吗?" %>
<span>(友情提示:删除该项目后如果您想恢复该项目,请联系系统管理员!)</span>
</div>
<% end %>
<div class="cl"></div>

View File

@ -1,3 +1,59 @@
<div class="pro_new_prompt ml15 mr15 mb10"><p>温馨提示:每个项目只能创建一个版本库</p></div>
<div class=" sy_new_tchbox clear " >
<% if @gitlab_repository.nil? %>
<a href="javascript:void(0);" class=" sy_btn_green mb10">新建版本库</a>
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %>
<ul class="pro_newsetting_con mb15">
<li style="display: none">
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm', options_for_select(["Git"],@repository.class.name.demodulize), :data => {:remote => true, :method => 'get'}) %>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<li>
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label class=" fl"><span class="c_red f12">*</span>&nbsp;版本库名称&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false, :label=>"", :no_label => true, :class => "w650 fl" %>
</li>
<li class="clear">
<label class=" fl">&nbsp;&nbsp;</label>
<p class=" fl c_grey pro_new_grey">1.长度必须在1到254个字符之间<br/>
2.仅限使用小写字母a-z、数字、破折号-和下划线_<br>
3.一旦保存,标识无法修改</p>
</li>
</ul>
<a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="fr sy_btn_grey"><%=l(:button_cancel)%></a>
<a href="#" onclick="$('#repository-form').submit();" class="fr sy_btn_blue mr5"><%=l(:lable_project_rep_create) %></a>
<% end %>
<% else %>
<div class=" clear ml15 mr15" >
<table class="sy_new_table clear mb15" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>版本库名</th>
<th >管理系统</th>
<th>库路径</th>
</tr>
</thead>
<tbody>
<tr>
<th><%= repository.identifier %></th>
<th>Gitlab</th>
<th><%=h truncate(@repos_url,:length=>10) %></th>
</tr>
</tbody>
</table>
</div>
<% end %>
</div>
<script>
function pro_st_show_ku()
{

View File

@ -1,3 +1,13 @@
<!--新版项目头部结束-->
<div class="pro_new_info mb10">
<h2>项目简介</h2>
<% if @project.description.blank? %>
<p><%= @project.name %><p>
<% else %>
<p><%= @project.description %><p>
<% end %>
</div>
<%#= stylesheet_link_tag 'courses' %>
<script type="text/javascript">
$(function () {

View File

@ -333,7 +333,7 @@ function close_window(type) {
function project_setting(n) {
for (var i = 1; i < 9; i++) {
if (i == n) {
$("#pro_st_tb_" + i).removeClass().addClass("pro_st_hovertab");
$("#pro_st_tb_" + i).removeClass().addClass("active");
$("#pro_st_tbc_0" + i).removeClass().addClass("pro_st_dis");
}
else {