diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3ab894c69..0d9fe62a8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -257,12 +257,12 @@ class ApplicationController < ActionController::Base def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false) if @attachment.container_type == "Memo" allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) - elsif @attachment.container_type == "Project" - return true - elsif @attachment.container_type == "course" - return true + elsif @attachment.container_type == "Message" && !@project.nil? + allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false) + elsif @attachment.container_type == "Message" && !@course.nil? + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) elsif @attachment.container_type == "contest" - return true + return true else return true end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index c511b5ace..08469ac48 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -22,7 +22,7 @@ class AttachmentsController < ApplicationController before_filter :delete_authorize, :only => :destroy before_filter :authorize_global, :only => :upload before_filter :authorize_attachment_download, :only => :download - before_filter :login_without_softapplication, only: [:download] + #before_filter :login_without_softapplication, only: [:download] accept_api_auth :show, :download, :upload require 'iconv' @@ -68,12 +68,20 @@ class AttachmentsController < ApplicationController elsif @attachment.container.is_a?(Project) project = @attachment.container candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) + elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && + @attachment.container.board.project + project = @attachment.container.board.project + candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course course = @attachment.container.course candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) elsif @attachment.container.is_a?(Course) course = @attachment.container candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) + elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && + @attachment.container.board.course + course = @attachment.container.board.course + candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3 candown = true else @@ -321,8 +329,11 @@ private raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename if @attachment.container_type == 'Course' @course = @attachment.course - elsif !@attachment.container.nil? && (@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course)) && @attachment.container.course + elsif !@attachment.container.nil? && (@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id)) && @attachment.container.course @course = @attachment.container.course + elsif !@attachment.container.nil? && ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && + @attachment.container.board.course) + @course = @attachment.container.board.course else unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' @project = @attachment.project diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 1e58c53f1..ccdf80464 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -130,7 +130,7 @@ class MyController < ApplicationController @user.pref.save @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) set_language_if_valid @user.language - flash[:notice] = l(:notice_account_updated) + flash.now[:notice] = l(:notice_account_updated) redirect_to user_path(@user) return else @@ -160,7 +160,7 @@ class MyController < ApplicationController @user.destroy if @user.destroyed? logout_user - flash[:notice] = l(:notice_account_deleted) + flash.now[:notice] = l(:notice_account_deleted) end redirect_to home_path end @@ -170,7 +170,7 @@ class MyController < ApplicationController def password @user = User.current unless @user.change_password_allowed? - flash[:error] = l(:notice_can_t_change_password) + flash.now[:error] = l(:notice_can_t_change_password) redirect_to my_account_path return end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d8ecb4ef7..638a883d2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -226,7 +226,14 @@ class UsersController < ApplicationController end end - membership = @user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current)) + #@user.coursememberships.all(:conditions => Course.visible_condition(User.current)) + + if User.current == @user || User.current.admin? + membership = @user.coursememberships.all + else + membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current)) + end + membership.sort! {|older, newer| newer.created_on <=> older.created_on } @memberships = [] membership.collect { |e| @@ -235,9 +242,9 @@ class UsersController < ApplicationController ## 判断课程是否过期 [需封装] @memberships_doing = [] @memberships_done = [] - now_time = Time.now.year + #now_time = Time.now.year @memberships.map { |e| - end_time = e.course.get_time.year + #end_time = e.course.get_time.year isDone = course_endTime_timeout?(e.course) if isDone @memberships_done.push e diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 0393206b7..a7d804321 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -17,6 +17,7 @@ class ZipdownController < ApplicationController @project = obj.courses[0] end end + def assort obj_class = params[:obj_class] obj_id = params[:obj_id] @@ -76,18 +77,18 @@ class ZipdownController < ApplicationController homeattaches = bid.homeworks #记录所有作业是不是有附件,有一个附件就改为true - has_file = false + #has_file = false # 得到每一个人所有文件打包的zip文件 # 并将每一个人的zip打包为一个并返回路径 user_zip_paths = homeattaches.map do |homeattach| if homeattach.attachments.count > 0 zip_homework_by_user homeattach - has_file = true unless has_file + #has_file = true unless has_file end end - unless has_file - render file: 'public/no_file_fond.html' , :layout => 'course_base' - end + #unless has_file + # render file: 'public/no_file_fond.html' , :layout => 'course_base' + #end zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER #@paths = homeworks_attach_path diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 26d61f94e..1139deb35 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -303,27 +303,27 @@ module WelcomeHelper str << content_tag("span", "发表了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << - link_to(truncate(strip_tags(event.event_description).gsub(/ /,''), length: 30, omission:'...'), event.event_url) + link_to(strip_tags(event.event_description).gsub(/ /,''), event.event_url) when 'issue', 'message' , 'bid' , 'wiki-page' , 'document' str << content_tag("span", "发表了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << - link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url) + link_to(event.event_title, event.event_url) when 'reply' ,'Reply', 'Memo' str << content_tag("span", "发表了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << - link_to(truncate(strip_tags(event.event_description).gsub(/ /,''), length: 30, omission:'...'), event.event_url) + link_to(strip_tags(event.event_description).gsub(/ /,''), event.event_url) when 'attachment' str << content_tag('span', '上传了') << content_tag('span', find_all_event_type(event)) << ': '.html_safe << - link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url) << + link_to(event.event_title, event.event_url) << link_to((' ['.html_safe+l(:label_downloads_list).to_s << ']'), project_files_path(event.container.project), :class => "attachments_list_color") else str << content_tag("span", "更新了") << content_tag("span", find_all_event_type(event)) << - ': '.html_safe << link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url) + ': '.html_safe << link_to(event.event_title, event.event_url) end str rescue Exception => e @@ -405,7 +405,8 @@ module WelcomeHelper "show_bids" => true, "show_contest" => true } - activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news', 'contestnotification'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } + activity.scope_select{|t| ['changesets', 'documents', 'memos', 'messages', 'journals_for_messages', 'bids', 'news', 'contestnotification'].include?(t) ? + nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'}) end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index e25434e6e..90cfed429 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -411,6 +411,17 @@ class Attachment < ActiveRecord::Base end end + # Finds an attachment that matches the given token + def self.find_by_token_only(token) + if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ + attachment_id, attachment_digest = $1, $2 + attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first + if attachment + attachment + end + end + end + # Bulk attaches a set of files to an object # # Returns a Hash of the results: diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 4a76a42ef..c70196a2f 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -26,7 +26,7 @@
- <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> + <% if Time.parse(@bid.deadline.to_s).strftime("%Y-%m-%d") < Time.parse(homework.created_at.to_s).strftime("%Y-%m-%d") %> 迟交 <% end %> | diff --git a/app/views/calendars/show.html.erb b/app/views/calendars/show.html.erb index 9166974fa..65b740203 100644 --- a/app/views/calendars/show.html.erb +++ b/app/views/calendars/show.html.erb @@ -2,38 +2,35 @@ <%= form_tag({:controller => 'calendars', :action => 'show', :project_id => @project}, :method => :get, :id => 'query_form') do %> -<%= hidden_field_tag 'set_filter', '1' %> - - -
<% 7.times do |i| %> | <%= day_name( (calendar.first_wday+i)%7 ) %> | <% end %>
---|---|
#{(day+(11-day.cwday)%7).cweek} | ".html_safe) if day.cwday == calendar.first_wday %> -
- <%= day.day %> -<% calendar.events_on(day).each do |i| %> - <% if i.is_a? Issue %> -
- <%= h("#{i.project} -") unless @project && @project == i.project %>
- <%= link_to_issue i, :truncate => 30 %>
- <%= render_issue_tooltip i %>
-
- <% else %>
-
- <%= h("#{i.project} -") unless @project && @project == i.project %>
- <%= link_to_version i%>
-
- <% end %>
-<% end %>
- |
-<%= '
+ <% 7.times do |i| %> + + <% end %> + | |
---|---|
#{(day+(11-day.cwday)%7).cweek} | ".html_safe) if day.cwday == calendar.first_wday %> +
+ <%= day.day %> + <% calendar.events_on(day).each do |i| %> + <% if i.is_a? Issue %> +
+ <%= h("#{i.project} -") unless @project && @project == i.project %>
+ <%= link_to_issue i, :truncate => 30 %>
+ <%= render_issue_tooltip i %>
+
+ <% else %>
+
+ <%= h("#{i.project} -") unless @project && @project == i.project %>
+ <%= link_to_version i%>
+
+ <% end %>
+ <% end %>
+ |
+ <%= '