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 @@
+
+ <%= l(:label_browse_org) %>
+ <%= 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' %>
+
<%= l(:label_file_upload_error_messages)%>
+ <%= 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 @@
+
+