# HG changeset patch # User Nattee Niparnan # Date 2017-08-19 14:13:43 # Node ID ecbd1a5dbc276474d427441674e3186f191a4aa7 # Parent 23fc3f2d9ad1b6518d830a04158a8a70a7649962 # Parent b70bda067430c7855f20cb2ddccfda19770305b5 merge with master diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -225,7 +225,7 @@ @by_lang[lang.pretty_name][:memory] = { avail: true, user_id: sub.user_id, value: sub.peak_memory, sub_id: sub.id } end - if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and + if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and sub.user and !sub.user.admin? @by_lang[lang.pretty_name][:first] = { avail: true, user_id: sub.user_id, value: sub.submitted_at, sub_id: sub.id } end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -111,7 +111,8 @@ def stat @user = User.find(params[:id]) - @submission = Submission.includes(:problem).where(user_id: params[:id]) + @submission = Submission.joins(:problem).where(user_id: params[:id]) + @submission = @submission.where('problems.available = true') unless current_user.admin? range = 120 @histogram = { data: Array.new(range,0), summary: {} } diff --git a/app/views/announcements/edit.html.haml b/app/views/announcements/edit.html.haml new file mode 100644 --- /dev/null +++ b/app/views/announcements/edit.html.haml @@ -0,0 +1,34 @@ +.container-fluid + %h1 Editing announcement + = error_messages_for :announcement + .row + .col-md-6 + = form_for(@announcement) do |f| + .form-group + %label Title + = f.text_field :title, class: 'form-control' + .form-group + %label Notes + (shown internally, used to organize announcements) + = f.text_field :notes, class: 'form-control' + .form-group + %label Body + = f.text_area :body, class: 'form-control', style: 'height: 200px;' + .form-group + %label Author + = f.text_field :author, class: 'form-control' + .checkbox + %label + = f.check_box :published + Published + .checkbox + %label + = f.check_box :frontpage + Show on front page? + .checkbox + %label + = f.check_box :contest_only + Show only in contest? + = f.submit "Update", class: 'btn btn-primary' + = link_to 'Show', @announcement, class: 'btn btn-default' + = link_to 'Back', announcements_path, class: 'btn btn-default' diff --git a/app/views/problems/_form.html.haml b/app/views/problems/_form.html.haml new file mode 100644 --- /dev/null +++ b/app/views/problems/_form.html.haml @@ -0,0 +1,52 @@ += error_messages_for 'problem' +/ [form:problem] +.form-group + %label{:for => "problem_name"} Name + = text_field 'problem', 'name', class: 'form-control' + %small + Do not directly edit the problem name, unless you know what you are doing. If you want to change the name, use the name change button in the problem management menu instead. +.form-group + %label{:for => "problem_full_name"} Full name + = text_field 'problem', 'full_name', class: 'form-control' +.form-group + %label{:for => "problem_full_score"} Full score + = text_field 'problem', 'full_score', class: 'form-control' +.form-group + %label{:for => "problem_date_added"} Date added + = date_select 'problem', 'date_added', class: 'form-control' +- # TODO: these should be put in model Problem, but I can't think of +- # nice default values for them. These values look fine only +- # in this case (of lazily adding new problems). +- @problem.available = true if @problem!=nil and @problem.available==nil +- @problem.test_allowed = true if @problem!=nil and @problem.test_allowed==nil +- @problem.output_only = false if @problem!=nil and @problem.output_only==nil +.checkbox + %label{:for => "problem_available"} + = check_box :problem, :available + Available? +.checkbox + %label{:for => "problem_test_allowed"} + = check_box :problem, :test_allowed + Test allowed? +.checkbox + %label{:for => "problem_output_only"} + = check_box :problem, :output_only + Output only? += error_messages_for 'description' +.form-group + %label{:for => "description_body"} Description + %br/ + = text_area :description, :body, :rows => 10, :cols => 80,class: 'form-control' +.form-group + %label{:for => "description_markdowned"} Markdowned? + = select "description", | + "markdowned", | + [['True',true],['False',false]], | + {:selected => (@description) ? @description.markdowned : false } | +.form-group + %label{:for => "problem_url"} URL + %br/ + = text_field 'problem', 'url',class: 'form-control' +%p + Task PDF #{file_field_tag 'file'} +/ [eoform:problem] diff --git a/app/views/problems/edit.html.haml b/app/views/problems/edit.html.haml new file mode 100644 --- /dev/null +++ b/app/views/problems/edit.html.haml @@ -0,0 +1,14 @@ +.container-fluid + = form_for @problem,url:{action: 'update'},html: {multipart: true} do + .row + .col-md-6 + %h1 Editing problem + = render :partial => 'form' + .row + .col-md-4 + = submit_tag 'Edit', class: 'btn btn-primary btn-block' + .col-md-4 + = link_to 'Show', {:action => 'show', :id => @problem}, class: 'btn btn-default btn-block' + .col-md-4 + = link_to 'Back', problems_path, class: 'btn btn-default btn-block' +.div{style: 'height: 5em'} diff --git a/config/application.rb.SAMPLE b/config/application.rb.SAMPLE --- a/config/application.rb.SAMPLE +++ b/config/application.rb.SAMPLE @@ -47,12 +47,6 @@ # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - config.active_record.whitelist_attributes = false - # Enable the asset pipeline config.assets.enabled = true diff --git a/spec/models/testcases_spec.rb b/spec/models/testcases_spec.rb new file mode 100644 --- /dev/null +++ b/spec/models/testcases_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Testcases do + pending "add some examples to (or delete) #{__FILE__}" +end