This commit is contained in:
sw 2014-07-11 14:52:15 +08:00
commit 59a5541e45
55 changed files with 839 additions and 172 deletions

View File

@ -234,4 +234,96 @@ class AdminController < ApplicationController
format.api format.api
end end
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 end

View File

@ -6,7 +6,8 @@ class AppliedProjectController < ApplicationController
@project = Project.find(params[:project_id]) @project = Project.find(params[:project_id])
@applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
if @applieds.count == 0 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 end
#redirect_to project_path(params[:project_id]) #redirect_to project_path(params[:project_id])

View File

@ -23,6 +23,7 @@ class AttachmentsController < ApplicationController
before_filter :login_without_softapplication, only: [:download] before_filter :login_without_softapplication, only: [:download]
accept_api_auth :show, :download, :upload accept_api_auth :show, :download, :upload
require 'iconv'
def show def show
respond_to do |format| respond_to do |format|
@ -49,19 +50,39 @@ class AttachmentsController < ApplicationController
end end
def download def download
if true || @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project) # modify by nwb
@attachment.increment_download # 下载添加权限设置
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 end
if candown || User.current.admin?
@attachment.increment_download
else
render_403 :message => :notice_not_authorized
end
if stale?(:etag => @attachment.digest) if stale?(:etag => @attachment.digest)
# images are sent inline # images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment), :type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment') :disposition => (@attachment.image? ? 'inline' : 'attachment')
end end
rescue => e rescue => e
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
return
end end
#更新资源文件类型 #更新资源文件类型
@ -76,6 +97,25 @@ class AttachmentsController < ApplicationController
end end
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 def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail) if stale?(:etag => thumbnail)
@ -90,6 +130,7 @@ class AttachmentsController < ApplicationController
end end
end end
def upload def upload
# Make sure that API users get used to set this content type # 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 # as it won't trigger Rails' automatic parsing of the request body for parameters

View File

@ -746,7 +746,7 @@ class ProjectsController < ApplicationController
#Added by young #Added by young
# @course_tag = params[:course] # @course_tag = params[:course]
# if @course_tag == '1' # if @course_tag == '1'
@course = Course.find_by_extra(@project.identifier) #@course = Course.find_by_extra(@project.identifier)
# if @project.project_type == 1 # if @project.project_type == 1
# render :layout => 'base_courses' # render :layout => 'base_courses'
# else # else

View File

@ -16,12 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WelcomeController < ApplicationController class WelcomeController < ApplicationController
include ApplicationHelper
caches_action :robots caches_action :robots
# before_filter :fake, :only => [:index, :course] # before_filter :fake, :only => [:index, :course]
before_filter :entry_select, :only => [:index] before_filter :entry_select, :only => [:index]
def index def index
@first_page = FirstPage.where("page_type = 'project'").first
end end
def robots def robots
@ -30,6 +31,7 @@ class WelcomeController < ApplicationController
end end
def course def course
@course_page = FirstPage.where("page_type = 'course'").first
if params[:school_id] if params[:school_id]
@school_id = params[:school_id] @school_id = params[:school_id]
elsif User.current.logged? && User.current.user_extensions.school elsif User.current.logged? && User.current.user_extensions.school
@ -41,13 +43,24 @@ class WelcomeController < ApplicationController
def logolink() def logolink()
@course_page = FirstPage.where("page_type = 'course'").first
logo = get_avatar?(@course_page)
id = params[:school_id] id = params[:school_id]
logo_link = "" logo_link = ""
if id.nil? and User.current.user_extensions.school.nil? if id.nil? && User.current.user_extensions.school.nil?
logo_link = '/images/transparent.png' if logo
logo_link = url_to_avatar(@course_page)
else
logo_link = '/images/transparent.png'
end
else else
if id == "0" 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 else
if id.nil? if id.nil?
if School.find(User.current.user_extensions.school.id).logo_link.nil? if School.find(User.current.user_extensions.school.id).logo_link.nil?
@ -66,7 +79,7 @@ class WelcomeController < ApplicationController
def contest def contest
@contest_page = FirstPage.where("page_type = 'contest'").first
end end
def search def search

View File

@ -625,10 +625,15 @@ module ApplicationHelper
end end
def html_title(*args) def html_title(*args)
first_page = FirstPage.where("page_type = 'project'").first
if args.empty? if args.empty?
title = @html_title || [] title = @html_title || []
title << @project.name if @project 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(' - ') title.select {|t| !t.blank? }.join(' - ')
else else
@html_title ||= [] @html_title ||= []

View File

