mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
recipient lists
This commit is contained in:
parent
ab6cefd055
commit
37e01c024b
24 changed files with 491 additions and 1 deletions
3
app/assets/javascripts/recipient_lists.coffee
Normal file
3
app/assets/javascripts/recipient_lists.coffee
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/recipient_lists.scss
Normal file
3
app/assets/stylesheets/recipient_lists.scss
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the recipient_lists controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
64
app/controllers/recipient_lists_controller.rb
Normal file
64
app/controllers/recipient_lists_controller.rb
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
class RecipientListsController < ApplicationController
|
||||
before_action :set_school
|
||||
before_action :set_recipient_list, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET schools/1/recipient_lists
|
||||
def index
|
||||
@recipient_lists = @school.recipient_lists
|
||||
end
|
||||
|
||||
# GET schools/1/recipient_lists/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET schools/1/recipient_lists/new
|
||||
def new
|
||||
@recipient_list = @school.recipient_lists.build
|
||||
end
|
||||
|
||||
# GET schools/1/recipient_lists/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST schools/1/recipient_lists
|
||||
def create
|
||||
@recipient_list = @school.recipient_lists.build(recipient_list_params)
|
||||
|
||||
if @recipient_list.save
|
||||
redirect_to([@recipient_list.school, @recipient_list], notice: 'Recipient list was successfully created.')
|
||||
else
|
||||
render action: 'new'
|
||||
end
|
||||
end
|
||||
|
||||
# PUT schools/1/recipient_lists/1
|
||||
def update
|
||||
if @recipient_list.update_attributes(recipient_list_params)
|
||||
redirect_to([@recipient_list.school, @recipient_list], notice: 'Recipient list was successfully updated.')
|
||||
else
|
||||
render action: 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE schools/1/recipient_lists/1
|
||||
def destroy
|
||||
@recipient_list.destroy
|
||||
|
||||
redirect_to @school
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_school
|
||||
@school = School.find(params[:school_id])
|
||||
end
|
||||
|
||||
def set_recipient_list
|
||||
@recipient_list = @school.recipient_lists.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
def recipient_list_params
|
||||
params.require(:recipient_list).permit(:name, :description, :recipient_ids)
|
||||
end
|
||||
end
|
||||
2
app/helpers/recipient_lists_helper.rb
Normal file
2
app/helpers/recipient_lists_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
module RecipientListsHelper
|
||||
end
|
||||
6
app/models/recipient_list.rb
Normal file
6
app/models/recipient_list.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class RecipientList < ApplicationRecord
|
||||
belongs_to :school
|
||||
|
||||
validates :name, presence: true
|
||||
validates :recipient_ids, presence: true
|
||||
end
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
class School < ApplicationRecord
|
||||
has_many :recipient_lists
|
||||
belongs_to :district
|
||||
has_many :recipients
|
||||
|
||||
|
|
|
|||
23
app/views/recipient_lists/_form.html.haml
Normal file
23
app/views/recipient_lists/_form.html.haml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
= form_for([@school, @recipient_list]) do |f|
|
||||
- if @recipient_list.errors.any?
|
||||
#error_explanation
|
||||
%h2
|
||||
= pluralize(@recipient_list.errors.count, "error")
|
||||
prohibited this recipient_list from being saved:
|
||||
%ul
|
||||
- @recipient_list.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
.field
|
||||
= f.label :name
|
||||
%br/
|
||||
= f.text_field :name
|
||||
.field
|
||||
= f.label :description
|
||||
%br/
|
||||
= f.text_area :description
|
||||
.field
|
||||
= f.label :recipient_ids
|
||||
%br/
|
||||
= f.text_area :recipient_ids
|
||||
.actions
|
||||
= f.submit
|
||||
5
app/views/recipient_lists/edit.html.haml
Normal file
5
app/views/recipient_lists/edit.html.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
%h1 Editing recipient_list
|
||||
= render 'form'
|
||||
= link_to 'Show', [@recipient_list.school, @recipient_list]
|
||||
|
|
||||
= link_to 'Back', school_recipient_lists_path(@recipient_list.school)
|
||||
19
app/views/recipient_lists/index.html.haml
Normal file
19
app/views/recipient_lists/index.html.haml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
%h1 Listing recipient_lists
|
||||
%table
|
||||
%tr
|
||||
%th Name
|
||||
%th Description
|
||||
%th Recipient ids
|
||||
%th
|
||||
%th
|
||||
%th
|
||||
- @recipient_lists.each do |recipient_list|
|
||||
%tr
|
||||
%td= recipient_list.name
|
||||
%td= recipient_list.description
|
||||
%td= recipient_list.recipient_ids
|
||||
%td= link_to 'Show', [recipient_list.school, recipient_list]
|
||||
%td= link_to 'Edit', edit_school_recipient_list_path(recipient_list.school, recipient_list)
|
||||
%td= link_to 'Destroy', [recipient_list.school, recipient_list], :confirm => 'Are you sure?', :method => :delete
|
||||
%br/
|
||||
= link_to 'New Recipient list', new_school_recipient_list_path(@school)
|
||||
3
app/views/recipient_lists/new.html.haml
Normal file
3
app/views/recipient_lists/new.html.haml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
%h1 New recipient_list
|
||||
= render 'form'
|
||||
= link_to 'Back', school_recipient_lists_path(@recipient_list.school)
|
||||
13
app/views/recipient_lists/show.html.haml
Normal file
13
app/views/recipient_lists/show.html.haml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%p#notice= notice
|
||||
%p
|
||||
%b Name:
|
||||
= @recipient_list.name
|
||||
%p
|
||||
%b Description:
|
||||
= @recipient_list.description
|
||||
%p
|
||||
%b Recipient ids:
|
||||
= @recipient_list.recipient_ids
|
||||
= link_to 'Edit', edit_school_recipient_list_path(@recipient_list.school, @recipient_list)
|
||||
|
|
||||
= link_to 'Back', school_recipient_lists_path(@recipient_list.school)
|
||||
4
app/views/school/recipient_lists/index.json.jbuilder
Normal file
4
app/views/school/recipient_lists/index.json.jbuilder
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
json.array!(@school_recipient_lists) do |school_recipient_list|
|
||||
json.extract! school_recipient_list, :id, :name, :description, :recipient_ids
|
||||
json.url school_recipient_list_url(school_recipient_list, format: :json)
|
||||
end
|
||||
1
app/views/school/recipient_lists/show.json.jbuilder
Normal file
1
app/views/school/recipient_lists/show.json.jbuilder
Normal file
|
|
@ -0,0 +1 @@
|
|||
json.extract! @school_recipient_list, :id, :name, :description, :recipient_ids, :created_at, :updated_at
|
||||
Loading…
Add table
Add a link
Reference in a new issue