diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index aa2c9574b..0003f7586 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -67,9 +67,7 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - # show_attachments [@course] - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? @@ -108,14 +106,18 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] - @result = find_public_attache q,sort - @result = visable_attachemnts_insite @result,@project - @searched_attach = paginateHelper @result,10 + if q == "%%" + @result = [] + @searched_attach = paginateHelper @result,10 + else + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@project + @searched_attach = paginateHelper @result,10 + end else @result = find_project_attache q,@project,sort @result = visable_attachemnts @result diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 8acca7f81..83f68d8d8 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -169,7 +169,7 @@ class IssuesController < ApplicationController attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} redirect_to new_project_issue_url(@issue.project, :issue => attrs) else - redirect_to issue_url(@issue) + redirect_to issue_url(@issue.id) end } format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) } @@ -239,7 +239,8 @@ class IssuesController < ApplicationController flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? respond_to do |format| - format.html { redirect_back_or_default issue_path(@issue) } + + format.html { redirect_to issue_url(@issue.id) } format.api { render_api_ok } end else diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0836bf307..a07ff320d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -622,8 +622,8 @@ module ApplicationHelper # 公开项目资源可以引用,admin和管理员和资源上传者拥有设置公开私有权限 def authority_pubilic_for_files(project, file) @result = false - if (is_project_manager?(User.current.id, @project.id) || file.author_id == User.current.id || User.current.admin) && - project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" + if (is_project_manager?(User.current.id, @project.id) && User.current.allowed_to?(:manage_files, project)) || file.author_id == User.current.id || User.current.admin && + project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" @result = true end return @result diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 508e58ba3..12925b0b1 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -65,6 +65,16 @@ module ProjectsHelper content_tag('div', content, :class => "tabs") end + # 判断我的项目中是否有重名项目 + def judge_same_projectname(user, project_name) + result = false + my_projects = user.projects + my_projects.each do |mp| + result = true if mp.name == project_name + end + return result + end + # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 1347c3026..43d01a5dd 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -277,6 +277,9 @@ module QueriesHelper elsif(params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='') params[:op][:created_on]='<=' params[:v][:created_on]=[params[:issue_create_date_end]] + else + params[:op][:created_on]='!' + params[:v][:created_on]='' end end @query.build_from_params(params) diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index d32d2319f..35aa36195 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -1,4 +1,4 @@ - +<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>

共有 <%= all_attachments.count%> 个资源

@@ -22,13 +22,13 @@ <% if User.current.logged? %> <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> - <% else %> - <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> - <% end %> - <% if authority_pubilic_for_files(project, file) %> + <% if authority_pubilic_for_files(project, file) && delete_allowed %> <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + <% end %> + <% else %> + <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% end %> <% end %>

diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb index ff498f100..a5823ede3 100644 --- a/app/views/issues/_action_menu.html.erb +++ b/app/views/issues/_action_menu.html.erb @@ -2,7 +2,5 @@ <%#= watcher_link_issue(@issue, User.current) %> <%#= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:add_issues, @project) %> <%= link_to l(:button_delete), issue_path(@issue.id), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'talk_edit fr' if User.current.allowed_to?(:delete_issues, @project) %> - - - <%= link_to l(:button_edit), edit_issue_path(@issue), :onclick => 'showAndScrollTo("all_attributes"); return false;', :class => 'talk_edit fr', :accesskey => accesskey(:edit) if @issue.editable? && User.current.allowed_to?(:edit_issues, @project) %> - <%= link_to l(:label_user_newfeedback), edit_issue_path(@issue), :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'talk_edit fr', :accesskey => accesskey(:edit) if @issue.editable? && User.current.allowed_to?(:add_issue_notes, @project) %> +<%= link_to l(:button_edit), edit_issue_path(@issue.id), :onclick => 'showAndScrollTo("all_attributes"); return false;', :class => 'talk_edit fr', :accesskey => accesskey(:edit) if @issue.editable? && User.current.allowed_to?(:edit_issues, @project) %> +<%= link_to l(:label_user_newfeedback), edit_issue_path(@issue.id), :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'talk_edit fr', :accesskey => accesskey(:edit) if @issue.editable? && User.current.allowed_to?(:add_issue_notes, @project) %> diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index bb8ea1bef..d075ae301 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -1,16 +1,9 @@ \ No newline at end of file diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb index 763b65515..fdb3c6f85 100644 --- a/app/views/settings/_general.html.erb +++ b/app/views/settings/_general.html.erb @@ -15,6 +15,11 @@

<%= setting_text_field :activity_days_default, :size => 6 %> <%= l(:label_day_plural) %>

<%= setting_text_field :host_name, :size => 60 %> +

<%= setting_text_field :host_course, :size => 60 %> +

<%= setting_text_field :host_contest, :size => 60 %> +

<%= setting_text_field :host_user, :size => 60 %> +

<%= setting_text_field :host_repository, :size => 60 %> + <%= l(:label_example) %>: <%= @guessed_host_and_path %>

<%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 844818ae4..09897c1eb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -183,6 +183,10 @@ en: setting_bcc_recipients: Blind carbon copy recipients (bcc) setting_plain_text_mail: Plain text mail (no HTML) setting_host_name: Host name and path + setting_host_course: Host course and path + setting_host_contest: Host contest and path + setting_host_user: Host user and path + setting_host_repository: Host repository and path setting_text_formatting: Text formatting setting_wiki_compression: Wiki history compression setting_feeds_limit: Maximum number of items in Atom feeds diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 24702ad46..4c752660a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -190,6 +190,10 @@ zh: setting_bcc_recipients: 使用密件抄送 (bcc) setting_plain_text_mail: 纯文本(无HTML) setting_host_name: 主机名称 + setting_host_course: 课程域名 + setting_host_contest: 竞赛域名 + setting_host_user: 用户域名 + setting_host_repository: 仓库域名 setting_text_formatting: 文本格式 setting_wiki_compression: 压缩Wiki历史文档 setting_feeds_limit: RSS Feed内容条数限制 diff --git a/public/javascripts/project.js b/public/javascripts/project.js index 0a04b2a7b..f9f88703d 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -425,4 +425,35 @@ $(function(){ personalized_init(); }); -//cookie记忆html区块 显示/隐藏 的代码 end \ No newline at end of file +//cookie记忆html区块 显示/隐藏 的代码 end + +// 新建项目的时候判断是否与我已有的项目重复 +function judgeprojectname(){ + $('#new_project').validate({ + errorPlacement: function(error, element){ + alert('error') + }, + success: function(label){ + alert('ok') + }, + onkeyup: false, + rules : { + name:{required : true, + remote : { + url : 'projects/judge_same_projectname', + type:'get', + dataType:'text', + data:{ + name : function(){ return $.trim( $("#name").val() ); } + }, + dataFilter:function( data ){ + if( data=='true')return false; else return true; + } + } + } + }, + messages : { + name:{required : "请填写项目名称!",remote:'您已新建过同名项目,请修改项目名称!'} + } + }); +} \ No newline at end of file