diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 2a3ce15d8..d87644e43 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -234,4 +234,96 @@ class AdminController < ApplicationController
format.api
end
end
+
+ #首页定制
+ def first_page_made
+ if request.get?
+ @first_page = FirstPage.where("page_type = 'project'").first
+ elsif request.post?
+ @first_page = FirstPage.where("page_type = 'project'").first
+ @first_page.web_title = params[:web_title]
+ @first_page.description = params[:description]
+ @first_page.title = params[:title]
+ if @first_page.save
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to admin_first_page_made_path
+ }
+ format.api { render_api_ok }
+ end
+ else
+ respond_to do |format|
+ format.html {
+ first_page_made
+ render :action => 'first_page_made'
+ }
+ format.api { render_validation_errors(@first_page) }
+ end
+ end
+ end
+ end
+
+ def course_page_made
+ if request.get?
+ @course_page = FirstPage.where("page_type = 'course'").first
+ @first_page = FirstPage.where("page_type = 'project'").first
+ elsif request.post?
+ @first_page = FirstPage.where("page_type = 'project'").first
+ @course_page = FirstPage.where("page_type = 'course'").first
+ @first_page.web_title = params[:web_title]
+ @course_page.title = params[:course_title]
+ @course_page.description = params[:course_description]
+ if @first_page.save && @course_page.save
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to admin_course_page_made_path
+ }
+ format.api { render_api_ok }
+ end
+ else
+ respond_to do |format|
+ format.html {
+ course_page_made
+ render :action => 'course_page_made'
+ }
+ format.api { render_validation_errors(@first_page) }
+ format.api { render_validation_errors(@course_page) }
+ end
+ end
+ end
+ end
+
+ def contest_page_made
+ if request.get?
+ @contest_page = FirstPage.where("page_type = 'contest'").first
+ @first_page = FirstPage.where("page_type = 'project'").first
+ elsif request.post?
+ @first_page = FirstPage.where("page_type = 'project'").first
+ @contest_page = FirstPage.where("page_type = 'contest'").first
+ @first_page.web_title = params[:web_title]
+ @contest_page.title = params[:contest_title]
+ @contest_page.description = params[:contest_description]
+ if @first_page.save && @contest_page.save
+ respond_to do |format|
+ format.html {
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to admin_contest_page_made_path
+ }
+ format.api { render_api_ok }
+ end
+ else
+ respond_to do |format|
+ format.html {
+ contest_page_made
+ render :action => 'contest_page_made'
+ }
+ format.api { render_validation_errors(@first_page) }
+ format.api { render_validation_errors(@contest_page) }
+ end
+ end
+ end
+ end
+
end
diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb
index fdb45b030..3d061ef74 100644
--- a/app/controllers/applied_project_controller.rb
+++ b/app/controllers/applied_project_controller.rb
@@ -6,7 +6,8 @@ class AppliedProjectController < ApplicationController
@project = Project.find(params[:project_id])
@applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
if @applieds.count == 0
- AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
+ appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
+ Mailer.applied_project(appliedproject).deliver
end
#redirect_to project_path(params[:project_id])
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 330e1cde6..b283b4792 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -23,6 +23,7 @@ class AttachmentsController < ApplicationController
before_filter :login_without_softapplication, only: [:download]
accept_api_auth :show, :download, :upload
+ require 'iconv'
def show
respond_to do |format|
@@ -49,19 +50,39 @@ class AttachmentsController < ApplicationController
end
def download
- if true || @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
+ # modify by nwb
+ # 下载添加权限设置
+ candown = false
+ if @attachment.container.has_attribute?(:project) && @attachment.container.project
+ project = @attachment.container.project
+ candown= User.current.member_of?(project)
+ elsif @attachment.container.is_a?(Project)
+ project = @attachment.container
+ candown= User.current.member_of?(project)
+ elsif @attachment.container.has_attribute?(:course) && @attachment.container.course
+ course = @attachment.container.course
+ candown= User.current.member_of_course?(course)
+ elsif @attachment.container.is_a?(Course)
+ course = @attachment.container
+ candown= User.current.member_of_course?(course)
+ elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3
+ candown = true
+ end
+ if candown || User.current.admin?
@attachment.increment_download
+ else
+ render_403 :message => :notice_not_authorized
end
+
if stale?(:etag => @attachment.digest)
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
- :type => detect_content_type(@attachment),
- :disposition => (@attachment.image? ? 'inline' : 'attachment')
+ :type => detect_content_type(@attachment),
+ :disposition => (@attachment.image? ? 'inline' : 'attachment')
end
rescue => e
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
- return
end
#更新资源文件类型
@@ -76,6 +97,25 @@ class AttachmentsController < ApplicationController
end
end
+ # 更新文件密级
+ def updateFileDense
+ @attachment = Attachment.find(params[:attachmentid])
+ if @attachment != nil
+ filedense = params[:newtype].to_s
+ # d = Iconv.conv("unicodebig","utf-8",filedense)
+ if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public)
+ @attachment.is_public = 1
+ else
+ @attachment.is_public = 0
+ end
+ @attachment.save
+ @newfiledense = filedense
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail)
@@ -90,6 +130,7 @@ class AttachmentsController < ApplicationController
end
end
+
def upload
# Make sure that API users get used to set this content type
# as it won't trigger Rails' automatic parsing of the request body for parameters
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 62b736294..a840ee934 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -746,7 +746,7 @@ class ProjectsController < ApplicationController
#Added by young
# @course_tag = params[:course]
# if @course_tag == '1'
- @course = Course.find_by_extra(@project.identifier)
+ #@course = Course.find_by_extra(@project.identifier)
# if @project.project_type == 1
# render :layout => 'base_courses'
# else
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index bf18332df..03bca6162 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -16,12 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WelcomeController < ApplicationController
+ include ApplicationHelper
caches_action :robots
# before_filter :fake, :only => [:index, :course]
before_filter :entry_select, :only => [:index]
def index
-
+ @first_page = FirstPage.where("page_type = 'project'").first
end
def robots
@@ -30,6 +31,7 @@ class WelcomeController < ApplicationController
end
def course
+ @course_page = FirstPage.where("page_type = 'course'").first
if params[:school_id]
@school_id = params[:school_id]
elsif User.current.logged? && User.current.user_extensions.school
@@ -41,13 +43,24 @@ class WelcomeController < ApplicationController
def logolink()
+ @course_page = FirstPage.where("page_type = 'course'").first
+ logo = get_avatar?(@course_page)
id = params[:school_id]
logo_link = ""
- if id.nil? and User.current.user_extensions.school.nil?
- logo_link = '/images/transparent.png'
+ if id.nil? && User.current.user_extensions.school.nil?
+ if logo
+ logo_link = url_to_avatar(@course_page)
+ else
+ logo_link = '/images/transparent.png'
+ end
+
else
if id == "0"
- logo_link = '/images/transparent.png'
+ if logo
+ logo_link = url_to_avatar(@course_page)
+ else
+ logo_link = '/images/transparent.png'
+ end
else
if id.nil?
if School.find(User.current.user_extensions.school.id).logo_link.nil?
@@ -66,7 +79,7 @@ class WelcomeController < ApplicationController
def contest
-
+ @contest_page = FirstPage.where("page_type = 'contest'").first
end
def search
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 0a84b7a55..4f6cb3e95 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -625,10 +625,15 @@ module ApplicationHelper
end
def html_title(*args)
+ first_page = FirstPage.where("page_type = 'project'").first
if args.empty?
title = @html_title || []
title << @project.name if @project
- title << Setting.app_title unless Setting.app_title == title.last
+ if first_page.nil? || first_page.web_title.nil?
+ title << Setting.app_title unless Setting.app_title == title.last
+ else
+ title << first_page.web_title unless first_page.web_title == title.last
+ end
title.select {|t| !t.blank? }.join(' - ')
else
@html_title ||= []
diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb
index 14105bf88..b43eb22f1 100644
--- a/app/helpers/attachments_helper.rb
+++ b/app/helpers/attachments_helper.rb
@@ -109,7 +109,7 @@ module AttachmentsHelper
domain = project.nil? ? attachAll : nobelong_attach
# 搜索到的资源
- searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
+ searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
#searched_attach = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10)
@@ -148,7 +148,7 @@ module AttachmentsHelper
domain = course.nil? ? attachAll : nobelong_attach
# 搜索到的资源
- searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
+ searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
#searched_attach = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10)
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 116e2de9a..0eb3e7666 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -196,6 +196,21 @@ class Attachment < ActiveRecord::Base
suffix
end
+ # 文件密级的字符描述
+ def file_dense_str
+ if self.is_public == 1
+ dense = l(:field_is_public)
+ else
+ dense = l(:field_is_private)
+ end
+ dense
+ end
+
+ # 文件可设置的密级列表
+ def file_dense_list
+ denselist = [l(:field_is_public),l(:field_is_private)]
+ end
+
def suffixArr
@@SuffixArr
end
diff --git a/app/models/course.rb b/app/models/course.rb
index 7db789a7a..248f80e0b 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -90,6 +90,18 @@ class Course < ActiveRecord::Base
false
end
+ # Returns the mail adresses of users that should be always notified on project events
+ def recipients
+ notified_users.collect {|user| user.mail}
+ end
+
+ # Returns the users that should be notified on project events
+ def notified_users
+ # TODO: User part should be extracted to User#notify_about?
+ members.select {|m| m.principal.present? && (m.mail_notification? || m.principal.mail_notification == 'all')}.collect {|m| m.principal}
+ end
+
+
# 课程的短描述信息
def short_description(length = 255)
description.gsub(/<\/?.*?>/,"").html_safe if description
@@ -124,6 +136,7 @@ class Course < ActiveRecord::Base
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
end
+
# 获取资源后缀名列表
def contenttypes
attachmenttypes
diff --git a/app/models/first_page.rb b/app/models/first_page.rb
new file mode 100644
index 000000000..8d8bbcff6
--- /dev/null
+++ b/app/models/first_page.rb
@@ -0,0 +1,3 @@
+class FirstPage < ActiveRecord::Base
+ attr_accessible :description, :title, :web_title
+end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index ef4996eac..131c72c8c 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -141,6 +141,19 @@ class Mailer < ActionMailer::Base
:subject => s
end
+ # 用户申请加入项目邮件通知
+ def applied_project(applied)
+ @project =applied.project
+ redmine_headers 'Project' => @project,
+ 'User' => applied.user
+ @user = applied.user
+ recipients = @project.manager_recipients
+ s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
+ @applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
+ mail :to => recipients,
+ :subject => s
+ end
+
def reminder(user, issues, days)
set_language_if_valid user.language
@issues = issues
@@ -177,25 +190,45 @@ class Mailer < ActionMailer::Base
added_to_url = ''
@author = attachments.first.author
case container.class.name
- when 'Project'
- added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
- added_to = "#{l(:label_project)}: #{container}"
- recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
- when 'Version'
- added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
- added_to = "#{l(:label_version)}: #{container.name}"
- recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail}
- when 'Document'
- added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
- added_to = "#{l(:label_document)}: #{container.title}"
- recipients = container.recipients
+ when 'Project'
+ added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
+ added_to = "#{l(:label_project)}: #{container}"
+ recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
+ when 'Course'
+ added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
+ added_to = "#{l(:label_course)}: #{container}"
+ recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
+ when 'Version'
+ added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
+ added_to = "#{l(:label_version)}: #{container.name}"
+ recipients = container.project.notified_users.select { |user| user.allowed_to?(:view_files, container.project) }.collect { |u| u.mail }
+ when 'Document'
+ added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
+ added_to = "#{l(:label_document)}: #{container.title}"
+ recipients = container.recipients
+ end
+ if container.class.name == 'Course'
+ redmine_headers 'Course' => container.id
+ @attachments = attachments
+ @added_to = added_to
+ @added_to_url = added_to_url
+ mail :to => recipients,
+ :subject => "[#{container.name}] #{l(:label_attachment_new)}"
+ elsif container.class.name == 'Project'
+ redmine_headers 'Project' => container.id
+ @attachments = attachments
+ @added_to = added_to
+ @added_to_url = added_to_url
+ mail :to => recipients,
+ :subject => "[#{container.name}] #{l(:label_attachment_new)}"
+ else
+ redmine_headers 'Project' => container.project.identifier
+ @attachments = attachments
+ @added_to = added_to
+ @added_to_url = added_to_url
+ mail :to => recipients,
+ :subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
end
- redmine_headers 'Project' => container.project.identifier
- @attachments = attachments
- @added_to = added_to
- @added_to_url = added_to_url
- mail :to => recipients,
- :subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
end
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
diff --git a/app/models/project.rb b/app/models/project.rb
index 4bd1f2774..698b1f26a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -207,6 +207,12 @@ class Project < ActiveRecord::Base
end
# end
+ # 管理员的邮件列表
+ def manager_recipients
+ notified = project.project_infos.collect(&:user)
+ notified.collect(&:mail)
+ end
+
def initialize(attributes=nil, *args)
super
diff --git a/app/views/admin/contest_page_made.html.erb b/app/views/admin/contest_page_made.html.erb
new file mode 100644
index 000000000..b8a86fa4d
--- /dev/null
+++ b/app/views/admin/contest_page_made.html.erb
@@ -0,0 +1,39 @@
+
<%=l(:label_first_page_made)%>
+
+<%= form_tag(:controller => 'admin', :action => 'contest_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %>
+ <%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %>
+ <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} , :class => 'selected'%>
+
+
+
+ <%=l(:label_contest_first_page)%>
+
+ <%= l(:label_site_image) %>:
+
+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>
+
+
+ <%= l(:label_site_title) %>:
+ <%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= l(:label_site_description)%>:
+ <%= text_area_tag 'contest_description',@contest_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= submit_tag l(:button_save), :class => "small", :name => nil %>
+<% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/course_page_made.html.erb b/app/views/admin/course_page_made.html.erb
new file mode 100644
index 000000000..4554fb8e0
--- /dev/null
+++ b/app/views/admin/course_page_made.html.erb
@@ -0,0 +1,37 @@
+<%=l(:label_first_page_made)%>
+
+<%= form_tag(:controller => 'admin', :action => 'course_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %>
+ <%= link_to l(:label_course_first_page), {:action => 'course_page_made'}, :class => 'selected' %>
+ <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %>
+
+
+ <%=l(:label_course_first_page)%>
+
+ <%= l(:label_site_image) %>:
+
+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>
+
+
+ <%= l(:label_site_title) %>:
+ <%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= l(:label_site_description)%>:
+ <%= text_area_tag 'course_description',@course_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= submit_tag l(:button_save), :class => "small", :name => nil %>
+<% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb
new file mode 100644
index 000000000..a64bbb443
--- /dev/null
+++ b/app/views/admin/first_page_made.html.erb
@@ -0,0 +1,38 @@
+<%=l(:label_first_page_made)%>
+
+<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+
+ <%= link_to l(:label_project_first_page), {:action => 'first_page_made'}, :class => 'selected' %>
+ <%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %>
+ <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %>
+
+
+ <%=l(:label_project_first_page)%>
+
+ <%= l(:label_site_image) %>:
+
+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
+
+
+
+ <%= l(:label_site_title) %>:
+ <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= l(:label_site_description)%>:
+ <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= submit_tag l(:button_save), :class => "small", :name => nil %>
+<% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/project_page_made.html.erb b/app/views/admin/project_page_made.html.erb
new file mode 100644
index 000000000..e338c21a9
--- /dev/null
+++ b/app/views/admin/project_page_made.html.erb
@@ -0,0 +1,31 @@
+<%=l(:label_first_page_made)%>
+
+<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
+
+ <%= l(:label_web_title) %>:
+ <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+ <%=l(:label_project_first_page)%>
+
+ <%= l(:label_site_image) %>:
+
+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
+
+
+
+ <%= l(:label_site_title) %>:
+ <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= l(:label_site_description)%>:
+ <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
+
+
+ <%= submit_tag l(:button_save), :class => "small", :name => nil %>
+<% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb
index d568dd63c..7f1887b23 100644
--- a/app/views/attachments/_form.html.erb
+++ b/app/views/attachments/_form.html.erb
@@ -3,10 +3,10 @@
<% container.attachments.each_with_index do |attachment, i| %>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
-
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") +
link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
+ <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, :class => 'is_public')%>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
<% end %>
diff --git a/app/views/attachments/updateFileDense.js.erb b/app/views/attachments/updateFileDense.js.erb
new file mode 100644
index 000000000..86fa36d4c
--- /dev/null
+++ b/app/views/attachments/updateFileDense.js.erb
@@ -0,0 +1,15 @@
+$('#edit-file-dense-form-<%= @attachment.id.to_s%>').hide();
+$('#field_file_dense_id_label<%= @attachment.id.to_s%>').show();
+$('#edit_box_dense<%= @attachment.id.to_s%>').show();
+<%if @attachment.is_public == 1%>
+$('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('公开');
+<%else%>
+$('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('私有');
+<%end%>
+// 下面2种写法都没起作用,暂时使用上面的非本地化模式
+// <%if @attachment.is_public == 1%>
+// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('<%l(:field_is_public)%>');
+// <%else%>
+// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html('<%l(:field_is_private)%>');
+// <%end%>
+// $('#field_file_dense_id_label<%= @attachment.id.to_s%>').html(<%=@newfiledense%>);
diff --git a/app/views/avatar/_avatar_form.html.erb b/app/views/avatar/_avatar_form.html.erb
index 272397c62..a880f32aa 100644
--- a/app/views/avatar/_avatar_form.html.erb
+++ b/app/views/avatar/_avatar_form.html.erb
@@ -45,6 +45,7 @@
<%= l(:button_upload_photo) %>
+
<%= file_field_tag 'avatar[image]',
:id => nil,
@@ -57,6 +58,8 @@
: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,
+ :file_type => Redmine::Configuration['pic_types'].to_s,
+ :type_support_message => l(:error_pic_type),
:upload_path => upload_avatar_path(:format => 'js'),
:description_placeholder => nil ,# l(:label_optional_description)
:source_type => source.class.to_s,
diff --git a/app/views/files/_course_file_dense_edit.html.erb b/app/views/files/_course_file_dense_edit.html.erb
new file mode 100644
index 000000000..53041ef14
--- /dev/null
+++ b/app/views/files/_course_file_dense_edit.html.erb
@@ -0,0 +1,13 @@
+<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
+<% if file_dense_list.any? %>
+
+ <%= select_tag "file_dense",
+ options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
+
+ <%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box_dense"+attachment.id.to_s ,
+ :onclick =>"$('#edit-file-dense-form-" +attachment.id.to_s+ "').show();
+ $('#field_file_dense_id_label" +attachment.id.to_s+ "').hide();
+ $('#edit_box_dense" +attachment.id.to_s+ "').hide();") if edit_allowed %>
+
+<% end %>
+
diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb
index 1a8a8ca65..a6da426c6 100644
--- a/app/views/files/_course_show_all_attachment.html.erb
+++ b/app/views/files/_course_show_all_attachment.html.erb
@@ -18,6 +18,7 @@
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
@@ -34,6 +35,9 @@
<% end -%>
<% container.attachments.each do |file| %>
+ <%if file.is_public == 0 && !User.current.member_of?(@project)%>
+ <%next%>
+ <%end%>
">
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
@@ -45,6 +49,14 @@
<%= file.show_suffix_type %>
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+
<%= file.downloads %>
diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb
index f73cac072..cda832493 100644
--- a/app/views/files/_course_sort_by_attachtypel.html.erb
+++ b/app/views/files/_course_sort_by_attachtypel.html.erb
@@ -5,66 +5,78 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
- <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
+ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
-
-
+
+
<% @containers.each do |container| %>
- <% next if container.attachments.empty? -%>
- <% container.attachments.each do |file| %>
- <% if isTypeOk(file,selAttachType,selContentType) %>
- ">
- <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
-
- <%= number_to_human_size(file.filesize) %>
-
- <%= file.attachmentstype.typeName %>
-
+ <% next if container.attachments.empty? -%>
+ <% container.attachments.each do |file| %>
+ <% if file.is_public == 0 && !User.current.member_of?(@project) %>
+ <% next %>
+ <% end %>
+ <% if isTypeOk(file, selAttachType, selContentType) %>
+ ">
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
+
+ <%= number_to_human_size(file.filesize) %>
+
+ <%= file.attachmentstype.typeName %>
+
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes,
- :attachment => file,:contentype=>selContentType} %>
+ :attachment => file, :contentype => selContentType} %>
-
- <%= file.show_suffix_type %>
- <%= file.downloads %>
-
-
- <%= link_to(image_tag('delete.png'), attachment_path(file),
- :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
-
-
-
-
-
-
-
-
- <% end -%>
- <% end -%>
- <% reset_cycle %>
- <% end -%>
-
-
+
+ <%= file.show_suffix_type %>
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+
+ <%= file.downloads %>
+
+
+ <%= link_to(image_tag('delete.png'), attachment_path(file),
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
+
+
+
+
+
+
+
+
+ <% end -%>
+ <% end -%>
+ <% reset_cycle %>
+ <% end -%>
+
+
diff --git a/app/views/files/_project_file_dense_edit.html.erb b/app/views/files/_project_file_dense_edit.html.erb
new file mode 100644
index 000000000..daa4b927d
--- /dev/null
+++ b/app/views/files/_project_file_dense_edit.html.erb
@@ -0,0 +1,13 @@
+<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
+<% if file_dense_list.any? %>
+
+ <%= select_tag "file_dense",
+ options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
+
+ <%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box_dense"+attachment.id.to_s ,
+ :onclick =>"$('#edit-file-dense-form-" +attachment.id.to_s+ "').show();
+ $('#field_file_dense_id_label" +attachment.id.to_s+ "').hide();
+ $('#edit_box_dense" +attachment.id.to_s+ "').hide();") if edit_allowed %>
+
+<% end %>
+
diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb
index 07dc6a27f..8c624d176 100644
--- a/app/views/files/_show_all_attachment.html.erb
+++ b/app/views/files/_show_all_attachment.html.erb
@@ -18,6 +18,7 @@
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
@@ -34,6 +35,9 @@
<% end -%>
<% container.attachments.each do |file| %>
+ <%if file.is_public == 0 && !User.current.member_of?(@project)%>
+ <%next%>
+ <%end%>
">
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
@@ -45,6 +49,14 @@
<%= file.show_suffix_type %>
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'project_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+
<%= file.downloads %>
diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb
index 01c57c490..d3723c340 100644
--- a/app/views/files/_sort_by_attachtypel.html.erb
+++ b/app/views/files/_sort_by_attachtypel.html.erb
@@ -5,66 +5,78 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
-
-
-
-
-
-
-
+
+
+
+
+
+
+
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
- <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
+ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
+ <%= sort_header_tag('field_file_dense', :caption => l(:field_file_dense), :default_order => 'desc', :scope => "col", :id => "vzebra-field_file_dense") %>
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
-
-
+
+
<% @containers.each do |container| %>
- <% next if container.attachments.empty? -%>
- <% container.attachments.each do |file| %>
- <% if isTypeOk(file,selAttachType,selContentType) %>
- ">
- <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
-
- <%= number_to_human_size(file.filesize) %>
-
- <%= file.attachmentstype.typeName %>
-
+ <% next if container.attachments.empty? -%>
+ <% container.attachments.each do |file| %>
+ <% if file.is_public == 0 && !User.current.member_of?(@project) %>
+ <% next %>
+ <% end %>
+ <% if isTypeOk(file, selAttachType, selContentType) %>
+ ">
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %>
+
+ <%= number_to_human_size(file.filesize) %>
+
+ <%= file.attachmentstype.typeName %>
+
<%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes,
- :attachment => file,:contentype=>selContentType} %>
+ :attachment => file, :contentype => selContentType} %>
-
- <%= file.show_suffix_type %>
- <%= file.downloads %>
-
-
- <%= link_to(image_tag('delete.png'), attachment_path(file),
- :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
-
-
-
-
-
-
-
-
- <% end -%>
- <% end -%>
- <% reset_cycle %>
- <% end -%>
-
-
+
+ <%= file.show_suffix_type %>
+
+ <%= file.file_dense_str %>
+
+
+ <%= render :partial => 'project_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
+ :attachment => file} %>
+
+
+ <%= file.downloads %>
+
+
+ <%= link_to(image_tag('delete.png'), attachment_path(file),
+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
+
+
+
+
+
+
+
+
+ <% end -%>
+ <% end -%>
+ <% reset_cycle %>
+ <% end -%>
+
+
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index b086b90db..69b41fc28 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -207,6 +207,23 @@
<%end%>
}
+
+ // 编辑文件密级
+ function file_dense_edit(id, type) {
+ $.ajax({
+ url: '<%=updateFileDense_attachments_path%>',
+ type: "POST",
+ remote:"true",
+ data: {
+ attachmentid: encodeURIComponent(id),
+ newtype: encodeURIComponent(type)
+ }
+
+ }).complete(function (xhr, textStatus) {
+ });
+
+ }
+
diff --git a/app/views/mailer/applied_project.html.erb b/app/views/mailer/applied_project.html.erb
new file mode 100644
index 000000000..4f266e6ce
--- /dev/null
+++ b/app/views/mailer/applied_project.html.erb
@@ -0,0 +1,5 @@
+<%= l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name) %>
+
+
+<%= link_to(h(@project.name), @applied_url) %>
+
diff --git a/app/views/mailer/applied_project.text.erb b/app/views/mailer/applied_project.text.erb
new file mode 100644
index 000000000..7af8c2018
--- /dev/null
+++ b/app/views/mailer/applied_project.text.erb
@@ -0,0 +1,4 @@
+<%= l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name) %>
+
+<%= link_to(h(@project.name), @applied_url) %>
+
diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb
index 43687aa78..0f5d96a45 100644
--- a/app/views/users/_score_new_index.html.erb
+++ b/app/views/users/_score_new_index.html.erb
@@ -28,7 +28,7 @@
= <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> +
<%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
- = <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_f %>
- + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
- = <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_f %>
+ = <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_i %>
+ + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
+ = <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_i %>
diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb
index c5f15694e..fddca46ac 100644
--- a/app/views/users/_show_new_score.html.erb
+++ b/app/views/users/_show_new_score.html.erb
@@ -38,7 +38,7 @@
<%= l(:label_user_score) %>
- <%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
@@ -49,23 +49,23 @@
<%= link_to l(:label_user_score) , {:controller => 'users', :action => 'score_new_index', :remote => true} %> :
- <%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= link_to l(:label_user_score_of_collaboration), {:controller => 'users',:action => 'topic_new_score_index', :remote => true} %> :
- <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= link_to l(:label_user_score_of_influence), {:controller => 'users',:action => 'project_new_score_index', :remote => true} %> :
- <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= link_to l(:label_user_score_of_skill), {:controller => 'users',:action => 'activity_new_score_index', :remote => true} %> :
- <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= link_to l(:label_user_score_of_active), {:controller => 'users',:action => 'influence_new_score_index', :remote => true} %> :
- <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/users/_user_score.html.erb b/app/views/users/_user_score.html.erb
index d047c11d0..53f05a2dd 100644
--- a/app/views/users/_user_score.html.erb
+++ b/app/views/users/_user_score.html.erb
@@ -1,5 +1,5 @@
<%= l(:label_user_grade)%>:
-<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_f, {:controller => 'users',
+<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_i, {:controller => 'users',
:action => 'show_new_score',
:remote => true,
:id => user.id
diff --git a/app/views/users/show_new_score.html.erb b/app/views/users/show_new_score.html.erb
index 07e82fd5f..0efae940c 100644
--- a/app/views/users/show_new_score.html.erb
+++ b/app/views/users/show_new_score.html.erb
@@ -53,7 +53,7 @@
<%= l(:label_user_score) %>
- <%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
@@ -64,23 +64,23 @@
<%= l(:label_user_score) %> :
- <%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= l(:label_user_score_of_collaboration) %> :
- <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= l(:label_user_score_of_influence) %> :
- <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= l(:label_user_score_of_skill) %> :
- <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= l(:label_user_score_of_active) %> :
- <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
+ <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb
index c87cc13e1..c3bd120da 100644
--- a/app/views/welcome/contest.html.erb
+++ b/app/views/welcome/contest.html.erb
@@ -114,12 +114,17 @@
- <%= image_tag '/images/transparent.png', size: "75x75" %>
+ <% if get_avatar?(@contest_page) %>
+ <%= image_tag(url_to_avatar(@contest_page), size: "75x75") %>
+ <% else %>
+ <%= image_tag '/images/transparent.png', size: "75x75" %>
+ <% end %>
-
- <%= l(:label_welcome_trustie) %> <%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
-
+ <% unless @contest_page.nil? %>
+
<%= @contest_page.title %> , <%= @contest_page.description %>
+ <% end %>
+
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb
index cfde8fca4..f6bffe51c 100644
--- a/app/views/welcome/course.html.erb
+++ b/app/views/welcome/course.html.erb
@@ -51,14 +51,17 @@
<% end %>
<% end %>
<% end %>
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %>
+ <% unless @course_page.nil? %>
+ <%= @course_page.title %>
+
<% if @school_id.nil? and User.current.user_extensions.school.nil? %>
- , <%= l(:label_welcome_trustie_course_description) %>
+ , <%= @course_page.description %>
<% else %>
<% if @school_id == "0" %>
- , <%= l(:label_welcome_trustie_course_description) %>
+ , <%= @course_page.description %>
<% end %>
<% end %>
+ <% end %>
<%= render :partial => "search_course", :locals => {:project_type => Project::ProjectType_course} %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index 67cbb3bd0..0cc5c5e2a 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -30,13 +30,21 @@
<%= link_to image_tag('/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" ), home_path %>
微信扫码
-
+
- <%= image_tag '/images/transparent.png', size: "75x75" %>
+
+ <% if get_avatar?(@first_page) %>
+ <%= image_tag(url_to_avatar(@first_page), size: "75x75") %>
+ <% else %>
+ <%= image_tag '/images/transparent.png', size: "75x75" %>
+ <% end %>
+
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %> , <%= l(:label_welcome_trustie_project_description) %>
+ <% unless @first_page.nil? %>
+ <%= @first_page.title %> , <%= @first_page.description %>
+ <% end %>
<%= render :partial => "search_project", :locals => {:project_type => 0}%>
diff --git a/config/configuration.yml b/config/configuration.yml
index a98ea3391..4bdd279aa 100644
--- a/config/configuration.yml
+++ b/config/configuration.yml
@@ -199,6 +199,7 @@ default:
# Maximum number of simultaneous AJAX uploads
#max_concurrent_ajax_uploads: 2
+ #pic_types: "bmp,jpeg,jpg,png,gif"
# specific configuration options for production environment
# that overrides the default ones
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a23bbfadb..6566564c9 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -233,6 +233,7 @@ en:
field_mail: Email
field_job_category: Job category # added by bai
field_filename: File
+ field_file_dense: File Dense
field_filesize: Size
field_downloads: Downloads
field_author: Author
@@ -1079,6 +1080,7 @@ en:
text_session_expiration_settings: "Warning: changing these settings may expire the current sessions including yours."
text_project_closed: This project is closed and read-only.
text_turning_multiple_off: "If you disable multiple values, multiple values will be removed in order to preserve only one value per item."
+ text_applied_project: "User %{id} Apply Join Project %{project}"
default_role_manager: Manager
default_role_developer: Developer
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 2fe9f754e..d3377fca9 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -251,6 +251,7 @@ zh:
field_lastname_eg: '(例:张三丰,请填写[张])'
field_mail: 邮件地址
field_filename: 文件
+ field_file_dense: 文件密级
field_filesize: 大小
field_downloads: 下载次数
field_author: 作者
@@ -515,6 +516,10 @@ zh:
label_project_new_description: '项目可以是软件开发项目,也可以是协作研究项目。'
label_project_plural: 项目列表
label_project_score: 项目评分
+ label_first_page_made: 首页定制
+ label_project_first_page: 项目托管平台首页
+ label_course_first_page: 课程实践平台首页
+ label_contest_first_page: 竞赛实战平台首页
label_x_projects:
zero: 无项目
one: 1 个项目
@@ -561,6 +566,10 @@ zh:
label_login_with_open_id_option: 或使用OpenID登录
label_password_lost: 忘记密码
label_home: 主页
+ label_web_title: 浏览器标题
+ label_site_title: 网站标题
+ label_site_description: 网站简介
+ label_site_image: 简介图片
#by young
label_requirement: 需求
label_new_course: 课程列表
@@ -1119,6 +1128,7 @@ zh:
text_own_membership_delete_confirmation: 你正在删除你现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该项目了。你确定要继续吗?
text_zoom_in: 放大
text_zoom_out: 缩小
+ text_applied_project: "用户 %{id} 申请加入项目 %{project}"
default_role_manager: 管理人员
default_role_developer: 开发人员
@@ -1217,6 +1227,7 @@ zh:
button_export: 导出
label_export_options: "%{export_format} 导出选项"
error_attachment_too_big: 该文件无法上传。超过文件大小限制 (%{max_size})
+ error_pic_type: "仅支持如下图片格式:"
notice_failed_to_save_time_entries: "无法保存下列所选取的 %{total} 个项目中的 %{count} 工时: %{ids}。"
label_x_issues:
zero: 0 问题
diff --git a/config/routes.rb b/config/routes.rb
index f9dd53cf3..dfb8d503b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -515,6 +515,7 @@ RedmineApp::Application.routes.draw do
resources :attachments, :only => [:show, :destroy] do
collection do
match "updateType" , via: [:get, :post]
+ match "updateFileDense" , via: [:get, :post]
match "renderTag" , via: [:get, :post]
end
end
@@ -558,6 +559,9 @@ RedmineApp::Application.routes.draw do
match 'admin', :controller => 'admin', :action => 'index', :via => :get
match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
match 'admin/users', :controller => 'admin', :action => 'users', :via => :get
+ match 'admin/first_page_made',:controller => 'admin',:action => 'first_page_made',:via => [:get,:post]
+ match 'admin/course_page_made',:controller => 'admin',:action => 'course_page_made',:via => [:get,:post]
+ match 'admin/contest_page_made',:controller => 'admin',:action => 'contest_page_made',:via => [:get,:post]
match 'admin/search', :controller => 'admin', :action => 'search', :via => [:get, :post]
match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
diff --git a/db/migrate/20140710024054_add_is_public_to_attachment.rb b/db/migrate/20140710024054_add_is_public_to_attachment.rb
new file mode 100644
index 000000000..2276304c8
--- /dev/null
+++ b/db/migrate/20140710024054_add_is_public_to_attachment.rb
@@ -0,0 +1,5 @@
+class AddIsPublicToAttachment < ActiveRecord::Migration
+ def change
+ add_column :attachments, :is_public, :integer,:default => 1
+ end
+end
diff --git a/db/migrate/20140710030426_update_attachment_public_attr.rb b/db/migrate/20140710030426_update_attachment_public_attr.rb
new file mode 100644
index 000000000..339c52543
--- /dev/null
+++ b/db/migrate/20140710030426_update_attachment_public_attr.rb
@@ -0,0 +1,22 @@
+class UpdateAttachmentPublicAttr < ActiveRecord::Migration
+ def up
+ # 更新资源文件的is_public属性
+ Attachment.all.each do |res|
+ if res.is_public
+ if(res.container.nil? ||
+ (res.container.class.to_s=="Project" && res.container.is_public == false) ||
+ (res.container.has_attribute?(:project) && res.container.project && res.container.project.is_public == false) ||
+ (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
+ (res.container.class.to_s=="Course" && res.container.is_public == false) ||
+ (res.container.has_attribute?(:course) && res.container.course && res.container.course.is_public == false)
+ )
+ res.is_public = false
+ res.save
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20140710071720_create_first_pages.rb b/db/migrate/20140710071720_create_first_pages.rb
new file mode 100644
index 000000000..fa7d01601
--- /dev/null
+++ b/db/migrate/20140710071720_create_first_pages.rb
@@ -0,0 +1,17 @@
+# -*coding:utf-8 -*-
+class CreateFirstPages < ActiveRecord::Migration
+ def change
+ create_table :first_pages do |t|
+ t.string :web_title
+ t.string :title
+ t.string :description
+
+ t.timestamps
+ end
+ fp = FirstPage.new
+ fp.web_title = "Trustie - 为大学生技术创新筑巢"
+ fp.title = "Trustie在线项目托管平台"
+ fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。"
+ fp.save
+ end
+end
diff --git a/db/migrate/20140710095123_add_cloumn_to_first_page.rb b/db/migrate/20140710095123_add_cloumn_to_first_page.rb
new file mode 100644
index 000000000..6720a8aa4
--- /dev/null
+++ b/db/migrate/20140710095123_add_cloumn_to_first_page.rb
@@ -0,0 +1,9 @@
+class AddCloumnToFirstPage < ActiveRecord::Migration
+ def change
+ add_column :first_pages,:type,:string
+
+ fr = FirstPage.all.first
+ fr.type = "project"
+ fr.save
+ end
+end
diff --git a/db/migrate/20140711010124_alt_column_name.rb b/db/migrate/20140711010124_alt_column_name.rb
new file mode 100644
index 000000000..24b784765
--- /dev/null
+++ b/db/migrate/20140711010124_alt_column_name.rb
@@ -0,0 +1,5 @@
+class AltColumnName < ActiveRecord::Migration
+ def change
+ rename_column :first_pages,:type,:page_type
+ end
+end
diff --git a/db/migrate/20140711012924_add_contest_and_course_first_page.rb b/db/migrate/20140711012924_add_contest_and_course_first_page.rb
new file mode 100644
index 000000000..801219bd5
--- /dev/null
+++ b/db/migrate/20140711012924_add_contest_and_course_first_page.rb
@@ -0,0 +1,17 @@
+# -*coding:utf-8 -*-
+class AddContestAndCourseFirstPage < ActiveRecord::Migration
+ def change
+ fp = FirstPage.new
+ fp.web_title = ""
+ fp.title = "Trustie在线课程实践平台"
+ fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
+ fp.page_type = "course"
+ fp.save
+ fp1 = FirstPage.new
+ fp1.web_title = ""
+ fp1.title = "Trustie在线竞赛实战平台"
+ fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
+ fp1.page_type = "contest"
+ fp1.save
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 26c82491d..fa41ed1d5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140708023356) do
+ActiveRecord::Schema.define(:version => 20140711012924) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -51,6 +51,7 @@ ActiveRecord::Schema.define(:version => 20140708023356) do
t.string "description"
t.string "disk_directory"
t.integer "attachtype", :default => 1
+ t.integer "is_public", :default => 1
end
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
@@ -406,6 +407,15 @@ ActiveRecord::Schema.define(:version => 20140708023356) do
add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type"
add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id"
+ create_table "first_pages", :force => true do |t|
+ t.string "web_title"
+ t.string "title"
+ t.string "description"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "page_type"
+ end
+
create_table "forums", :force => true do |t|
t.string "name", :null => false
t.string "description", :default => ""
@@ -794,7 +804,7 @@ ActiveRecord::Schema.define(:version => 20140708023356) do
end
create_table "relative_memos", :force => true do |t|
- t.integer "osp_id", :null => false
+ t.integer "osp_id"
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :null => false
@@ -831,19 +841,6 @@ ActiveRecord::Schema.define(:version => 20140708023356) do
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
- create_table "rich_rich_files", :force => true do |t|
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "rich_file_file_name"
- t.string "rich_file_content_type"
- t.integer "rich_file_file_size"
- t.datetime "rich_file_updated_at"
- t.string "owner_type"
- t.integer "owner_id"
- t.text "uri_cache"
- t.string "simplified_type", :default => "file"
- end
-
create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index 30bbaedda..1318f8afa 100644
--- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -60,11 +60,28 @@ module Redmine
@unsaved_attachments ||= []
end
+ # 设置资源文件的公开属性
+ # add by nwb
+ def set_attachment_public(res)
+ # 公开的资源判断他的父级的公开属性
+ if res.is_public
+ if( (self.class.to_s=="Project" && self.is_public == false) ||
+ (self.has_attribute?(:project) && self.project && self.project.is_public == false) ||
+ (self.class.to_s=="HomeworkAttach" && self.bid.reward_type == 3) ||
+ (self.class.to_s=="Course" && self.is_public == false) ||
+ (self.has_attribute?(:course) && self.course && self.course.is_public == false)
+ )
+ res.is_public = false
+ end
+ end
+ end
+
def save_attachmentsex(attachments, author=User.current,attachment_type)
@curattachment_type = attachment_type
result = save_attachments(attachments,author)
result
end
+
def save_attachments(attachments, author=User.current)
if attachments.is_a?(Hash)
attachments = attachments.stringify_keys
@@ -94,6 +111,10 @@ module Redmine
a.filename = attachment['filename'] unless attachment['filename'].blank?
a.content_type = attachment['content_type']
end
+ if !attachment[:is_public]
+ a.is_public = false
+ end
+ set_attachment_public(a)
next unless a
a.description = attachment['description'].to_s.strip
a.attachtype = @curattachment_type;
diff --git a/lib/redmine.rb b/lib/redmine.rb
index e17d657c8..6215a04ba 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -351,6 +351,7 @@ end
Redmine::MenuManager.map :admin_menu do |menu|
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
+ menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made
menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
diff --git a/lib/redmine/configuration.rb b/lib/redmine/configuration.rb
index 6723b777e..ba8e91294 100644
--- a/lib/redmine/configuration.rb
+++ b/lib/redmine/configuration.rb
@@ -21,7 +21,8 @@ module Redmine
# Configuration default values
@defaults = {
'email_delivery' => nil,
- 'max_concurrent_ajax_uploads' => 2
+ 'max_concurrent_ajax_uploads' => 2,
+ 'pic_types' => "bmp,jpeg,jpg,png,gif"
}
@config = nil
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js
index 663183b9a..c60a77bd3 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -23,7 +23,9 @@ function addFile(inputEl, file, eagerUpload) {
fileSpan.append(
$('
', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
$('
', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
- $('
  ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload),
+ $('
公开: ').attr({ 'class': 'ispublic-label' }) ,
+ $('
', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public]', checked:'checked' } ).toggle(!eagerUpload),
+ $('
  ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload),
$('
', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
).appendTo('#attachments_fields');
@@ -63,6 +65,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
.done(function(result) {
progressSpan.progressbar( 'value', 100 ).remove();
fileSpan.find('input.description, a').css('display', 'inline-block');
+ fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
diff --git a/public/javascripts/avatars.js b/public/javascripts/avatars.js
index 24bc1ee1c..db9a2255e 100644
--- a/public/javascripts/avatars.js
+++ b/public/javascripts/avatars.js
@@ -140,10 +140,34 @@ function uploadAndAttachFiles(files, inputEl) {
if (sizeExceeded) {
window.alert(maxFileSizeExceeded);
} else {
- $.each(files, function() {addFile(inputEl, this, true);});
+ uploadAndTypeFiles(files,inputEl);
+ //$.each(files, function() {addFile(inputEl, this, true);});
}
}
+function uploadAndTypeFiles(files, inputEl) {
+
+ var enableType = $(inputEl).data('file-type');
+ var typeSupportrdMessage = $(inputEl).data('type-support-message');
+ if (enableType == null || enableType.trim() == "")
+ {
+ $.each(files, function() {addFile(inputEl, this, true);});
+ return;
+ }
+ var typeSupported = false;
+ $.each(files, function() {
+ var a = this.name.split('.');
+ var type = a[a.length-1];
+ var rs = enableType.indexOf(type);
+ if(rs >= 0) {typeSupported = true }
+ });
+ if (typeSupported) {
+ $.each(files, function() {addFile(inputEl, this, true);});
+ } else {
+ window.alert(typeSupportrdMessage + enableType);
+ }
+}
+
function handleFileDropEvent(e) {
$(this).removeClass('fileover');
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 89ee39ada..aae90eb4e 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1843,6 +1843,7 @@ span.required {color: #bb0000;}
.summary {font-style: italic;}
#attachments_fields input.description {margin-left:4px; width:100px; }
+#attachments_fields span {display:block; white-space:nowrap;}
#attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';}
#attachments_fields input.filename {border:0; height:1.8em; width:150px; color:#555; background-color:inherit; background:url(../images/attachment.png) no-repeat 1px 50%; padding-left:18px;}/*Modified by young*/
#attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;}
@@ -1850,6 +1851,8 @@ span.required {color: #bb0000;}
#attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;}
a.remove-upload:hover {text-decoration:none !important;}
+#attachments_fields input.is_public_checkbox {width:20px;}
+#attachments_fields span.ispublic-label {display:inline-block;width:50px;margin-left:10px; }
/*gcm upload file count and deleteall*/
#upload_file_count #count {color:red; font-size:1.5em;}
diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css
index 012b99c6d..03a2349a2 100644
--- a/public/stylesheets/nyan.css
+++ b/public/stylesheets/nyan.css
@@ -1151,6 +1151,11 @@ div.tags_area {
border-bottom: 1px solid #c8d4fd;
}
+#ver-zebra #vzebra-field_file_dense, #ver-zebra #vzebra-children {
+ background: #ffffff;
+ border-bottom: 1px solid #c8d4fd;
+}
+
#ver-zebra #vzebra-comedy, #ver-zebra #vzebra-action {
background: #ffffff;
border-bottom: 1px solid #d6dfff;
diff --git a/test/fixtures/first_pages.yml b/test/fixtures/first_pages.yml
new file mode 100644
index 000000000..5af4dd417
--- /dev/null
+++ b/test/fixtures/first_pages.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ web_title: MyString
+ title: MyString
+ description: MyString
+
+two:
+ web_title: MyString
+ title: MyString
+ description: MyString
diff --git a/test/unit/first_page_test.rb b/test/unit/first_page_test.rb
new file mode 100644
index 000000000..77e2cc97a
--- /dev/null
+++ b/test/unit/first_page_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class FirstPageTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end