@ -109,7 +109,7 @@ module AttachmentsHelper
domain = project.nil? ? attachAll : nobelong_attach 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 = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10) searched_attach = paginateHelper(searched_attach, 10)
@ -148,7 +148,7 @@ module AttachmentsHelper
domain = course.nil? ? attachAll : nobelong_attach 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 = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10) searched_attach = paginateHelper(searched_attach, 10)

View File

@ -196,6 +196,21 @@ class Attachment < ActiveRecord::Base
suffix suffix
end 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 def suffixArr
@@SuffixArr @@SuffixArr
end end

View File

@ -90,6 +90,18 @@ class Course < ActiveRecord::Base
false false
end 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) def short_description(length = 255)
description.gsub(/<\/?.*?>/,"").html_safe if description 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 ]) @attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
end end
# 获取资源后缀名列表 # 获取资源后缀名列表
def contenttypes def contenttypes
attachmenttypes attachmenttypes

3
app/models/first_page.rb Normal file
View File

@ -0,0 +1,3 @@
class FirstPage < ActiveRecord::Base
attr_accessible :description, :title, :web_title
end

View File

@ -141,6 +141,19 @@ class Mailer < ActionMailer::Base
:subject => s :subject => s
end 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) def reminder(user, issues, days)
set_language_if_valid user.language set_language_if_valid user.language
@issues = issues @issues = issues
@ -177,25 +190,45 @@ class Mailer < ActionMailer::Base
added_to_url = '' added_to_url = ''
@author = attachments.first.author @author = attachments.first.author
case container.class.name case container.class.name
when 'Project' when 'Project'
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container) added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
added_to = "#{l(:label_project)}: #{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} recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
when 'Version' when 'Course'
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project) added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
added_to = "#{l(:label_version)}: #{container.name}" added_to = "#{l(:label_course)}: #{container}"
recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}.collect {|u| u.mail} recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
when 'Document' when 'Version'
added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id) added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
added_to = "#{l(:label_document)}: #{container.title}" added_to = "#{l(:label_version)}: #{container.name}"
recipients = container.recipients 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 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 end
# Builds a Mail::Message object used to email recipients of a news' project when a news item is added. # Builds a Mail::Message object used to email recipients of a news' project when a news item is added.

View File

@ -207,6 +207,12 @@ class Project < ActiveRecord::Base
end end
# end # end
# 管理员的邮件列表
def manager_recipients
notified = project.project_infos.collect(&:user)
notified.collect(&:mail)
end
def initialize(attributes=nil, *args) def initialize(attributes=nil, *args)
super super

View File

@ -0,0 +1,39 @@
<h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'contest_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<div class="tabs">
<ul>
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %></li>
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %></li>
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} , :class => 'selected'%></li>
</ul>
</div>
<h4><%=l(:label_contest_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p>
<div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>
</div>
<p style="margin-left:60px;padding-right: 20px;">
<label for='contest_title'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_title) %>:</label>
<%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='contest_description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<%= text_area_tag 'contest_description',@contest_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

View File

@ -0,0 +1,37 @@
<h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'course_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<div class="tabs">
<ul>
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %></li>
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'}, :class => 'selected' %></li>
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %></li>
</ul>
</div>
<h4><%=l(:label_course_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p>
<div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>
</div>
<p style="margin-left:60px;padding-right: 20px;">
<label for='course_title'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_title) %>:</label>
<%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='course_description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<%= text_area_tag 'course_description',@course_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

View File

@ -0,0 +1,38 @@
<h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<div class="tabs">
<ul>
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'}, :class => 'selected' %></li>
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %></li>
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %></li>
</ul>
</div>
<h4><%=l(:label_project_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p>
<div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
</div>
<p style="margin-left:60px;padding-right: 20px;">
<label for='title'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_title) %>:</label>
<%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

View File

@ -0,0 +1,31 @@
<h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<h4><%=l(:label_project_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p>
<div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
</div>
<p style="margin-left:60px;padding-right: 20px;">
<label for='title'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_title) %>:</label>
<%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

View File

@ -3,10 +3,10 @@
<% container.attachments.each_with_index do |attachment, i| %> <% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment"> <span id="attachments_p<%= i %>" class="attachment">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> <%= 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;") + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") +
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> link_to('&nbsp;'.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"} %> <%#= 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}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>
<% end %> <% end %>

View File

@ -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%>);

View File

