forked from codefordurham/adopt-a-drain
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial cleaning model and schema * Added icon for reporting cleaning * Base cleanings controller and routes * Cleaning form outline * Ability to create new cleaning record * Link now sends to add cleaning page * Added information tooltip * Thank you page * Made date field required
- Loading branch information
Showing
15 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class CleaningsController < ApplicationController | ||
respond_to :html, :json | ||
def create | ||
@cleaning = Cleaning.new(cleaning_params) | ||
if @cleaning.save | ||
respond_to do |format| | ||
format.html { render :created } | ||
format.json { render(json: @cleaning) } | ||
end | ||
else | ||
respond_to do |format| | ||
format.json { render(json: {errors: @thing.errors}, status: 500) } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def cleaning_params | ||
params.require(:cleanings).permit(:date_cleaned, :diverted, :user_id, :thing_id) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Cleaning < ActiveRecord::Base | ||
belongs_to :user | ||
belongs_to :thing | ||
validates :date_cleaned, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
= form_for :cleanings, :url => {action: 'create'}, :html => {:id => "cleaning-form", :class => "form-vertical"} do |f| | ||
:javascript | ||
$(document).ready(function() { | ||
$('[data-toggle="tooltip"]').tooltip(); | ||
}); | ||
.form-group | ||
%label.control-label{:for => "date_cleaned", :id => "date_cleaned_label"} | ||
= t("labels.date_cleaned") | ||
= f.date_field "date_cleaned", :class => "form-control", :required => true | ||
%label.control-label{:for => "diverted", :id => "diverted_label"} | ||
= t("labels.diverted") | ||
%i.fa.fa-question-circle{:data_toggle=>"tooltip", :title=>"Please enter the type and weight of the materials you pulled out of the drain. Ex: 2lbs of hard plastic & 3lbs of pine straw. This information helps tremendously with research."} | ||
= f.text_area "diverted", :class => "form-control" | ||
= f.hidden_field "user_id", :value => params[:user] | ||
= f.hidden_field "thing_id", :value => params[:thing] | ||
.form-actions | ||
= f.submit t("buttons.submit_cleaning"), :class => "btn btn-primary btn-block" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%h1 | ||
Cleaning Reported | ||
%p | ||
Thank you for cleaning your drain! Keeping our waterways clean is critical to our neighborhoods. | ||
%button.btn.btn-default{:type => "button", :"data-dismiss" => "modal", :onclick=>"window.close(); return false"} | ||
Close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render :partial => "cleaning_form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CreateCleanings < ActiveRecord::Migration | ||
def change | ||
create_table :cleanings do |t| | ||
t.timestamps | ||
t.text :diverted | ||
t.date :date_cleaned | ||
t.integer :thing_id | ||
t.integer :user_id | ||
|
||
t.timestamps null: false | ||
end | ||
|
||
add_index :cleanings, :user_id | ||
add_index :cleanings, :thing_id | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
diverted: MyText | ||
date_cleaned: 2019-09-01 | ||
thing_id: thing_1 | ||
|
||
two: | ||
diverted: MyText | ||
date_cleaned: 2019-09-01 | ||
thing_id: thing_2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class CleaningTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |