diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index dd237de17..43e95a0e9 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -38,6 +38,11 @@ class OrgDocumentCommentsController < ApplicationController def show @document = OrgDocumentComment.find(params[:id]) + @org_subfield = OrgSubfield.where(:id => @document.org_subfield_id).first + @subfield_content = @organization.org_subfields.order("priority") + respond_to do |format| + format.html {render :layout => @organization.switch_type ? 'base_org_custom' : 'base_org'} + end end def index @@ -91,7 +96,7 @@ class OrgDocumentCommentsController < ApplicationController def add_reply_in_doc @document = OrgDocumentComment.find(params[:id]).root @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) - @comment.content = params[:org_comment][:org_content] + @comment.content = params[:org_content] @document.children << @comment @document.save respond_to do |format| diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index a0ef84798..ae1119609 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -28,8 +28,9 @@ class OrganizationsController < ApplicationController helper :project_score helper :issues include UsersHelper + include OrganizationsHelper before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students, :projects, :courses] - before_filter :allow_as_admin, :only => [:students, :teachers, :projects, :courses, :acts] + # before_filter :allow_as_admin, :only => [:students, :teachers, :projects, :courses, :acts] layout 'base_org' def index @@ -77,8 +78,12 @@ class OrganizationsController < ApplicationController def show # 组织新类型 show_mode:判断标准 1为新类型,0为旧 - if @organization.switch_type && params[:org_subfield_id].nil? && params[:list] .nil? + if @organization.switch_type && params[:list] .nil? if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + unless params[:org_subfield_id].nil? + @org_subfield = OrgSubfield.where(:id => params[:org_subfield_id]).first + @subfield_acts = get_subfield_acts(@org_subfield) + end @subfield_content = @organization.org_subfields.order("priority") 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) @@ -102,7 +107,7 @@ class OrganizationsController < ApplicationController if @organization.org_subfields.where(:field_type => "Compact", :hide => 0).count > 0 @acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'News', 'Message', 'Issue') and ((container_type = 'Course' and container_id in (#{course_ids.join(',')})) or (container_type = 'Project' and container_id in (#{project_ids.join(',')}))) - order by created_at desc limit 6;") + order by updated_at desc limit 6;") end render :layout => 'base_org_custom' else @@ -175,7 +180,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comptec").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type == "courses" || @type.nil? + if @type.blank? @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") elsif @type == "famous" @@ -199,7 +204,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type == "courses" || @type.nil? + if @type.blank? @org_students = User.find_by_sql("select u.*, ue.student_id, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity= 1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") elsif @type == "famous" @@ -235,7 +240,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comppro").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type.nil? + if @type.blank? @containers = Project.find_by_sql("select p.*, (select count(*) from forge_activities where forge_activities.project_id = p.id) as project_count from projects p where p.status =1 and p.is_public =1 and name like '%#{q}%' order by project_count desc;") elsif @type == "famous" @@ -249,7 +254,7 @@ class OrganizationsController < ApplicationController q = params[:search].nil? ? "" : "#{params[:search].strip}" @field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id]) @type = params[:type] - if @type.nil? + if @type.blank? @containers = Course.find_by_sql("select c.*, (select count(*) from course_activities where course_activities.course_id = c.id) as course_count from courses c where c.is_delete =0 and c.is_public =1 and name like '%#{q}%' order by course_count desc;") elsif @type == "famous" diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 531f0cb90..857f98afc 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -325,13 +325,10 @@ update def show ## TODO: the below will move to filter, done. - if !User.current.member_of?(@project) - if @project.hidden_repo - render_403 - return -1 - end + if !User.current.member_of?(@project) && @project.hidden_repo + render_403 + return end - @entries = @repository.entries(@path, @rev) @changeset = @repository.find_changeset_by_name(@rev) if request.xhr? diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb index 80c14f004..2e0890e27 100644 --- a/app/controllers/sub_document_comments_controller.rb +++ b/app/controllers/sub_document_comments_controller.rb @@ -3,7 +3,7 @@ class SubDocumentCommentsController < ApplicationController before_filter :find_subfield_content, :only => [:show, :index] before_filter :authorize_allowed, :only => [:create, :add_reply] helper :attachments,:organizations - layout 'base_sub_domain' + layout 'base_org_custom' def new @sub_document_comment = SubDocumentComment.new @@ -41,7 +41,7 @@ class SubDocumentCommentsController < ApplicationController if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @document = SubDocumentComment.find(params[:id]) respond_to do |format| - format.html {render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'} + format.html {render :layout => @organization.switch_type ? 'base_org_custom' : 'base_org'} end else render_403 @@ -58,7 +58,7 @@ class SubDocumentCommentsController < ApplicationController @offset ||= @atta_pages.offset @documents = paginateHelper @documents,20 respond_to do |format| - format.html {render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'} + format.html {render :layout => @organization.switch_type ? 'base_org_custom' : 'base_org'} end else render_403 diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index fa0d33f6e..60714f597 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -66,52 +66,87 @@ module OrganizationsHelper def org_user_by_type obj case obj.act_type when "Message" - user = obj.act.author + obj.act.author when "News" - user = obj.act.author + obj.act.author when "HomeworkCommon" - user = obj.act.user + obj.act.user when "Issue" - user = obj.act.author + obj.act.author end end def org_title_by_type obj case obj.act_type when "Message" - user = obj.act.parent_id.nil? ? obj.act.subject : obj.act.parent.subject + obj.act.parent_id.nil? ? obj.act.subject : obj.act.parent.subject when "News" - user = obj.act.title + obj.act.title when "HomeworkCommon" - user = obj.act.name + obj.act.name when "Issue" - user = obj.act.subject + obj.act.subject end end def org_content_by_type obj case obj.act_type when "Message" - user = obj.act.parent_id.nil? ? obj.act.content : obj.act.parent.content + obj.act.parent_id.nil? ? obj.act.content : obj.act.parent.content when "News" - user = obj.act.description + obj.act.description when "HomeworkCommon" - user = obj.act.description + obj.act.description when "Issue" - user = obj.act.description + obj.act.description end end def org_time_by_type obj case obj.act_type when "Message" - time = obj.act.updated_on + obj.act.updated_on when "News" - user = obj.act.created_on + obj.act.created_on when "HomeworkCommon" - user = obj.act.updated_at + obj.act.updated_at when "Issue" - user = obj.act.updated_on + obj.act.updated_on + end + end + + # 组织的栏目类型标题 + def subfield_title_type obj + case obj.org_act_type + when "OrgDocumentComment" + obj.org_act.title + when "Message" + obj.org_act.parent_id.nil? ? obj.org_act.subject : obj.org_act.parent.subject + when "News" + obj.org_act.title + end + end + + # 组织的栏目类型时间 + def subfield_time_type obj + case obj.org_act_type + when "OrgDocumentComment" + obj.org_act.updated_at + when "Message" + obj.org_act.updated_on + when "News" + obj.org_act.created_on + end + end + + def subfield_reply_count_type obj + case obj.org_act_type + when "OrgDocumentComment" + obj.org_act.children.count + when "Message" + obj.org_act.children.count + when "News" + obj.org_act.comments_count end end @@ -178,17 +213,19 @@ module OrganizationsHelper # 系统栏目只有管理员才能看到 def subfield_to_addmin?(org) - if User.current.admin? - @organization.org_subfields.order("priority") - else - @organization.org_subfields.select { |os| (os.field_type != "Comptec" && os.field_type != "Compstu" && os.field_type != "Comppro" && os.field_type != "Compcou" && os.field_type != "Compact") }.sort_by {|os| os.priority} - end + # if User.current.admin? + @organization.org_subfields.order("priority") + # else + # @organization.org_subfields.select { |os| (os.field_type != "Comptec" && os.field_type != "Compstu" && os.field_type != "Comppro" && os.field_type != "Compcou" && os.field_type != "Compact") }.sort_by {|os| os.priority} + # end end def get_subfield_acts field - org_subfield = OrgSubfield.find(field.id) - org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0 - org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{org_subfield.id})").order('updated_at desc') + unless field.nil? + org_subfield = OrgSubfield.find(field.id) + org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0 + org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{org_subfield.id})").order('updated_at desc') + end end def allow_to_create?(org, type) diff --git a/app/views/attachments/_attachment_history_download.html.erb b/app/views/attachments/_attachment_history_download.html.erb index c805960f0..c3e586fb1 100644 --- a/app/views/attachments/_attachment_history_download.html.erb +++ b/app/views/attachments/_attachment_history_download.html.erb @@ -13,7 +13,7 @@ 版本号:当前
diff --git a/app/views/layouts/_org_subdomain_footer.html.erb b/app/views/layouts/_org_subdomain_footer.html.erb new file mode 100644 index 000000000..dd991d900 --- /dev/null +++ b/app/views/layouts/_org_subdomain_footer.html.erb @@ -0,0 +1,13 @@ +