@ -45,6 +45,7 @@
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;"> <a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
<span><%= l(:button_upload_photo) %></span> <span><%= l(:button_upload_photo) %></span>
</a> </a>
<!-- :accept => 'image/png,image/gif,image/jpeg', -->
<span class="add_avatar" style="margin-left: -55px;width: 70px"> <span class="add_avatar" style="margin-left: -55px;width: 70px">
<%= file_field_tag 'avatar[image]', <%= file_field_tag 'avatar[image]',
:id => nil, :id => nil,
@ -57,6 +58,8 @@
:max_file_size => Setting.attachment_max_size.to_i.kilobytes, :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_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, :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'), :upload_path => upload_avatar_path(:format => 'js'),
:description_placeholder => nil ,# l(:label_optional_description) :description_placeholder => nil ,# l(:label_optional_description)
:source_type => source.class.to_s, :source_type => source.class.to_s,

View File

@ -0,0 +1,13 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
<% if file_dense_list.any? %>
<div id="edit-file-dense-form-<%=attachment.id%>" class="hidden">
<%= select_tag "file_dense",
options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
</div>
<%= 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 %>

View File

@ -18,6 +18,7 @@
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %> <%= 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('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('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
@ -34,6 +35,9 @@
</tr> </tr>
<% end -%> <% end -%>
<% container.attachments.each do |file| %> <% container.attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of?(@project)%>
<%next%>
<%end%>
<tr class="file <%= cycle("odd", "odd") %>"> <tr class="file <%= cycle("odd", "odd") %>">
<td class="filename" style="font-size: 13px; "><%= 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;" %></td> <td class="filename" style="font-size: 13px; "><%= 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;" %></td>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> --> <!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
@ -45,6 +49,14 @@
</span> </span>
</td> </td>
<td class="content_type"><%= file.show_suffix_type %></td> <td class="content_type"><%= file.show_suffix_type %></td>
<td class="field_file_dense">
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
&nbsp;
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
:attachment => file} %>
</span>
</td>
<td class="downloads"><%= file.downloads %></td> <td class="downloads"><%= file.downloads %></td>
<!-- <td class="digest" width="300px"><%= file.description %></td> --> <!-- <td class="digest" width="300px"><%= file.description %></td> -->
<td align="center"> <td align="center">

View File

