Show More
Commit Description:
merge
Commit Description:
merge
References:
File last commit:
Show/Diff file:
Action:
app/controllers/tasks_controller.rb | 76 lines | 2.1 KiB | text/x-ruby | RubyLexer |
jittat
[web] added body to problems, added task view page...
r88 class TasksController < ApplicationController
more test and clean up authorization
r756 before_action :check_valid_login, :check_viewability
jittat
[web] added body to problems, added task view page...
r88
def index
redirect_to :action => 'list'
end
def list
Jittat Fakcharoenphol
controllers get available problems from current user
r288 @problems = @user.available_problems
jittat
[web] added body to problems, added task view page...
r88 end
Jittat Fakcharoenphol
added contest problem access control
r282 # this has contest-wide access control
jittat
[web] confirm when start contest, downloading task description through apache...
r130 def view
Jittat Fakcharoenphol
imports task description as pdf
r271 base_name = params[:file]
Jittat Fakcharoenphol
added contest problem access control
r282 base_filename = File.basename("#{base_name}.#{params[:ext]}")
filename = "#{Problem.download_file_basedir}/#{base_filename}"
if !FileTest.exists?(filename)
Jittat Fakcharoenphol
imports task description as pdf
r271 redirect_to :action => 'index' and return
end
Jittat Fakcharoenphol
added contest problem access control
r282 send_file_to_user(filename, base_filename)
end
Jittat Fakcharoenphol
imports task description as pdf
r271
Jittat Fakcharoenphol
added contest problem access control
r282 # this has problem-level access control
def download
problem = Problem.find(params[:id])
add remove_all in groups...
r680 unless @current_user.can_view_problem? problem
fix error message when submission to closed problem
r797 flash[:error] = 'You are not authorized to access this file'
redirect_to list_main_path
return
jittat
[web] confirm when start contest, downloading task description through apache...
r130 end
jittat
[web] download through apache, sites highlight, logout for site admin...
r133
Jittat Fakcharoenphol
added contest problem access control
r282 base_name = params[:file]
base_filename = File.basename("#{base_name}.#{params[:ext]}")
filename = "#{Problem.download_file_basedir}/#{params[:id]}/#{base_filename}"
if !FileTest.exists?(filename)
add current score by group
r762 flash[:notice] = 'File does not exists'
fix error message when submission to closed problem
r797 redirect_to list_main_path
return
Jittat Fakcharoenphol
added contest problem access control
r282 end
send_file_to_user(filename, base_filename)
end
protected
def send_file_to_user(filename, base_filename)
jittat
added option for Apapche X-Sendfile...
r172 if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE
response.headers['Content-Type'] = "application/force-download"
response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\""
response.headers["X-Sendfile"] = filename
response.headers['Content-length'] = File.size(filename)
render :nothing => true
else
Jittat Fakcharoenphol
returns correct content type for task description download
r273 if params[:ext]=='pdf'
content_type = 'application/pdf'
else
content_type = 'application/octet-stream'
end
fix pdf to use inline display of browsers...
r367 send_file filename, :stream => false, :disposition => 'inline', :filename => base_filename, :type => content_type
jittat
added option for Apapche X-Sendfile...
r172 end
jittat
[web] confirm when start contest, downloading task description through apache...
r130 end
jittat
[web] added mode + access control, when sites started/finished...
r122 def check_viewability
Jittat Fakcharoenphol
imports task description as pdf
r271 @user = User.find(session[:user_id])
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if @user==nil or !GraderConfiguration.show_tasks_to?(@user)
jittat
[web] added mode + access control, when sites started/finished...
r122 redirect_to :controller => 'main', :action => 'list'
return false
end
end
jittat
[web] added body to problems, added task view page...
r88 end