diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -66,14 +66,14 @@ @problem = Problem.find(params[:id]) @description = @problem.description if @description.nil? and params[:description][:body]!='' - @description = Description.new(params[:description]) + @description = Description.new(description_params) if !@description.save flash[:notice] = 'Error saving description' render :action => 'edit' and return end @problem.description = @description elsif @description - if !@description.update_attributes(params[:description]) + if !@description.update_attributes(description_params) flash[:notice] = 'Error saving description' render :action => 'edit' and return end @@ -301,4 +301,8 @@ params.require(:problem).permit(:name, :full_name, :full_score, :change_date_added, :date_added, :available, :test_allowed,:output_only, :url, :description, tag_ids:[]) end + def description_params + params.require(:description).permit(:body, :markdown) + end + end diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,7 +27,7 @@ belongs_to :site belongs_to :country - has_and_belongs_to_many :contests, -> { order(:name); uniq} + has_and_belongs_to_many :contests, -> { order(:name)} scope :activated_users, -> {where activated: true} @@ -173,7 +173,7 @@ return false if site==nil return site.finished? elsif GraderConfiguration.indv_contest_mode? - return false if self.contest_stat(true)==nil + return false if self.contest_stat==nil return contest_time_left == 0 else return false diff --git a/app/views/problems/import.html.haml b/app/views/problems/import.html.haml --- a/app/views/problems/import.html.haml +++ b/app/views/problems/import.html.haml @@ -8,7 +8,8 @@ - if @problem and @problem.errors =error_messages_for 'problem' -= form_tag({:action => 'do_import'}, :multipart => true) do += simple_form_for :problem, url: do_import_problems_path, :multipart => true do |f| + .submitbox %table %tr diff --git a/app/views/report/max_score.html.haml b/app/views/report/max_score.html.haml --- a/app/views/report/max_score.html.haml +++ b/app/views/report/max_score.html.haml @@ -1,6 +1,6 @@ %h1 Maximum score -= form_tag report_show_max_score_path += form_tag show_max_score_report_path .row .col-md-4 .panel.panel-primary diff --git a/app/views/submissions/edit.html.haml b/app/views/submissions/edit.html.haml --- a/app/views/submissions/edit.html.haml +++ b/app/views/submissions/edit.html.haml @@ -51,17 +51,18 @@ %h2 Console %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20} -.modal.fade#compiler{tabindex: -1,role: 'dialog'} - .modal-dialog.modal-lg{role:'document'} - .modal-content - .modal-header - %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} - %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × - %h4 Compiler message - .modal-body - %pre#compiler_msg= @submission.compiler_message - .modal-footer - %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close +- if @submission + .modal.fade#compiler{tabindex: -1,role: 'dialog'} + .modal-dialog.modal-lg{role:'document'} + .modal-content + .modal-header + %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} + %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × + %h4 Compiler message + .modal-body + %pre#compiler_msg= @submission.compiler_message + .modal-footer + %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close :javascript $(document).ready(function() { diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -40,6 +40,7 @@ get 'manage' get 'quick_create' post 'do_manage' + post 'do_import' end end @@ -81,6 +82,7 @@ get 'download' get 'compiler_msg' get 'rejudge' + get 'source' end collection do get 'prob/:problem_id', to: 'submissions#index', as: 'problem' @@ -115,6 +117,7 @@ get 'user_stat' get 'clear_stat' get 'clear_all_stat' + get 'change_contest_mode' end end