@ -5,66 +5,78 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %> <% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
<table class="list files" id="ver-zebra"> <table class="list files" id="ver-zebra">
<colgroup> <colgroup>
<col class="vzebra-odd"/> <col class="vzebra-odd"/>
<col class="vzebra-even"/> <col class="vzebra-even"/>
<col class="vzebra-odd"/> <col class="vzebra-odd"/>
<col class="vzebra-even"/> <col class="vzebra-even"/>
<!-- <col class="vzebra-odd"/> --> <!-- <col class="vzebra-odd"/> -->
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %> <%= 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('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('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('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('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @containers.each do |container| %> <% @containers.each do |container| %>
<% next if container.attachments.empty? -%> <% next if container.attachments.empty? -%>
<% container.attachments.each do |file| %> <% container.attachments.each do |file| %>
<% if isTypeOk(file,selAttachType,selContentType) %> <% if file.is_public == 0 && !User.current.member_of?(@project) %>
<tr class="file <%= cycle("odd", "odd") %>"> <% next %>
<td class="filename" style="font-size: 13px; "><%= 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;" %></td> <% end %>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> --> <% if isTypeOk(file, selAttachType, selContentType) %>
<td class="filesize"><%= number_to_human_size(file.filesize) %></td> <tr class="file <%= cycle("odd", "odd") %>">
<td class="attach_type"> <td class="filename" style="font-size: 13px; "><%= 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;" %></td>
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span> <!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
&nbsp; <td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
&nbsp;
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;"> <span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes,
:attachment => file,:contentype=>selContentType} %> :attachment => file, :contentype => selContentType} %>
</span> </span>
</td> </td>
<td class="content_type"><%= file.show_suffix_type %></td> <td class="content_type"><%= file.show_suffix_type %></td>
<td class="downloads"><%= file.downloads %></td> <td class="field_file_dense">
<!-- <td class="digest" width="300px"><%= file.description %></td> --> <span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
<td align="center"> &nbsp;
<%= link_to(image_tag('delete.png'), attachment_path(file), <span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> <%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
</td> :attachment => file} %>
</tr> </span>
<tr> </td>
<td class='description' colspan="6"> <td class="downloads"><%= file.downloads %></td>
<div class="tags_area"> <!-- <td class="digest" width="300px"><%= file.description %></td> -->
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> <td align="center">
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> <%= link_to(image_tag('delete.png'), attachment_path(file),
<div class="tags_gradint"></div> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</div> </td>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a> </tr>
</div> <tr>
</td> <td class='description' colspan="6">
</tr> <div class="tags_area">
<% end -%> <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<% end -%> <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<% reset_cycle %> <div class="tags_gradint"></div>
<% end -%> </div>
<!-- %= h downloadAll(@containers) % --> <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
<!-- %= link_to "download all file", (downloadAll(@containers)) % --> </div>
</td>
</tr>
<% end -%>
<% end -%>
<% reset_cycle %>
<% end -%>
<!-- %= h downloadAll(@containers) % -->
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
</tbody> </tbody>
</table> </table>

View File

@ -0,0 +1,13 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
<% if file_dense_list.any? %>
<div id="edit-file-dense-form-<%=attachment.id%>" class="hidden">
<%= select_tag "file_dense",
options_for_select(file_dense_list,attachment.file_dense_str), :onchange=>"file_dense_edit("+attachment.id.to_s + ",this.value)"%>
</div>
<%= 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 %>

View File

@ -18,6 +18,7 @@
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %> <%= 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('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('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
@ -34,6 +35,9 @@
</tr> </tr>
<% end -%> <% end -%>
<% container.attachments.each do |file| %> <% container.attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of?(@project)%>
<%next%>
<%end%>
<tr class="file <%= cycle("odd", "odd") %>"> <tr class="file <%= cycle("odd", "odd") %>">
<td class="filename" style="font-size: 13px; "><%= 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;" %></td> <td class="filename" style="font-size: 13px; "><%= 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;" %></td>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> --> <!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
@ -45,6 +49,14 @@
</span> </span>
</td> </td>
<td class="content_type"><%= file.show_suffix_type %></td> <td class="content_type"><%= file.show_suffix_type %></td>
<td class="field_file_dense">
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
&nbsp;
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'project_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
:attachment => file} %>
</span>
</td>
<td class="downloads"><%= file.downloads %></td> <td class="downloads"><%= file.downloads %></td>
<!-- <td class="digest" width="300px"><%= file.description %></td> --> <!-- <td class="digest" width="300px"><%= file.description %></td> -->
<td align="center"> <td align="center">

View File

@ -5,66 +5,78 @@
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %> <% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
<table class="list files" id="ver-zebra"> <table class="list files" id="ver-zebra">
<colgroup> <colgroup>
<col class="vzebra-odd"/> <col class="vzebra-odd"/>
<col class="vzebra-even"/> <col class="vzebra-even"/>
<col class="vzebra-odd"/> <col class="vzebra-odd"/>
<col class="vzebra-even"/> <col class="vzebra-even"/>
<!-- <col class="vzebra-odd"/> --> <!-- <col class="vzebra-odd"/> -->
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %> <%= 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('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('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('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('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @containers.each do |container| %> <% @containers.each do |container| %>
<% next if container.attachments.empty? -%> <% next if container.attachments.empty? -%>
<% container.attachments.each do |file| %> <% container.attachments.each do |file| %>
<% if isTypeOk(file,selAttachType,selContentType) %> <% if file.is_public == 0 && !User.current.member_of?(@project) %>
<tr class="file <%= cycle("odd", "odd") %>"> <% next %>
<td class="filename" style="font-size: 13px; "><%= 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;" %></td> <% end %>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> --> <% if isTypeOk(file, selAttachType, selContentType) %>
<td class="filesize"><%= number_to_human_size(file.filesize) %></td> <tr class="file <%= cycle("odd", "odd") %>">
<td class="attach_type"> <td class="filename" style="font-size: 13px; "><%= 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;" %></td>
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span> <!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
&nbsp; <td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
&nbsp;
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;"> <span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes, <%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes,
:attachment => file,:contentype=>selContentType} %> :attachment => file, :contentype => selContentType} %>
</span> </span>
</td> </td>
<td class="content_type"><%= file.show_suffix_type %></td> <td class="content_type"><%= file.show_suffix_type %></td>
<td class="downloads"><%= file.downloads %></td> <td class="field_file_dense">
<!-- <td class="digest" width="300px"><%= file.description %></td> --> <span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
<td align="center"> &nbsp;
<%= link_to(image_tag('delete.png'), attachment_path(file), <span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> <%= render :partial => 'project_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
</td> :attachment => file} %>
</tr> </span>
<tr> </td>
<td class='description' colspan="6"> <td class="downloads"><%= file.downloads %></td>
<div class="tags_area"> <!-- <td class="digest" width="300px"><%= file.description %></td> -->
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> <td align="center">
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> <%= link_to(image_tag('delete.png'), attachment_path(file),
<div class="tags_gradint"></div> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</div> </td>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a> </tr>
</div> <tr>
</td> <td class='description' colspan="6">
</tr> <div class="tags_area">
<% end -%> <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<% end -%> <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<% reset_cycle %> <div class="tags_gradint"></div>
<% end -%> </div>
<!-- %= h downloadAll(@containers) % --> <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
<!-- %= link_to "download all file", (downloadAll(@containers)) % --> </div>
</td>
</tr>
<% end -%>
<% end -%>
<% reset_cycle %>
<% end -%>
<!-- %= h downloadAll(@containers) % -->
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
</tbody> </tbody>
</table> </table>

View File

@ -207,6 +207,23 @@
<%end%> <%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) {
});
}
</script> </script>

