diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 9853b4dc1..173e5fabc 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -608,7 +608,7 @@ private @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' + unless @attachment.container_type == 'Bid'|| @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' @project = @attachment.project end end @@ -660,8 +660,10 @@ private end def has_login - unless @attachment && @attachment.container_type == "PhoneAppVersion" - 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) + unless@attachment.container_type == "Organization" + unless @attachment && @attachment.container_type == "PhoneAppVersion" + 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) + end end end end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 69b356b5a..cf94da8d9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -623,6 +623,36 @@ class FilesController < ApplicationController @attachtype = 0 @contenttype = 0 + respond_to do |format| + format.js + # format.html { + # redirect_to org_subfield_files_url(@org_subfield) + # } + end + # 组织添加附件,为了修改图片 + elsif params[:organization_id] + @organization = Organization.find(params[:organization_id]) + @addTag=false + # atttchment_type = 0为logo 1为banner + if params[:logo] + attachments = Attachment.attach_filesex(@organization, params[:attachments], false) + else + attachments = Attachment.attach_filesex(@organization, params[:attachments], true) + end + # TODO: 临时用 nyan + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [Organization.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@organization.id)] + + show_attachments @containers + @tag_list = attachment_tag_list @all_attachments + @attachtype = 0 + @contenttype = 0 + respond_to do |format| format.js # format.html { diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index fb7b59742..ab97b5b1b 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -78,6 +78,10 @@ class OrganizationsController < ApplicationController # 组织新类型 show_mode:判断标准 1为新类型,0为旧 if @organization.show_mode == 1 && params[:org_subfield_id].nil? && params[:list] .nil? if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + # REDO:时间紧,暂时先这样 + @org_logo_attchment = Attachment.where("container_id =? and container_type =? and attachtype =?", @organization, "Organization", 0).order("created_on desc").first + @org_banner_attchment = Attachment.where("container_id =? and container_type =? and attachtype =?", @organization, "Organization", 1).order("created_on desc").first + @subfield_content = @organization.org_subfields.order("priority") @organization = Organization.find(params[:id]) # 统计访问量 @@ -136,7 +140,7 @@ class OrganizationsController < ApplicationController @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", - @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) when 'project_issue' @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) when 'project_message' @@ -251,10 +255,10 @@ class OrganizationsController < ApplicationController if @organization.show_mode == 1 format.html { redirect_to organization_path(@organization)} else - format.html { redirect_to setting_organization_path(@organization)} - end + format.html { redirect_to setting_organization_path(@organization)} end end + end def check_uniq @check = false; diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 881621c3a..754bd4dee 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -23,6 +23,7 @@ class Attachment < ActiveRecord::Base belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'" belongs_to :org_subfield, foreign_key: 'container_id', conditions: "attachements.container_type = 'OrgSubfield'" + belongs_to :organization, foreign_key: 'container_id', conditions: "attachements.container_type = 'Organization'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" diff --git a/app/models/organization.rb b/app/models/organization.rb index 248783a26..427cd4c10 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -8,6 +8,8 @@ class Organization < ActiveRecord::Base has_many :org_courses, :dependent => :destroy has_many :org_subfields, :dependent => :destroy has_many :users, :through => :org_members + has_many :files + acts_as_attachable validates_uniqueness_of :name after_create :save_as_org_activity, :add_default_subfields diff --git a/app/views/files/_org_upload_attachment_list.html.erb b/app/views/files/_org_upload_attachment_list.html.erb new file mode 100644 index 000000000..973aeddd6 --- /dev/null +++ b/app/views/files/_org_upload_attachment_list.html.erb @@ -0,0 +1,34 @@ + + + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file#{container.id}", + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => "addInputFiles_board(this, '#{container.id}','"+"submit_resource"+"');", + :style => ie8? ? '': 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all), + :lebel_file_uploding => l(:lebel_file_uploding), + :containerid => "#{container.id}" + } %> + + + + + <%= l(:label_no_file_uploaded)%> + +(<%= l(:label_max_size) %>:<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) +

建议上传高度不超过52px的图片

+
+
+ + +
\ No newline at end of file diff --git a/app/views/files/_upload_org_new_files.html.erb b/app/views/files/_upload_org_new_files.html.erb new file mode 100644 index 000000000..cd460e328 --- /dev/null +++ b/app/views/files/_upload_org_new_files.html.erb @@ -0,0 +1,25 @@ +
+
+

更换Logo

