diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -45,7 +45,7 @@ # @hidelogin = true # end - @announcements = Announcement.find_for_frontpage + @announcements = Announcement.frontpage render :action => 'login', :layout => 'empty' end @@ -86,18 +86,18 @@ render :action => 'list' and return end - if @submission.valid? + if @submission.valid?(@current_user) if @submission.save == false - flash[:notice] = 'Error saving your submission' + flash[:notice] = 'Error saving your submission' elsif Task.create(:submission_id => @submission.id, :status => Task::STATUS_INQUEUE) == false - flash[:notice] = 'Error adding your submission to task queue' + flash[:notice] = 'Error adding your submission to task queue' end else prepare_list_information render :action => 'list' and return end - redirect_to :action => 'list' + redirect_to edit_submission_path(@submission) end def source @@ -106,7 +106,7 @@ (submission.problem != nil) and (submission.problem.available)) send_data(submission.source, - {:filename => submission.download_filename, + {:filename => submission.download_filename, :type => 'text/plain'}) else flash[:notice] = 'Error viewing source' @@ -124,23 +124,6 @@ end end - def submission - @user = User.find(session[:user_id]) - @problems = @user.available_problems - if params[:id]==nil - @problem = nil - @submissions = nil - else - @problem = Problem.find_by_id(params[:id]) - if (@problem == nil) or (not @problem.available) - redirect_to :action => 'list' - flash[:notice] = 'Error: submissions for that problem are not viewable.' - return - end - @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) - end - end - def result if !GraderConfiguration.show_grading_result redirect_to :action => 'list' and return @@ -217,9 +200,9 @@ def prepare_announcements(recent=nil) if GraderConfiguration.show_tasks_to?(@user) - @announcements = Announcement.find_published(true) + @announcements = Announcement.published(true) else - @announcements = Announcement.find_published + @announcements = Announcement.published end if recent!=nil recent_id = recent.to_i