View File

@ -0,0 +1,5 @@
<%= l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name) %>
<hr />
<h1><%= link_to(h(@project.name), @applied_url) %></h1>

View File

@ -0,0 +1,4 @@
<%= l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name) %>
<h1><%= link_to(h(@project.name), @applied_url) %></h1>

View File

@ -28,7 +28,7 @@
<div> = <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> + <div> = <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> +
<%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %></div> <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %></div>
<!-- <div>&nbsp;&nbsp;&nbsp;+ <%= l(:label_user_score_of_influence) %></div> --> <!-- <div>&nbsp;&nbsp;&nbsp;+ <%= l(:label_user_score_of_influence) %></div> -->
<div> = <%= 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 %> <div> = <%= 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_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %></div> + <%= 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 %></div>
<div> = <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_f %></div> <div> = <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_i %></div>
<!-- end --> <!-- end -->

View File

@ -38,7 +38,7 @@
<td> <td>
<table> <table>
<tr class="info_font"><td><%= l(:label_user_score) %></td></tr> <tr class="info_font"><td><%= l(:label_user_score) %></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= format("%.2f" , @user.user_score_attr.total_score).to_f %></span></td></tr> <tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= format("%.2f" , @user.user_score_attr.total_score).to_i %></span></td></tr>
</table> </table>
</td> </td>
</tr> </tr>
@ -49,23 +49,23 @@
<table style="border-bottom: solid 0px #80a6d2;" width="100%"> <table style="border-bottom: solid 0px #80a6d2;" width="100%">
<tr> <tr>
<%= link_to l(:label_user_score) , {:controller => 'users', :action => 'score_new_index', :remote => true} %> : <%= 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 %>
</tr><br> </tr><br>
<tr> <tr>
<%= link_to l(:label_user_score_of_collaboration), {:controller => 'users',:action => 'topic_new_score_index', :remote => true} %> : <%= 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 %>
</tr><br> </tr><br>
<tr> <tr>
<%= link_to l(:label_user_score_of_influence), {:controller => 'users',:action => 'project_new_score_index', :remote => true} %> : <%= 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 %>
</tr><br> </tr><br>
<tr> <tr>
<%= link_to l(:label_user_score_of_skill), {:controller => 'users',:action => 'activity_new_score_index', :remote => true} %> : <%= 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 %>
</tr><br> </tr><br>
<tr> <tr>
<%= link_to l(:label_user_score_of_active), {:controller => 'users',:action => 'influence_new_score_index', :remote => true} %> <%= 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 %>
</tr><br> </tr><br>
</table> </table>

View File

@ -1,5 +1,5 @@
<%= l(:label_user_grade)%>: <%= 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', :action => 'show_new_score',
:remote => true, :remote => true,
:id => user.id :id => user.id

View File

@ -53,7 +53,7 @@
<td> <td>
<table> <table>
<tr class="info_font"><td><%= l(:label_user_score) %></td></tr> <tr class="info_font"><td><%= l(:label_user_score) %></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= format("%.2f" , @user.user_score_attr.total_score).to_f %></span></td></tr> <tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= format("%.2f" , @user.user_score_attr.total_score).to_i %></span></td></tr>
</table> </table>
</td> </td>
</tr> </tr>
@ -64,23 +64,23 @@
<table style="border-bottom: solid 0px #80a6d2;" width="100%"> <table style="border-bottom: solid 0px #80a6d2;" width="100%">
<tr> <tr>
<%= l(:label_user_score) %> : <%= l(:label_user_score) %> :
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %> <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
</tr><br> </tr><br>
<tr> <tr>
<%= l(:label_user_score_of_collaboration) %> : <%= 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 %>
</tr><br> </tr><br>
<tr> <tr>
<%= l(:label_user_score_of_influence) %> : <%= 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 %>
</tr><br> </tr><br>
<tr> <tr>
<%= l(:label_user_score_of_skill) %> : <%= 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 %>
</tr><br> </tr><br>
<tr> <tr>
<%= l(:label_user_score_of_active) %> <%= 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 %>
</tr><br> </tr><br>
</table> </table>

