Begin refactoring to allow Adopt-a-Whatever

This commit is contained in:
Erik Michaels-Ober 2011-09-15 14:02:16 -07:00
parent 98eff20127
commit 688b408308
12 changed files with 26 additions and 25 deletions

View File

@ -6,7 +6,7 @@ class AddressesController < ApplicationController
unless @address.blank? unless @address.blank?
respond_with @address respond_with @address
else else
render(:json => {"errors" => {"address" => [t("errors.address")]}}, :status => 404) render(:json => {"errors" => {"address" => [t("errors.not_found", :thing => t("defaults.address"))]}}, :status => 404)
end end
end end
end end

View File

@ -6,7 +6,7 @@ class HydrantsController < ApplicationController
unless @hydrants.blank? unless @hydrants.blank?
respond_with @hydrants respond_with @hydrants
else else
render(:json => {"errors" => {"address" => [t("errors.hydrants")]}}, :status => 404) render(:json => {"errors" => {"address" => [t("errors.not_found", :thing => t("defaults.thing"))]}}, :status => 404)
end end
end end

View File

@ -2,4 +2,4 @@
= f.hidden_field "id" = f.hidden_field "id"
= f.hidden_field "user_id", :value => "" = f.hidden_field "user_id", :value => ""
= f.hidden_field "name", :value => "" = f.hidden_field "name", :value => ""
= f.submit t("buttons.abandon") = f.submit t("buttons.abandon", :thing => t("defaults.thing"))

View File

@ -2,4 +2,4 @@
= f.hidden_field "id" = f.hidden_field "id"
= f.hidden_field "user_id", :value => "" = f.hidden_field "user_id", :value => ""
= f.hidden_field "name", :value => "" = f.hidden_field "name", :value => ""
= f.submit t("buttons.steal") = f.submit t("buttons.steal", :thing => t("buttons.thing"))

View File

@ -1,9 +1,9 @@
= form_for :hydrant, :url => hydrants_path, :method => :put, :html => {:id => "adoption_form"} do |f| = form_for :hydrant, :url => hydrants_path, :method => :put, :html => {:id => "adoption_form"} do |f|
%h2 %h2
= t("titles.adopt") = t("titles.adopt", :thing => t("defaults.thing").titleize)
= f.hidden_field "id" = f.hidden_field "id"
= f.hidden_field "user_id", :value => current_user.id = f.hidden_field "user_id", :value => current_user.id
= f.label "name", t("labels.name_hydrant"), :id => "hydrant_name_label" = f.label "name", t("labels.name_thing", :thing => t("defaults.thing")), :id => "hydrant_name_label"
= f.text_field "name", :tabindex => 1 = f.text_field "name", :tabindex => 1
= f.submit t("buttons.adopt"), :tabindex => 2 = f.submit t("buttons.adopt"), :tabindex => 2
= render :partial => 'users/edit_profile' = render :partial => 'users/edit_profile'

View File

@ -2,7 +2,7 @@
%html %html
%head %head
%title %title
= t("titles.main") = t("titles.main", :thing => t("defaults.thing").titleize)
= stylesheet_link_tag "application" = stylesheet_link_tag "application"
= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" = javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false"
= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" = javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"

View File

@ -1,6 +1,6 @@
#sidebar #sidebar
%h1 %h1
= t("titles.main") = t("titles.main", :thing => t("defaults.thing").titleize)
%p#tagline %p#tagline
= t("defaults.tagline") = t("defaults.tagline")
= form_for :address, :html => {:id => "address_form"} do |f| = form_for :address, :html => {:id => "address_form"} do |f|
@ -9,12 +9,12 @@
= label_tag "address", t("labels.address"), :id => "address_label" = label_tag "address", t("labels.address"), :id => "address_label"
= text_field_tag "address", params[:address], :tabindex => 11 = text_field_tag "address", params[:address], :tabindex => 11
= hidden_field_tag "limit", params[:limit] || 20 = hidden_field_tag "limit", params[:limit] || 20
= submit_tag t("buttons.find"), :tabindex => 12 = submit_tag t("buttons.find", :thing => t("defaults.thing").pluralize), :tabindex => 12
#logos #logos
= image_tag "logos/cfa.png", :alt => t("sponsors.cfa"), :title => t("sponsors.cfa") = image_tag "logos/cfa.png", :alt => t("sponsors.cfa"), :title => t("sponsors.cfa")
= image_tag "logos/boston.png", :alt => t("sponsors.city"), :title => t("sponsors.city") = image_tag "logos/boston.png", :alt => t("sponsors.city"), :title => t("sponsors.city")
#feedback #feedback
%a{:href => "mailto:adoptahydrant@cityofboston.gov?subject=#{t("titles.main")} #{t("links.feedback")}"} %a{:href => "mailto:adoptahydrant@cityofboston.gov?subject=#{t("titles.main", :thing => t("defaults.thing").titleize)} #{t("links.feedback")}"}
= t("links.feedback") = t("links.feedback")
= image_tag "hydrant-in-snow.jpg", :id => "hydrant-in-snow" = image_tag "hydrant-in-snow.jpg", :id => "hydrant-in-snow"
#map_canvas #map_canvas

