diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d14bccc4e..ad0fab173 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -372,7 +372,8 @@ class ApplicationController < ActionController::Base return true end - if allowed + + if allowed || (params[:type] && params[:type] == "wechat" ) true else if @project && @project.archived? diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 5d1345f24..3986acc0a 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -130,7 +130,12 @@ class AttachmentsController < ApplicationController def download # modify by nwb # 下载添加权限设置 - candown = attachment_candown @attachment + if (params[:type] && params[:type] == "wechat" ) + candown = true + else + candown = attachment_candown @attachment + end + if candown || User.current.admin? || User.current.id == @attachment.author_id if stale?(:etag => @attachment.digest) if params[:preview] == 'true' @@ -710,7 +715,7 @@ class AttachmentsController < ApplicationController def has_login unless (@attachment && @attachment.container_type == "Organization").nil? unless (@attachment && @attachment.container_type == "PhoneAppVersion").nil? - render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) + render_403 if (!User.current.logged? && !(params[:type] && params[:type] == "wechat")) && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) end end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index bdbdc7d9c..6fb2868bc 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -132,16 +132,13 @@ class IssuesController < ApplicationController User.current.at_messages.unviewed('Journal', j.id).each {|x| x.viewed!} end - # 缺陷状态更新 - query_journals = @issue.journals - query_journals.each do |query_journal| - query_journal.forge_messages.each do |f| - if User.current.id == f.user_id - f.update_attributes(:viewed => true) - end - end - end - # end + # 缺陷状态消息更新 + query_journals_ids = @issue.journals.map{|journal| journal.id} + if query_journals_ids.length > 0 + query_journals = ForgeMessage.where("user_id =? and forge_message_type =? and forge_message_id in (#{query_journals_ids.join(",")})", User.current.id, "Journal") + query_journals.update_all(:viewed => true) + end + @jour_reply = Journal.new @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 56ffc77e2..2b31cae13 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -88,7 +88,7 @@ class OrganizationsController < ApplicationController shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) project_ids = (@organization.projects.map(&:id) - shield_project_ids) << 0 - course_ids = (@organization.courses.map(&:id) - shield_course_ids) << 0 + course_ids = (@organization.courses.not_deleted.map(&:id) - shield_course_ids) << 0 course_types = "('Message','News','HomeworkCommon','Poll','Course')" @project_acts = get_project_activities_org @organization, project_ids @course_acts = get_course_activities_org @organization, course_ids @@ -140,7 +140,7 @@ class OrganizationsController < ApplicationController shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 - course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 0 + course_ids = (@organization.courses.not_deleted.map(&:id)-shield_course_ids) << 0 course_types = "('Message','News','HomeworkCommon','Poll','Course')" case params[:type] when nil diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 365889640..4e522ec73 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -252,7 +252,7 @@ class QualityAnalysisController < ApplicationController unresolved_issue_count = JSON.parse(unresolved_issues)["total"].to_i all_issues = open(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}").read all_issue_count = JSON.parse(all_issues)["total"].to_i - ratio = (changes == 0 ? 0 : format("%0.4f",unresolved_issue_count.to_f/changes.to_f)) + ratio = ((changes == 0 || all_issue_count == 0) ? 0 : format("%0.4f",all_issue_count.to_f/changes.to_f)) @user_quality_infos << {:email => email, :changes => changes, :unresolved_issue_count => unresolved_issue_count, :ratio => ratio, :all_issue_count => all_issue_count} end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c1d6950fa..94b0b2c6e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -417,13 +417,13 @@ module ApplicationHelper end # status_id:3、已解决 5、已关闭 if issue.status_id == 3 - s = link_to text, issue_path(issue), :class => "text_line_s", :title => title + s = link_to text, issue_path(issue), :class => "text_line_s fl", :title => title elsif issue.status_id == 5 - s = link_to text, issue_path(issue), :class => "text_line_s del_line", :title => title + s = link_to text, issue_path(issue), :class => "text_line_s del_line fl", :title => title else - s = link_to text, issue_path(issue), :class => "c_blue", :title => title + s = link_to text, issue_path(issue), :class => "c_blue fl", :title => title end - s << h(": #{subject}") if subject + s << h("".html_safe) if subject s = h("#{issue.project} - ") + s if options[:project] s end @@ -652,7 +652,7 @@ module ApplicationHelper s << watcher_link(@project, User.current)#, ['whiteButton']) s << "" end - s << (render :partial => 'projects/project', :locals => {:project => project}).to_s + s << (render :partial => 'projects/tracker_project', :locals => {:project => project}).to_s else s << (render :partial => 'projects/course', :locals => {:project => project}).to_s end @@ -832,9 +832,15 @@ module ApplicationHelper atts.count > 0 ? true :false end - # 必须是项目成,项目必须提交过代码 + # 如果Pull Request数量为0就显示在更多中 + def allow_show_pull_request project + g = Gitlab.client + count = g.merge_requests(project.gpid).count + end + + # 必须是项目成员,项目必须提交过代码 def allow_pull_request project - return false if project.gpid.nil? + return 0 if project.gpid.nil? g = Gitlab.client count = g.user_static(project.gpid, :rev => "master").count count diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index 5e3a927da..80cc40fb0 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -64,7 +64,6 @@ <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %> <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %> - <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %> <%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del', :onClick=>"delcfm()" ) %> diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 8f8aabef5..1be21cbc1 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -78,5 +78,12 @@
<%= call_hook(:view_issues_form_details_bottom, {:issue => @issue, :form => f}) %> <% end %> - 确定 - 取消 + 确定 +<% if params[:action] == "new" %> + <% if @copy_from %> + <%= link_to "取消", issue_path(@copy_from), :class => "grey_btn fl mr50 ml10" %> + <% end %> +<% else %> + 取消 +<% end %> + diff --git a/app/views/issues/_jounal_refresh.js.erb b/app/views/issues/_jounal_refresh.js.erb index df3d605f4..db5a068bf 100644 --- a/app/views/issues/_jounal_refresh.js.erb +++ b/app/views/issues/_jounal_refresh.js.erb @@ -1,8 +1,5 @@ -$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue}) %>"); -$("#issue_detail_show").html('<%= escape_javascript(render :partial => 'issues/detail') %>') -$("#issue_edit_show").html('<%= escape_javascript(render :partial => 'issues/edit') %>') -$("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => @issue}) %>"); -sd_create_editor_from_data(<%= @issue.id %>, null, "100%", "<%= @issue.class.name %>"); + +location.reload(); issue_desc_editor = KindEditor.create('#issue_description', {"width":"85%", "resizeType":0, @@ -17,5 +14,3 @@ issue_desc_editor = KindEditor.create('#issue_description', "uploadJson":"/kindeditor/upload", "fileManagerJson":"/kindeditor/filemanager"}); // $("#issue_test_<%#= @issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/edit', :locals => {:issue => Issue.find( @issue_id)}) %>"); -$(".homepagePostReplyBannerCount").html('<%= escape_javascript(render :partial => 'issues/issue_reply_banner') %>'); -sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%= @issue.class.name %>"); \ No newline at end of file diff --git a/app/views/issues/update.js.erb b/app/views/issues/update.js.erb index bd4385340..733066d38 100644 --- a/app/views/issues/update.js.erb +++ b/app/views/issues/update.js.erb @@ -1,12 +1,5 @@ <% if @saved %> -$("#issue_detail").replaceWith('<%= escape_javascript(render :partial => 'issues/detail') %>') -$("#issue_edit").replaceWith('<%= escape_javascript(render :partial => 'issues/edit') %>') - -$("#issue_detail").show(); -$("#issue_edit").hide(); -$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>"); -sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%=@issue.class.name%>"); -$(".homepagePostReplyBannerCount").html('<%= escape_javascript(render :partial => 'issues/issue_reply_banner') %>'); +location.reload(); //edit里的编辑器貌似显示不出来,所以手动js生成。 issue_desc_editor = KindEditor.create('#issue_description', {"width":"85%", @@ -31,6 +24,7 @@ issue_desc_editor = KindEditor.create('#issue_description', // "allowFileManager":true, // "uploadJson":"/kindeditor/upload", // "fileManagerJson":"/kindeditor/filemanager"}); + <%else%> alert('<%= @issue.errors.full_messages[0].to_s%>') <%end %> diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb index 584970f16..2d6da0770 100644 --- a/app/views/layouts/_show_messages_list.html.erb +++ b/app/views/layouts/_show_messages_list.html.erb @@ -138,7 +138,7 @@
  • <%=ma.forge_message.author.show_name %> 评论了新闻:<%= ma.forge_message.commented.title%>
  • <% end %> <% elsif ma.class == MemoMessage %> - <% if ma.memo_type == "Memo" %> + <% if ma.memo_type == "Memo" && !ma.memo.nil? && !ma.memo.author.nil? %>
  • <%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%>"><%=ma.memo.author.show_name %> <%= ma.memo.parent_id.nil? ? "在贴吧发布帖子:" : "回复了贴吧帖子:" %><%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%>
  • <% end %> <% elsif ma.class == UserFeedbackMessage %> diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index 21858fbea..754cfd10b 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -2,10 +2,10 @@
  • <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> -

    + <%= link_to course.syllabus.title, syllabus_path(course.syllabus_id), :target => '_blank', :class => 'hidden', :style => "max-width:85px; display:inline-block;"%> + · + <%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :target => '_blank', :class => 'hidden', :style => "max-width:85px; display:inline-block;"%>

    <%#= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :id => "show_course_#{course.id}", :class => 'course_list_menu hidden', :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级:")+course.name+"("+current_time_and_term(course)+")"%> @@ -104,4 +104,13 @@ $("#user_show_more_course").hide(); $('#user_hide_course').show(); } + + $(".course_list_menu").each(function(){ + var courseWidth = $(this).children().eq(0).width(); + var classWidth = 170 -courseWidth; + console.log(courseWidth, classWidth); + if(courseWidth < 80){ + $(this).children().eq(2).css("max-width",classWidth + "px"); + } + }) diff --git a/app/views/layouts/new_base_user_show.html.erb b/app/views/layouts/new_base_user_show.html.erb index b92218241..94c5c8a30 100644 --- a/app/views/layouts/new_base_user_show.html.erb +++ b/app/views/layouts/new_base_user_show.html.erb @@ -147,7 +147,7 @@
    - 编辑个人资料 + <%= link_to "编辑个人资料", my_account_path(:tip => 1), :class => "user_editinfo"%>
    diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 435fd0f9e..d684b4297 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -90,7 +90,7 @@
    <%= reply.author.name%><%= format_date(reply.created_at) %>
    -
    <%= h reply.content.html_safe%>
    +
    <%= h reply.content.html_safe%>