View File

@ -114,12 +114,17 @@
<div class="main-content-bar" id="main-content-bar"> <div class="main-content-bar" id="main-content-bar">
<!--文字--> <!--文字-->
<div style="float: left"> <div style="float: left">
<%= 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 %>
</div> </div>
<div class="welcome_left" id="welcome_left"> <div class="welcome_left" id="welcome_left">
<% unless @contest_page.nil? %>
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %>&nbsp;<%= l(:label_welcome_trustie_contest) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_contest_description) %></span> <span class="font_welcome_trustie"><%= @contest_page.title %></span> <span class="font_welcome_tdescription">, <%= @contest_page.description %></span>
</div> <% end %>
</div>
<!--搜索框--> <!--搜索框-->
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;"> <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">

View File

@ -51,14 +51,17 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> </span> <% end %> </span>
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span> <% unless @course_page.nil? %>
<span class="font_welcome_trustie"><%= @course_page.title %> </span>
<% if @school_id.nil? and User.current.user_extensions.school.nil? %> <% if @school_id.nil? and User.current.user_extensions.school.nil? %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span> <span class="font_welcome_tdescription">, <%= @course_page.description %></span>
<% else %> <% else %>
<% if @school_id == "0" %> <% if @school_id == "0" %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span> <span class="font_welcome_tdescription">, <%= @course_page.description %></span>
<% end %> <% end %>
<% end %> <% end %>
<% end %>
</div> </div>
<div class="search-bar" id="search-bar"> <div class="search-bar" id="search-bar">
<%= render :partial => "search_course", :locals => {:project_type => Project::ProjectType_course} %> <%= render :partial => "search_course", :locals => {:project_type => Project::ProjectType_course} %>

View File

@ -30,13 +30,21 @@
<div id="identifier-pannel" style="display:none"> <div id="identifier-pannel" style="display:none">
<%= link_to image_tag('/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" ), home_path %> <%= link_to image_tag('/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" ), home_path %>
<div class="weixin-content">微信扫码</div> <div class="weixin-content">微信扫码</div>
</div> </div>
<div class="main-content-bar" id="main-content-bar"> <div class="main-content-bar" id="main-content-bar">
<div style="float: left"> <div style="float: left">
<%= image_tag '/images/transparent.png', size: "75x75" %> <!-- <#%= image_tag(get_project_avatar(@first_page), 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 %>
</div> </div>
<div class="welcome_left" id="welcome_left"> <div class="welcome_left" id="welcome_left">
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_project_description) %></span> <% unless @first_page.nil? %>
<span class="font_welcome_trustie"><%= @first_page.title %></span> <span class="font_welcome_tdescription">, <%= @first_page.description %></span>
<% end %>
</div> </div>
<div class="search-bar" id="search-bar"> <div class="search-bar" id="search-bar">
<%= render :partial => "search_project", :locals => {:project_type => 0}%> <%= render :partial => "search_project", :locals => {:project_type => 0}%>

View File

@ -199,6 +199,7 @@ default:
# Maximum number of simultaneous AJAX uploads # Maximum number of simultaneous AJAX uploads
#max_concurrent_ajax_uploads: 2 #max_concurrent_ajax_uploads: 2
#pic_types: "bmp,jpeg,jpg,png,gif"
# specific configuration options for production environment # specific configuration options for production environment
# that overrides the default ones # that overrides the default ones

View File

@ -233,6 +233,7 @@ en:
field_mail: Email field_mail: Email
field_job_category: Job category # added by bai field_job_category: Job category # added by bai
field_filename: File field_filename: File
field_file_dense: File Dense
field_filesize: Size field_filesize: Size
field_downloads: Downloads field_downloads: Downloads
field_author: Author field_author: Author
@ -1079,6 +1080,7 @@ en:
text_session_expiration_settings: "Warning: changing these settings may expire the current sessions including yours." 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_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_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_manager: Manager
default_role_developer: Developer default_role_developer: Developer

View File

