Merge remote-tracking branch 'origin/szzh' into szzh
This commit is contained in:
commit
b704a44dfb
|
@ -630,7 +630,13 @@ class CoursesController < ApplicationController
|
||||||
:with_subprojects => false,
|
:with_subprojects => false,
|
||||||
:author => @author)
|
:author => @author)
|
||||||
@activity.scope_select {|t| has["show_#{t}"]}
|
@activity.scope_select {|t| has["show_#{t}"]}
|
||||||
events = @activity.events(@date_from, @date_to)
|
# modify by nwb
|
||||||
|
# 添加私密性判断
|
||||||
|
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||||
|
events = @activity.events(@date_from, @date_to)
|
||||||
|
else
|
||||||
|
events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||||
|
end
|
||||||
|
|
||||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
@events_count = events.count
|
@events_count = events.count
|
||||||
|
|
|
@ -23,6 +23,7 @@ class DocumentsController < ApplicationController
|
||||||
before_filter :find_model_object, :except => [:index, :new, :create]
|
before_filter :find_model_object, :except => [:index, :new, :create]
|
||||||
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
before_filter :find_project_from_association, :except => [:index, :new, :create]
|
||||||
before_filter :authorize , :except => [:index]#Added by young
|
before_filter :authorize , :except => [:index]#Added by young
|
||||||
|
before_filter :authorize_document
|
||||||
|
|
||||||
helper :attachments
|
helper :attachments
|
||||||
|
|
||||||
|
@ -100,4 +101,12 @@ class DocumentsController < ApplicationController
|
||||||
end
|
end
|
||||||
redirect_to document_path(@document)
|
redirect_to document_path(@document)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 权限判断
|
||||||
|
# add by nwb
|
||||||
|
def authorize_document
|
||||||
|
if !(User.current.admin? || User.current.member_of?(@project) || @document.is_public==1)
|
||||||
|
render_403 :message => :notice_not_authorized
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -697,8 +697,14 @@ class ProjectsController < ApplicationController
|
||||||
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
@activity.scope_select {|t| !has["show_#{t}"].nil?}
|
||||||
# logger.debug "=========================================#{@activity.scope}"
|
# logger.debug "=========================================#{@activity.scope}"
|
||||||
# @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
# @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
|
||||||
#Added by young
|
|
||||||
events = @activity.events(@date_from, @date_to)
|
# modify by nwb
|
||||||
|
# 添加私密性判断
|
||||||
|
if User.current.member_of?(@project)|| User.current.admin?
|
||||||
|
events = @activity.events(@date_from, @date_to)
|
||||||
|
else
|
||||||
|
events = @activity.events(@date_from, @date_to, :is_public => 1)
|
||||||
|
end
|
||||||
|
|
||||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
@events_count = events.count
|
@events_count = events.count
|
||||||
|
|
|
@ -39,19 +39,22 @@ class Attachment < ActiveRecord::Base
|
||||||
|
|
||||||
#课程资源文件
|
#课程资源文件
|
||||||
acts_as_activity_provider :type => 'course_files',
|
acts_as_activity_provider :type => 'course_files',
|
||||||
|
:is_public => 'attachments.is_public',
|
||||||
:permission => :view_files,
|
:permission => :view_files,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
:joins => "LEFT JOIN #{Course.table_name} ON ( #{Attachment.table_name}.container_type='Course' AND #{Attachment.table_name}.container_id = #{Course.table_name}.id )"}
|
:joins => "LEFT JOIN #{Course.table_name} ON ( #{Attachment.table_name}.container_type='Course' AND #{Attachment.table_name}.container_id = #{Course.table_name}.id )"}
|
||||||
|
|
||||||
acts_as_activity_provider :type => 'files',
|
acts_as_activity_provider :type => 'files',
|
||||||
|
:is_public => 'attachments.is_public',
|
||||||
:permission => :view_files,
|
:permission => :view_files,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => { :select => "#{Attachment.table_name}.*",
|
||||||
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
:joins => "LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
|
||||||
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"}
|
"LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )"}
|
||||||
|
|
||||||
acts_as_activity_provider :type => 'documents',
|
acts_as_activity_provider :type => 'documents',
|
||||||
|
:is_public => 'documents.is_public',
|
||||||
:permission => :view_documents,
|
:permission => :view_documents,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
|
|
|
@ -30,7 +30,8 @@ class Document < ActiveRecord::Base
|
||||||
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
|
||||||
:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
|
:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
|
||||||
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
|
||||||
acts_as_activity_provider :find_options => {:include => :project}
|
acts_as_activity_provider :find_options => {:include => :project},
|
||||||
|
:is_public => 'documents.is_public'
|
||||||
|
|
||||||
validates_presence_of :project, :title, :category
|
validates_presence_of :project, :title, :category
|
||||||
validates_length_of :title, :maximum => 60
|
validates_length_of :title, :maximum => 60
|
||||||
|
@ -39,7 +40,7 @@ class Document < ActiveRecord::Base
|
||||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_documents, *args))
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_attributes 'category_id', 'title', 'description'
|
safe_attributes 'category_id', 'title', 'description','is_public'
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_documents, project)
|
!user.nil? && user.allowed_to?(:view_documents, project)
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
class FirstPage < ActiveRecord::Base
|
class FirstPage < ActiveRecord::Base
|
||||||
attr_accessible :description, :title, :web_title
|
attr_accessible :description, :title, :web_title,:page_type
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,11 +2,19 @@
|
||||||
<% contests.each do |contest|%>
|
<% contests.each do |contest|%>
|
||||||
<table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
<table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top" width="50" ><%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %></td>
|
<td colspan="2" valign="top" width="50" >
|
||||||
|
<% unless contest.author.nil? %>
|
||||||
|
<%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<table width="100%" border="0">
|
<table width="100%" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top"><strong><%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>: <%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
|
<td colspan="2" valign="top"><strong>
|
||||||
|
<% unless contest.author.nil? %>
|
||||||
|
<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>:
|
||||||
|
<% end %>
|
||||||
|
<%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path', :target => "_blank") %></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="500">
|
<td width="500">
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<%= error_messages_for @document %>
|
<%= error_messages_for @document %>
|
||||||
|
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<p><%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %></p>
|
<p><%= f.select :category_id, DocumentCategory.active.collect {|c| [c.name, c.id]} %> </p>
|
||||||
|
<p> <em style ="display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %>
|
||||||
|
<%= l(:label_document_public_info) %></em>
|
||||||
|
</p>
|
||||||
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
|
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
|
||||||
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
|
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
<% if forums.any? %>
|
<% if forums.any? %>
|
||||||
<% forums.each do |forum| %>
|
<% forums.each do |forum| %>
|
||||||
<div class="forums-index">
|
<div class="forums-index">
|
||||||
<div class="forums-inex-avatar"><%= link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator) %></div>
|
<div class="forums-inex-avatar">
|
||||||
|
<% unless forum.creator.nil? %>
|
||||||
|
<%= link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
<div class="forums-index-content">
|
<div class="forums-index-content">
|
||||||
<p ><%= link_to h(forum.name), forum_path(forum) %></p>
|
<p ><%= link_to h(forum.name), forum_path(forum) %></p>
|
||||||
<p ><%= forum.description%></p>
|
<p ><%= forum.description%></p>
|
||||||
|
|
|
@ -537,6 +537,7 @@ en:
|
||||||
label_document_new: New document
|
label_document_new: New document
|
||||||
label_document_plural: Documents
|
label_document_plural: Documents
|
||||||
label_document_added: Document added
|
label_document_added: Document added
|
||||||
|
label_document_public_info: "If you don't choose public, only the project's members can see the document."
|
||||||
label_role: Role
|
label_role: Role
|
||||||
label_role_plural: Roles
|
label_role_plural: Roles
|
||||||
label_role_new: New role
|
label_role_new: New role
|
||||||
|
|
|
@ -537,6 +537,7 @@ zh:
|
||||||
label_document_new: 新建文档
|
label_document_new: 新建文档
|
||||||
label_document_plural: 文档
|
label_document_plural: 文档
|
||||||
label_document_added: 文档已添加
|
label_document_added: 文档已添加
|
||||||
|
label_document_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该文档。)
|
||||||
label_role: 角色
|
label_role: 角色
|
||||||
label_role_plural: 角色
|
label_role_plural: 角色
|
||||||
label_role_new: 新建角色
|
label_role_new: 新建角色
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddIsPublicToDocuments < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :documents, :is_public, :integer,:default => 1
|
||||||
|
end
|
||||||
|
end
|
|
@ -29,7 +29,7 @@ module Redmine
|
||||||
send :include, Redmine::Acts::ActivityProvider::InstanceMethods
|
send :include, Redmine::Acts::ActivityProvider::InstanceMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options, :func)
|
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options, :func,:is_public)
|
||||||
self.activity_provider_options ||= {}
|
self.activity_provider_options ||= {}
|
||||||
|
|
||||||
# One model can provide different event types
|
# One model can provide different event types
|
||||||
|
@ -65,6 +65,11 @@ module Redmine
|
||||||
scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id])
|
scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add by nwb
|
||||||
|
if options[:is_public] && !provider_options[:is_public].nil?
|
||||||
|
scope = scope.scoped(:conditions => ["#{provider_options[:is_public]} = ?", options[:is_public]])
|
||||||
|
end
|
||||||
|
|
||||||
if options[:limit]
|
if options[:limit]
|
||||||
# id and creation time should be in same order in most cases
|
# id and creation time should be in same order in most cases
|
||||||
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
|
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
|
||||||
|
|
|
@ -82,6 +82,8 @@ module Redmine
|
||||||
def events(from = nil, to = nil, options={})
|
def events(from = nil, to = nil, options={})
|
||||||
e = []
|
e = []
|
||||||
@options[:limit] = options[:limit]
|
@options[:limit] = options[:limit]
|
||||||
|
# modify by nwb
|
||||||
|
@options[:is_public] = options[:is_public]
|
||||||
|
|
||||||
@scope.each do |event_type|
|
@scope.each do |event_type|
|
||||||
constantized_providers(event_type).each do |provider|
|
constantized_providers(event_type).each do |provider|
|
||||||
|
|
Loading…
Reference in New Issue