+
+ <%= error_messages_for 'attachment' %> + + <%= form_tag(organization_files_path(org, :in_org => params[:in_org], :logo => true), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + + <%= render :partial => 'files/org_upload_attachment_list', :locals => {:container => org}%> +
+ <%= l(:button_cancel)%> + <%= l(:button_confirm)%> + <% end %> +
+ +
+ +
+ + \ No newline at end of file diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 1d66c2955..38308be12 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -1,71 +1,75 @@ <% if @addTag%> - <% if @obj_flag == '3'%> - $('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', +<% if @obj_flag == '3'%> +$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); - //$('#put-tag-form-issue').hide(); - $('#name-issue').val(""); - <% elsif @obj_flag == '6'%> - $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); - $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', +//$('#put-tag-form-issue').hide(); +$('#name-issue').val(""); +<% elsif @obj_flag == '6'%> +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); - $("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide(); - $("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); - <% else %> - $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', +$("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide(); +$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); +<% else %> +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); - $('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>'); - $('#put-tag-form #name').val(""); - //$('#put-tag-form').hide(); - <% end %> +$('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>'); +$('#put-tag-form #name').val(""); +//$('#put-tag-form').hide(); +<% end %> <% else %> $("#attachments_fields").children().remove(); $("#upload_file_count").text("未上传文件"); $('#upload_file_div').slideToggle('slow'); - <% if @project %> - hideModal(); - <% if @in_project_toolbar %> - window.location.href = '<%= project_files_path(@project) %>' - <% else %> +<% if @project %> +hideModal(); +<% if @in_project_toolbar %> +window.location.href = '<%= project_files_path(@project) %>' +<% else %> - $("#resource_list").html('<%= j(render partial:"project_file", locals: {project: @project}) %>'); - $("#project_files_count_info").html("<%= @all_attachments.count %>"); - $("#project_files_count_nav").html("(<%= @all_attachments.count %>)") - // 添加文件上传成功提示 - <% unless params[:attachments].nil? %> - var div = $('
文件上传成功!
'); - $("#course_list").prepend(div); - setTimeout( function(){div.remove();},3000) - <% end %> - <% end %> - <%elsif @course%> - hideModal(); - <%if @in_course_toolbar %> - window.location.href='<%= course_files_path(@course)%>' - <%else%> - $("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); - $("#courses_files_count_info").html("<%= @all_attachments.count%>"); - $("#courses_files_count_nav").html("(<%= @all_attachments.count%>)") - // 添加文件上传成功提示, - <% unless params[:attachments].nil? %> - var div = $('
文件上传成功!
'); - $("#course_list").prepend(div); - setTimeout( function(){div.remove();},3000) - <% end %> - <%end%> - <% elsif @org_subfield %> - <% if params[:in_org] %> - window.location.href = '<%= org_subfield_files_path @org_subfield %>'; - <%else %> - hideModal(); - $("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_subfield: @org_subfield}) %>'); - // 添加文件上传成功提示, - <% unless params[:attachments].nil? %> +$("#resource_list").html('<%= j(render partial:"project_file", locals: {project: @project}) %>'); +$("#project_files_count_info").html("<%= @all_attachments.count %>"); +$("#project_files_count_nav").html("(<%= @all_attachments.count %>)") +// 添加文件上传成功提示 +<% unless params[:attachments].nil? %> +var div = $('
文件上传成功!
'); +$("#course_list").prepend(div); +setTimeout( function(){div.remove();},3000) +<% end %> +<% end %> +<%elsif @course%> +hideModal(); +<%if @in_course_toolbar %> +window.location.href='<%= course_files_path(@course)%>' +<%else%> +$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); +$("#courses_files_count_info").html("<%= @all_attachments.count%>"); +$("#courses_files_count_nav").html("(<%= @all_attachments.count%>)") +// 添加文件上传成功提示, +<% unless params[:attachments].nil? %> +var div = $('
文件上传成功!
'); +$("#course_list").prepend(div); +setTimeout( function(){div.remove();},3000) +<% end %> +<%end%> +<% elsif @org_subfield %> +<% if params[:in_org] %> +window.location.href = '<%= org_subfield_files_path @org_subfield %>'; +<%else %> +hideModal(); +$("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_subfield: @org_subfield}) %>'); +// 添加文件上传成功提示, +<% unless params[:attachments].nil? %> // var div = $('
文件上传成功!
'); // $("#org_subfield_list").prepend(div); // setTimeout( function(){div.remove();},3000); - <% end %> - <% end %> - <% end %> +<% end %> +<% end %> +<% elsif @organization %> //组织单独处理 +hideModal(); +window.location.href = '<%= organization_path @organization %>'; + +<% end %> <% end %> $(document).ready(img_thumbnails); diff --git a/app/views/layouts/base_org_newstyle.html.erb b/app/views/layouts/base_org_newstyle.html.erb index 2bb3975cf..9ae752f6c 100644 --- a/app/views/layouts/base_org_newstyle.html.erb +++ b/app/views/layouts/base_org_newstyle.html.erb @@ -9,10 +9,10 @@ <%= favicon %> <%= javascript_heads %> <%= heads_for_theme %> - <%= stylesheet_link_tag 'org_new_style' %> - <%= javascript_include_tag 'org' %> + <%= stylesheet_link_tag 'org_new_style','jquery/jquery-ui-1.9.2' %> + <%= javascript_include_tag 'cookie','project', 'organization','header','prettify','select_list_move','org'%> <%= javascript_include_tag 'attachments' %> - <%= call_hook :view_layouts_base_html_head %> + <%#= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> @@ -59,13 +59,35 @@ + +
- + + + + <%# 登录 %> <%= render :partial => 'organizations/org_logined_header' %>
@@ -363,7 +385,7 @@ - + <%#= call_hook :view_layouts_base_body_bottom %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d36117556..e67ca806d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -679,6 +679,7 @@ zh: label_repository: 版本库 label_course_repository: 代码库 label_browse: 上传文件 + label_browse_org: 上传图片 label_branch: 分支 label_tag: 标签 label_revision: 修订 diff --git a/config/routes.rb b/config/routes.rb index 56194bd20..c6b3d9da3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,14 @@ RedmineApp::Application.routes.draw do end end resources :organizations do + resource :files do + member do + + end + collection do + + end + end resources :org_document_comments do member do diff --git a/public/images/org_new_style/default-img.jpg b/public/images/org_new_style/default-img.jpg index e345ca3d7..e9aead6ed 100644 Binary files a/public/images/org_new_style/default-img.jpg and b/public/images/org_new_style/default-img.jpg differ diff --git a/public/images/org_new_style/default-img2.jpg b/public/images/org_new_style/default-img2.jpg new file mode 100644 index 000000000..8d194d605 Binary files /dev/null and b/public/images/org_new_style/default-img2.jpg differ diff --git a/public/images/org_new_style/default-img2.png b/public/images/org_new_style/default-img2.png deleted file mode 100644 index 3a824b1f6..000000000 Binary files a/public/images/org_new_style/default-img2.png and /dev/null differ diff --git a/public/stylesheets/org_new_style.css b/public/stylesheets/org_new_style.css index 442ca9ce3..8fca32cb1 100644 --- a/public/stylesheets/org_new_style.css +++ b/public/stylesheets/org_new_style.css @@ -192,6 +192,73 @@ a:hover.more-btn-center{ background:#29146f; color:#fff;} .note-box p{display:block; width:515px; color:#888; font-size:12px; line-height:2.5;} .right-info2{background:url(../images/org_new_style/icons.png) no-repeat -41px -540px ; width:15px; line-height:1.9; height:16px; padding-left:20px; color:#888; margin-top:5px;} +.upload_con h2 { + display: block; + background: #eaeaea; + font-size: 14px; + color: #343333; + height: 31px; + width: auto; + margin-top: 25px; + padding-left: 20px; + padding-top: 5px; +} +a.blue_btn { + background: #64bdd9; + color: #fff; + font-size: 14px; + font-weight: normal; + padding: 2px 8px; + text-align: center; + cursor: pointer; +} +a.grey_btn { + background: #d9d9d9; + color: #656565; + font-size: 14px; + font-weight: normal; + text-align: center; + margin-left: 10px; + margin-bottom: 10px; + padding: 2px 10px; +} +span.add_attachment { + font-size: 80%; + line-height: 2.5em; +} +.c_dark { + color: #2d2d2d; +} +.upload_filename { + background: url(../images/pic_file.png) 0 -20px no-repeat; + color: #7f7f7f; + width: 270px; + border: none; + padding-left: 20px; + margin-right: 10px; + margin-bottom: 5px; + white-space: nowrap; + text-overflow: ellipsis; +} +.profiler-results.profiler-left { + left: 0px; +} +.profiler-results { + z-index: 2147483643; + position: fixed; + top: 0px; +} + +.filename { background: url(../images/pic_file.png) 0 -25px no-repeat;color: #3ca5c6;max-width: 150px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;} +.ajax-waiting input.upload_filename {background:url(../images/hourglass.png) no-repeat 0px 50%;} +.ajax-loading input.upload_filename {background:url(../images/loading.gif) no-repeat 0px 50%;} +div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; } +.upload_filename{ background: url(../images/pic_file.png) 0 -20px no-repeat;color: #7f7f7f;width: 270px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;} +.evaluation{position: relative;} +.evaluation_submit{position: absolute;right: 0px;bottom: 0px;} +.student_work_search{background-color: #64bdd9;color: white !important;padding: 2px 7px;margin-left: 10px;cursor: pointer; } + +