View File

@ -1,6 +1,6 @@
= form_for :user, :html => {:id => "combo_form"} do |f| = form_for :user, :html => {:id => "combo_form"} do |f|
%h2 %h2
= t("titles.adopt") = t("titles.adopt", :thing => t("defaults.thing").titleize)
#common_fields #common_fields
= f.label "email", t("labels.email"), :id => "user_email_label" = f.label "email", t("labels.email"), :id => "user_email_label"
%em %em

View File

@ -1,5 +1,5 @@
%h2 %h2
= t("titles.adopted", :hydrant_name => @hydrant.name ? @hydrant.name.titleize : t("defaults.hydrant_name")) = t("titles.adopted", :thing_name => @hydrant.name ? @hydrant.name.titleize : t("defaults.this_thing", :thing => t("defaults.thing")))
%br %br
= t("titles.byline", :name => @hydrant.user.name) = t("titles.byline", :name => @hydrant.user.name)
%br %br

View File

@ -1,5 +1,5 @@
%h2 %h2
= t("titles.thank_you") = t("titles.thank_you", :thing => t("defaults.thing"))
= render :partial => 'hydrants/abandon' = render :partial => 'hydrants/abandon'
= render :partial => 'users/edit_profile' = render :partial => 'users/edit_profile'
= render :partial => 'sessions/sign_out' = render :partial => 'sessions/sign_out'

View File

@ -2,18 +2,18 @@
en: en:
buttons: buttons:
abandon: "Abandon this hydrant" abandon: "Abandon this %{thing}"
adopt: "Adopt!" adopt: "Adopt!"
back: "Back" back: "Back"
change_password: "Change my password" change_password: "Change my password"
edit_profile: "Edit profile" edit_profile: "Edit profile"
email_password: "Email me my password" email_password: "Email me my password"
find: "Find fire hydrants" find: "Find %{thing}"
send_reminder: "Send reminder to shovel" send_reminder: "Send reminder to shovel"
sign_in: "Sign in" sign_in: "Sign in"
sign_out: "Sign out" sign_out: "Sign out"
sign_up: "Sign up" sign_up: "Sign up"
steal: "Steal this hydrant" steal: "Steal this %{thing}"
update: "Update" update: "Update"
captions: captions:
current_password: "(we need your current password to confirm your changes)" current_password: "(we need your current password to confirm your changes)"
@ -21,20 +21,21 @@ en:
private: "(private)" private: "(private)"
public: "(may be visible to other users)" public: "(may be visible to other users)"
defaults: defaults:
address: "address"
city: "Boston, MA" city: "Boston, MA"
hydrant_name: "This hydrant" thing: "hydrant"
this_thing: "This %{thing}"
tagline: "Claim responsibility for shoveling out a fire hydrant after it snows." tagline: "Claim responsibility for shoveling out a fire hydrant after it snows."
tos: "By signing up, you agree to the %{tos}." tos: "By signing up, you agree to the %{tos}."
errors: errors:
address: "Could not find address."
password: "You need to sign in or sign up before continuing." password: "You need to sign in or sign up before continuing."
hydrants: "Could not find hydrants." not_found: "Could not find %{thing}."
labels: labels:
address: "Address, Neighborhood" address: "Address, Neighborhood"
city_state: "City" city_state: "City"
email: "Email address" email: "Email address"
name: "Name" name: "Name"
name_hydrant: "Give this hydrant a name" name_thing: "Give this %{thing} a name"
organization: "Organization" organization: "Organization"
password: "Password" password: "Password"
password_choose: "Choose a password" password_choose: "Choose a password"
@ -50,13 +51,13 @@ en:
forgot_password: "Forgot your password?" forgot_password: "Forgot your password?"
remembered_password: "Never mind. I remembered my password." remembered_password: "Never mind. I remembered my password."
titles: titles:
adopt: "Adopt this Hydrant" adopt: "Adopt this %{thing}"
adopted: "%{hydrant_name} has been adopted" adopted: "%{thing_name} has been adopted"
byline: "by %{name}" byline: "by %{name}"
edit_profile: "Edit your Profile" edit_profile: "Edit your Profile"
main: "Adopt a Hydrant" main: "Adopt a %{thing}"
ofline: "of %{organization}" ofline: "of %{organization}"
thank_you: "Thank you for adopting this hydrant!" thank_you: "Thank you for adopting this %{thing}!"
tos: "Terms of Service" tos: "Terms of Service"
sponsors: sponsors:
cfa: "Code for America" cfa: "Code for America"

View File

@ -19,7 +19,7 @@ class MainControllerTest < ActionController::TestCase
assert_select 'input#address', true assert_select 'input#address', true
assert_select 'input[name="commit"]' do assert_select 'input[name="commit"]' do
assert_select '[type=?]', 'submit' assert_select '[type=?]', 'submit'
assert_select '[value=?]', 'Find fire hydrants' assert_select '[value=?]', 'Find hydrants'
end end
assert_select 'div#map_canvas', true assert_select 'div#map_canvas', true
end end