wrekatlanta / wrektranet

New intranet for Georgia Tech's student-run radio station, WREK.
wrek.org
MIT License
9 stars 2 forks source link

PSA Submissions #22

Open pstoica opened 10 years ago

pstoica commented 10 years ago

UP FOR GRABS

Staff members should be able to submit PSAs for approval, since DJs are often part of other student orgs that would have good material.

We often use a natural language parser called Chronic for dates, abstracted as a mixable concern). This module could use some documentation, but it's already implemented in the PSA model:

class Psa < ActiveRecord::Base
  include NaturalLanguageDate
  natural_language_date_attr :expiration_date

  validate :expiration_date_string_is_date
end

You use it by calling natural_language_date_attr on the field, and it will create a setter named :expiration_date_string which takes a string, parses it into a date, and passes it back to the :expiration_date field. The mixin also creates an _is_date validator, but you have to add the validation yourself.

The PSA admin form shows how to use all this in a form:

= f.input :expiration_date_string, input_html: { class: 'form-control' }, required: true

So, make a controller (app/controllers/staff/psas_controller.rb) with new and create actions (maybe index if you want to show pending PSAs?), the appropriate views in (app/views/staff/*.html.slim), and the routes in routes.rb.

pstoica commented 10 years ago

Note: PSA submissions should have the status 'new' which can only be changed on the admin side; so hide this for the end user.

pstoica commented 10 years ago

@nlts if you're looking for a starter/refresher issue, this one is pretty straightforward.