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 %> +

+ + <%= 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_contest_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %> +
+

+ + <%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ +

+ + <%= 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 %> +

+ + <%= 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_course_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %> +
+

+ + <%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= 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 %> +

+ + <%= 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)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> +
+ +

+ + <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= 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 %> +

+ + <%= 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)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> +
+ +

+ + <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= 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? %> + + <%= 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) %> - "> - - - - "> + + + + - - - - - - - - - <% end -%> - <% end -%> - <% reset_cycle %> - <% end -%> - - + + + + + + + + + + + <% end -%> + <% end -%> + <% reset_cycle %> + <% 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;" %><%= 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 %> -
-
- <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> -
-
- -
<%= 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 %> +
+
+ <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> +
+
+ +
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? %> + + <%= 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) %> - "> - - - - "> + + + + - - - - - - - - - <% end -%> - <% end -%> - <% reset_cycle %> - <% end -%> - - + + + + + + + + + + + <% end -%> + <% end -%> + <% reset_cycle %> + <% 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;" %><%= 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 %> -
-
- <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> -
-
- -
<%= 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 %> +
+
+ <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> +
+
+ +
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 %>
- <%= 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 %>