-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added admin interface to allow us to update the campaign goals.
- Loading branch information
1 parent
b102b8a
commit 9a34c00
Showing
10 changed files
with
107 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class GoalsController < ApplicationController | ||
def edit | ||
@goal = Goal.first || Goal.new | ||
end | ||
|
||
def update | ||
goal = Goal.first || Goal.new | ||
goal.shirts_sold = params[:shirts_sold] | ||
goal.dollars_raised = params[:dollars_raised] | ||
goal.total_shirt_goal = params[:total_shirt_goal] | ||
|
||
goal.campaign_end_date = Date.civil(params[:campain_date][:year].to_i, params[:campain_date][:month].to_i, params[:campain_date][:day].to_i) | ||
|
||
goal.save | ||
|
||
render :text => "MoBRO! You did it, you're changing the face of men's health." | ||
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
class HomeController < ApplicationController | ||
|
||
def index | ||
@goal = Goal.first || Goal.new | ||
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,10 @@ | ||
class Goal < ActiveRecord::Base | ||
|
||
def shirts_sold_as_percentage | ||
((shirts_sold.to_f / total_shirt_goal.to_f) * 100).to_i | ||
end | ||
|
||
def days_left_in_campaign | ||
(campaign_end_date.to_date - Date.today).to_i | ||
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,25 @@ | ||
<h1>Update Stachesquatch Goals</h1> | ||
|
||
<div style="margin-top: 25px;"> | ||
<%= form_tag(goals_path) do %> | ||
|
||
<%= label :shirts_sold, :shirts_sold %> | ||
<%= text_field_tag :shirts_sold, @goal.shirts_sold %> | ||
<br/> | ||
|
||
<%= label :dollars_raised, :dollars_raised %> | ||
<%= text_field_tag :dollars_raised, @goal.dollars_raised %> | ||
<br/> | ||
|
||
<%= label :total_shirt_goal, :total_shirt_goal %> | ||
<%= text_field_tag :total_shirt_goal, @goal.total_shirt_goal %> | ||
<br/> | ||
|
||
|
||
<%= label :campaign_end_date, :campaign_end_date %> | ||
<%= select_date @goal.campaign_end_date, :prefix => :campain_date %> | ||
<br/> | ||
|
||
<%= submit_tag "Update" %> | ||
<% end %> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<div class="goal"> | ||
<div class="sold"> | ||
<h1>30</h1> | ||
<h1><%= @goal.shirts_sold %></h1> | ||
shirts sold | ||
</div> | ||
|
||
<div class="progress"> | ||
<h1>$600</h1> | ||
<h1>$<%= @goal.dollars_raised %></h1> | ||
dollars raised | ||
</div> | ||
|
||
<div class="reset"></div> | ||
|
||
<div class="meter"> | ||
<div class="fill" style="width:40%"> </div> | ||
<div class="fill" style="width:<%=@goal.shirts_sold_as_percentage%>%"> </div> | ||
</div> | ||
|
||
<div class="shirts_sold"> | ||
<span class="em">40%</span> of 75 shirt goal | ||
<span class="em"><%= number_to_percentage(@goal.shirts_sold_as_percentage, :precision => 0)%></span> of <%= @goal.total_shirt_goal %> shirt goal | ||
</div> | ||
<div class="days_to_go"> | ||
<span class="em">15</span> days to go | ||
<span class="em"><%= @goal.days_left_in_campaign%></span> days to go | ||
</div> | ||
<div class="reset"></div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div id="fb-root"></div> | ||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); | ||
</script> | ||
<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script> | ||
<script>(function(d, s, id) { | ||
var js, fjs = d.getElementsByTagName(s)[0]; | ||
if (d.getElementById(id)) return; | ||
js = d.createElement(s); js.id = id; | ||
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; | ||
fjs.parentNode.insertBefore(js, fjs); | ||
}(document, 'script', 'facebook-jssdk')); | ||
</script> |
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,9 @@ | ||
<div class="pintrest"> | ||
<a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fstachesquatch.herokuapp.com%2F&media=http%3A%2F%2Flocalhost%3A3001%2Fassets%2Fshirt_design.jpg&description=It's%20Movember%20and%20time%20to%20make%20a%20difference.%20%20This%20year%20we%20are%20selling%20limited%20edition%20Tees%20to%20raise%20funds%20for%20men's%20health." class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a> | ||
</div> | ||
<div class="fb"> | ||
<div class="fb-like" data-href="http://stachesquatch.herokuapp.com/" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false" data-font="tahoma"></div> | ||
</div> | ||
<div class="twitter"> | ||
<a href="https://twitter.com/share" class="twitter-share-button" data-lang="en">Tweet</a> | ||
</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
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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
Stachesquatch::Application.routes.draw do | ||
resources :goals do | ||
collection do | ||
get :edit | ||
post :update | ||
end | ||
|
||
end | ||
|
||
root :to => 'home#index' | ||
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,14 @@ | ||
class AddGoalsTable < ActiveRecord::Migration | ||
def up | ||
create_table :goals do |t| | ||
t.column "shirts_sold", :integer | ||
t.column "dollars_raised", :integer | ||
t.column "total_shirt_goal", :integer | ||
t.column "campaign_end_date", :datetime | ||
end | ||
end | ||
|
||
def down | ||
drop_table :goals | ||
end | ||
end |