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