@ -251,6 +251,7 @@ zh:
field_lastname_eg: '(例:张三丰,请填写[张])' field_lastname_eg: '(例:张三丰,请填写[张])'
field_mail: 邮件地址 field_mail: 邮件地址
field_filename: 文件 field_filename: 文件
field_file_dense: 文件密级
field_filesize: 大小 field_filesize: 大小
field_downloads: 下载次数 field_downloads: 下载次数
field_author: 作者 field_author: 作者
@ -515,6 +516,10 @@ zh:
label_project_new_description: '项目可以是软件开发项目,也可以是协作研究项目。' label_project_new_description: '项目可以是软件开发项目,也可以是协作研究项目。'
label_project_plural: 项目列表 label_project_plural: 项目列表
label_project_score: 项目评分 label_project_score: 项目评分
label_first_page_made: 首页定制
label_project_first_page: 项目托管平台首页
label_course_first_page: 课程实践平台首页
label_contest_first_page: 竞赛实战平台首页
label_x_projects: label_x_projects:
zero: 无项目 zero: 无项目
one: 1 个项目 one: 1 个项目
@ -561,6 +566,10 @@ zh:
label_login_with_open_id_option: 或使用OpenID登录 label_login_with_open_id_option: 或使用OpenID登录
label_password_lost: 忘记密码 label_password_lost: 忘记密码
label_home: 主页 label_home: 主页
label_web_title: 浏览器标题
label_site_title: 网站标题
label_site_description: 网站简介
label_site_image: 简介图片
#by young #by young
label_requirement: 需求 label_requirement: 需求
label_new_course: 课程列表 label_new_course: 课程列表
@ -1119,6 +1128,7 @@ zh:
text_own_membership_delete_confirmation: 你正在删除你现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该项目了。你确定要继续吗? text_own_membership_delete_confirmation: 你正在删除你现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该项目了。你确定要继续吗?
text_zoom_in: 放大 text_zoom_in: 放大
text_zoom_out: 缩小 text_zoom_out: 缩小
text_applied_project: "用户 %{id} 申请加入项目 %{project}"
default_role_manager: 管理人员 default_role_manager: 管理人员
default_role_developer: 开发人员 default_role_developer: 开发人员
@ -1217,6 +1227,7 @@ zh:
button_export: 导出 button_export: 导出
label_export_options: "%{export_format} 导出选项" label_export_options: "%{export_format} 导出选项"
error_attachment_too_big: 该文件无法上传。超过文件大小限制 (%{max_size}) error_attachment_too_big: 该文件无法上传。超过文件大小限制 (%{max_size})
error_pic_type: "仅支持如下图片格式:"
notice_failed_to_save_time_entries: "无法保存下列所选取的 %{total} 个项目中的 %{count} 工时: %{ids}。" notice_failed_to_save_time_entries: "无法保存下列所选取的 %{total} 个项目中的 %{count} 工时: %{ids}。"
label_x_issues: label_x_issues:
zero: 0 问题 zero: 0 问题

View File

@ -515,6 +515,7 @@ RedmineApp::Application.routes.draw do
resources :attachments, :only => [:show, :destroy] do resources :attachments, :only => [:show, :destroy] do
collection do collection do
match "updateType" , via: [:get, :post] match "updateType" , via: [:get, :post]
match "updateFileDense" , via: [:get, :post]
match "renderTag" , via: [:get, :post] match "renderTag" , via: [:get, :post]
end end
end end
@ -558,6 +559,9 @@ RedmineApp::Application.routes.draw do
match 'admin', :controller => 'admin', :action => 'index', :via => :get match 'admin', :controller => 'admin', :action => 'index', :via => :get
match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
match 'admin/users', :controller => 'admin', :action => 'users', :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/search', :controller => 'admin', :action => 'search', :via => [:get, :post]
match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
match 'admin/info', :controller => 'admin', :action => 'info', :via => :get match 'admin/info', :controller => 'admin', :action => 'info', :via => :get

View File

@ -0,0 +1,5 @@
class AddIsPublicToAttachment < ActiveRecord::Migration
def change
add_column :attachments, :is_public, :integer,:default => 1
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
class AltColumnName < ActiveRecord::Migration
def change
rename_column :first_pages,:type,:page_type
end
end

View File

