Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #461 from mehulkar/create-suggeston
Create suggeston
- Loading branch information
Showing
6 changed files
with
78 additions
and
70 deletions.
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
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,26 @@ | ||
class CitySuggestionsController < ApplicationController | ||
def new | ||
use_new_styles | ||
if current_user | ||
@city = City.new | ||
else | ||
flash[:notice] = 'Sign up first so we can let you know when your city is approved!' | ||
redirect_to sign_up_path | ||
end | ||
end | ||
|
||
def create | ||
use_new_styles | ||
@city = NewSuggestedCity.call(city_params, current_user) | ||
if @city.persisted? | ||
redirect_to forbes_city_path(@city), notice: 'We\'ve gotten your submission and will get to it ASAP.' | ||
else | ||
render :new, alert: "Something went wrong! Our fault. Could you try again?" | ||
end | ||
end | ||
|
||
private | ||
def city_params | ||
params.require(:city).permit! | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
<div class="light-background"> | ||
<%= render 'shared/header' %> | ||
|
||
<div class='container'> | ||
<div class="cities-partial"> | ||
<div class="city-cta-header"> | ||
<h1 class="dark center">Let's bring TWS to new lands!</h1> | ||
<p class="header-small">If you didn’t find your city in the list before, add it here!</p> | ||
</div> | ||
<div class="submit-city-container"> | ||
<%= form_for @city, html: {class: 'dummy new_city'}, url: suggest_create_cities_path do |f| %> | ||
<%= f.text_field :name, placeholder: 'Your city or college name' %> | ||
<%= f.submit 'Submit', data: { confirmation: false }, class: 'save-city' %> | ||
<% end %> | ||
<div class="city-confirmation-text"> | ||
<h2 class="confirm-message"> | ||
Double check your spelling! And make sure it’s just the city or school name. | ||
</h2> | ||
<p> | ||
After you confirm, we’ll make sure everything checks out and email you | ||
when your friends and neighbors can join you for Tea With Strangers. | ||
</p> | ||
</div> | ||
<% if @city.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%="#{pluralize(@city.errors.count, "error")} prohibited this city from being saved:"%></h2> | ||
<ul> | ||
<%= @city.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class="active-city-list"> | ||
<h3 class="capitalize center current-cities-header">Or click your city below if we're already there</h3> | ||
<div class="cities-list"> | ||
<% City.visible.each do |c| %> | ||
<div class="city no-photo"> | ||
<%= link_to c.name, forbes_city_path(c) %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<%= render partial: 'shared/new_footer' %> | ||
</div> |
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