Skip to content

Commit

Permalink
Merge pull request #8 from chelsea-shorte/vote-bill
Browse files Browse the repository at this point in the history
Vote bill
  • Loading branch information
AfroDevGirl authored Oct 28, 2017
2 parents 105c989 + 36c5518 commit a6a7ac8
Show file tree
Hide file tree
Showing 62 changed files with 580 additions and 261 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions app/assets/javascripts/committees.coffee
Original file line number Diff line number Diff line change
@@ -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/
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the COMMITEEs controller here.
// Place all the styles related to the Amendments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/committees.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the COMMITTEEs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
74 changes: 74 additions & 0 deletions app/controllers/amendments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class AmendmentsController < ApplicationController
before_action :set_amendment, only: [:show, :edit, :update, :destroy]

# GET /amendments
# GET /amendments.json
def index
@amendments = Amendment.all
end

# GET /amendments/1
# GET /amendments/1.json
def show
end

# GET /amendments/new
def new
@amendment = Amendment.new
end

# GET /amendments/1/edit
def edit
end

# POST /amendments
# POST /amendments.json
def create
@amendment = Amendment.new(amendment_params)

respond_to do |format|
if @amendment.save
format.html { redirect_to @amendment, notice: 'Amendment was successfully created.' }
format.json { render :show, status: :created, location: @amendment }
else
format.html { render :new }
format.json { render json: @amendment.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /amendments/1
# PATCH/PUT /amendments/1.json
def update
respond_to do |format|
if @amendment.update(amendment_params)
format.html { redirect_to @amendment, notice: 'Amendment was successfully updated.' }
format.json { render :show, status: :ok, location: @amendment }
else
format.html { render :edit }
format.json { render json: @amendment.errors, status: :unprocessable_entity }
end
end
end

# DELETE /amendments/1
# DELETE /amendments/1.json
def destroy
@amendment.destroy
respond_to do |format|
format.html { redirect_to amendments_url, notice: 'Amendment was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_amendment
@amendment = Amendment.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def amendment_params
params.require(:amendment).permit(:sponsor_title)
end
end
74 changes: 0 additions & 74 deletions app/controllers/commitees_controller.rb

This file was deleted.

74 changes: 74 additions & 0 deletions app/controllers/committees_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class CommitteesController < ApplicationController
before_action :set_committee, only: [:show, :edit, :update, :destroy]

# GET /committees
# GET /committees.json
def index
@committees = Committees.all
end

# GET /committees/1
# GET /committees/1.json
def show
end

# GET /committees/new
def new
@committee = Committees.new
end

# GET /committees/1/edit
def edit
end

# POST /committees
# POST /committees.json
def create
@committee = Committees.new(committee_params)

respond_to do |format|
if @committee.save
format.html { redirect_to @committee, notice: 'Committees was successfully created.' }
format.json { render :show, status: :created, location: @committee }
else
format.html { render :new }
format.json { render json: @committee.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /committees/1
# PATCH/PUT /committees/1.json
def update
respond_to do |format|
if @committee.update(committee_params)
format.html { redirect_to @committee, notice: 'Committees was successfully updated.' }
format.json { render :show, status: :ok, location: @committee }
else
format.html { render :edit }
format.json { render json: @committee.errors, status: :unprocessable_entity }
end
end
end

# DELETE /committees/1
# DELETE /committees/1.json
def destroy
@committee.destroy
respond_to do |format|
format.html { redirect_to committees_index_url, notice: 'Committees was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_committee
@committee = Committees.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def committee_params
params.require(:committee).permit(:propublica_id, :name, :chamber, :url)
end
end
2 changes: 2 additions & 0 deletions app/helpers/amendments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AmendmentsHelper
end
2 changes: 0 additions & 2 deletions app/helpers/commitees_helper.rb

This file was deleted.

2 changes: 2 additions & 0 deletions app/helpers/committees_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CommitteesHelper
end
2 changes: 1 addition & 1 deletion app/helpers/representatives_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
module RepresentativEsHelper
module RepresentativesHelper
end
3 changes: 3 additions & 0 deletions app/models/amendment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Amendment < ApplicationRecord
belongs_to :bill
end
3 changes: 3 additions & 0 deletions app/models/bill.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class Bill < ApplicationRecord
has_many :votes
has_many :amendments
has_and_belongs_to_many :representatives
end
2 changes: 0 additions & 2 deletions app/models/commitees.rb

This file was deleted.

4 changes: 4 additions & 0 deletions app/models/committees.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Committees < ApplicationRecord
has_and_belongs_to_many :representatives
has_many :subcommittees
end
4 changes: 4 additions & 0 deletions app/models/representative.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class Representative < ApplicationRecord
has_and_belongs_to_many :bills
has_and_belongs_to_many :votes
has_and_belongs_to_many :committees
has_and_belongs_to_many :subcommittees
end
2 changes: 0 additions & 2 deletions app/models/subcommitee.rb

This file was deleted.

4 changes: 4 additions & 0 deletions app/models/subcommittee.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Subcommittee < ApplicationRecord
belongs_to :committees
has_and_belongs_to_many :representatives
end
3 changes: 2 additions & 1 deletion app/models/vote.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Vote < ApplicationRecord
has_many :vote_parties
#has_many :vote_parties
belongs_to :bill
has_and_belongs_to_many :representatives
end
2 changes: 2 additions & 0 deletions app/views/amendments/_amendment.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.extract! amendment, :id, :sponsor_title, :created_at, :updated_at
json.url amendment_url(amendment, format: :json)
22 changes: 22 additions & 0 deletions app/views/amendments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= form_with(model: amendment, local: true) do |form| %>
<% if amendment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(amendment.errors.count, "error") %> prohibited this amendment from being saved:</h2>

<ul>
<% amendment.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= form.label :sponsor_title %>
<%= form.text_field :sponsor_title, id: :amendment_sponsor_title %>
</div>

<div class="actions">
<%= form.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/amendments/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Editing Amendment</h1>

<%= render 'form', amendment: @amendment %>

<%= link_to 'Show', @amendment %> |
<%= link_to 'Back', amendments_path %>
27 changes: 27 additions & 0 deletions app/views/amendments/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<p id="notice"><%= notice %></p>

<h1>Amendments</h1>

<table>
<thead>
<tr>
<th>Sponsor title</th>
<th colspan="3"></th>
</tr>
</thead>

<tbody>
<% @amendments.each do |amendment| %>
<tr>
<td><%= amendment.sponsor_title %></td>
<td><%= link_to 'Show', amendment %></td>
<td><%= link_to 'Edit', edit_amendment_path(amendment) %></td>
<td><%= link_to 'Destroy', amendment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>

<br>

<%= link_to 'New Amendment', new_amendment_path %>
1 change: 1 addition & 0 deletions app/views/amendments/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.array! @amendments, partial: 'amendments/amendment', as: :amendment
5 changes: 5 additions & 0 deletions app/views/amendments/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>New Amendment</h1>

<%= render 'form', amendment: @amendment %>

<%= link_to 'Back', amendments_path %>
9 changes: 9 additions & 0 deletions app/views/amendments/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<p id="notice"><%= notice %></p>

<p>
<strong>Sponsor title:</strong>
<%= @amendment.sponsor_title %>
</p>

<%= link_to 'Edit', edit_amendment_path(@amendment) %> |
<%= link_to 'Back', amendments_path %>
1 change: 1 addition & 0 deletions app/views/amendments/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.partial! "amendments/amendment", amendment: @amendment
2 changes: 0 additions & 2 deletions app/views/commite_es/_commitee.json.jbuilder

This file was deleted.

Loading

0 comments on commit a6a7ac8

Please sign in to comment.