@ -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

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # 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| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -51,6 +51,7 @@ ActiveRecord::Schema.define(:version => 20140708023356) do
t.string "description" t.string "description"
t.string "disk_directory" t.string "disk_directory"
t.integer "attachtype", :default => 1 t.integer "attachtype", :default => 1
t.integer "is_public", :default => 1
end end
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" 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", ["id", "type"], :name => "index_enumerations_on_id_and_type"
add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" 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| create_table "forums", :force => true do |t|
t.string "name", :null => false t.string "name", :null => false
t.string "description", :default => "" t.string "description", :default => ""
@ -794,7 +804,7 @@ ActiveRecord::Schema.define(:version => 20140708023356) do
end end
create_table "relative_memos", :force => true do |t| create_table "relative_memos", :force => true do |t|
t.integer "osp_id", :null => false t.integer "osp_id"
t.integer "parent_id" t.integer "parent_id"
t.string "subject", :null => false t.string "subject", :null => false
t.text "content", :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" 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| create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1 t.integer "position", :default => 1

View File

@ -60,11 +60,28 @@ module Redmine
@unsaved_attachments ||= [] @unsaved_attachments ||= []
end 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) def save_attachmentsex(attachments, author=User.current,attachment_type)
@curattachment_type = attachment_type @curattachment_type = attachment_type
result = save_attachments(attachments,author) result = save_attachments(attachments,author)
result result
end end
def save_attachments(attachments, author=User.current) def save_attachments(attachments, author=User.current)
if attachments.is_a?(Hash) if attachments.is_a?(Hash)
attachments = attachments.stringify_keys attachments = attachments.stringify_keys
@ -94,6 +111,10 @@ module Redmine
a.filename = attachment['filename'] unless attachment['filename'].blank? a.filename = attachment['filename'] unless attachment['filename'].blank?
a.content_type = attachment['content_type'] a.content_type = attachment['content_type']
end end
if !attachment[:is_public]
a.is_public = false
end
set_attachment_public(a)
next unless a next unless a
a.description = attachment['description'].to_s.strip a.description = attachment['description'].to_s.strip
a.attachtype = @curattachment_type; a.attachtype = @curattachment_type;

View File

@ -351,6 +351,7 @@ end
Redmine::MenuManager.map :admin_menu do |menu| Redmine::MenuManager.map :admin_menu do |menu|
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_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 :groups, {:controller => 'groups'}, :caption => :label_group_plural
menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural

View File

@ -21,7 +21,8 @@ module Redmine
# Configuration default values # Configuration default values
@defaults = { @defaults = {
'email_delivery' => nil, 'email_delivery' => nil,
'max_concurrent_ajax_uploads' => 2 'max_concurrent_ajax_uploads' => 2,
'pic_types' => "bmp,jpeg,jpg,png,gif"
} }
@config = nil @config = nil

View File

@ -23,7 +23,9 @@ function addFile(inputEl, file, eagerUpload) {
fileSpan.append( fileSpan.append(
$('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), $('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
$('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), $('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload), $('<span >公开:</span>').attr({ 'class': 'ispublic-label' }) ,
$('<input>', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public]', checked:'checked' } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload),
$('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) $('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
).appendTo('#attachments_fields'); ).appendTo('#attachments_fields');
@ -63,6 +65,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
.done(function(result) { .done(function(result) {
progressSpan.progressbar( 'value', 100 ).remove(); progressSpan.progressbar( 'value', 100 ).remove();
fileSpan.find('input.description, a').css('display', 'inline-block'); fileSpan.find('input.description, a').css('display', 'inline-block');
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
}) })
.fail(function(result) { .fail(function(result) {
progressSpan.text(result.statusText); progressSpan.text(result.statusText);

View File

@ -140,10 +140,34 @@ function uploadAndAttachFiles(files, inputEl) {
if (sizeExceeded) { if (sizeExceeded) {
window.alert(maxFileSizeExceeded); window.alert(maxFileSizeExceeded);
} else { } 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) { function handleFileDropEvent(e) {
$(this).removeClass('fileover'); $(this).removeClass('fileover');

View File

@ -1843,6 +1843,7 @@ span.required {color: #bb0000;}
.summary {font-style: italic;} .summary {font-style: italic;}
#attachments_fields input.description {margin-left:4px; width:100px; } #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 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 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%;} #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; } #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 {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;} 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*/ /*gcm upload file count and deleteall*/
#upload_file_count #count {color:red; font-size:1.5em;} #upload_file_count #count {color:red; font-size:1.5em;}

View File

@ -1151,6 +1151,11 @@ div.tags_area {
border-bottom: 1px solid #c8d4fd; 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 { #ver-zebra #vzebra-comedy, #ver-zebra #vzebra-action {
background: #ffffff; background: #ffffff;
border-bottom: 1px solid #d6dfff; border-bottom: 1px solid #d6dfff;

11
test/fixtures/first_pages.yml vendored Normal file
View File

@ -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

View File

@ -0,0 +1,7 @@
require 'test_helper'
class FirstPageTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end