This repository has been archived by the owner on Mar 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removes extra spaces and reduces indentation in rb files
- Loading branch information
Showing
7 changed files
with
183 additions
and
184 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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
ActiveAdmin.register AdminUser do | ||
index do | ||
column :email | ||
column :current_sign_in_at | ||
column :last_sign_in_at | ||
column :sign_in_count | ||
default_actions | ||
end | ||
ActiveAdmin.register AdminUser do | ||
index do | ||
column :email | ||
column :current_sign_in_at | ||
column :last_sign_in_at | ||
column :sign_in_count | ||
default_actions | ||
end | ||
|
||
filter :email | ||
filter :email | ||
|
||
form do |f| | ||
f.inputs "Admin Details" do | ||
f.input :email | ||
f.input :password | ||
f.input :password_confirmation | ||
end | ||
f.actions | ||
end | ||
end | ||
form do |f| | ||
f.inputs "Admin Details" do | ||
f.input :email | ||
f.input :password | ||
f.input :password_confirmation | ||
end | ||
f.actions | ||
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 |
---|---|---|
|
@@ -10,5 +10,5 @@ | |
end | ||
|
||
actions :index, :show | ||
|
||
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,27 +1,27 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
protect_from_forgery | ||
|
||
before_filter :ref_to_cookie | ||
before_filter :ref_to_cookie | ||
|
||
def mobile_device? | ||
if session[:mobile_param] | ||
session[:mobile_param] == "1" | ||
else | ||
request.user_agent =~ /Mobile|webOS/ | ||
end | ||
def mobile_device? | ||
if session[:mobile_param] | ||
session[:mobile_param] == "1" | ||
else | ||
request.user_agent =~ /Mobile|webOS/ | ||
end | ||
end | ||
|
||
protected | ||
protected | ||
|
||
def ref_to_cookie | ||
if params[:ref] && !Rails.application.config.ended | ||
if !User.find_by_referral_code(params[:ref]).nil? | ||
cookies[:h_ref] = { :value => params[:ref], :expires => 1.week.from_now } | ||
end | ||
def ref_to_cookie | ||
if params[:ref] && !Rails.application.config.ended | ||
if !User.find_by_referral_code(params[:ref]).nil? | ||
cookies[:h_ref] = { :value => params[:ref], :expires => 1.week.from_now } | ||
end | ||
|
||
if request.env["HTTP_USER_AGENT"] and !request.env["HTTP_USER_AGENT"].include?("facebookexternalhit/1.1") | ||
redirect_to proc { url_for(params.except(:ref)) } | ||
end | ||
end | ||
if request.env["HTTP_USER_AGENT"] and !request.env["HTTP_USER_AGENT"].include?("facebookexternalhit/1.1") | ||
redirect_to proc { url_for(params.except(:ref)) } | ||
end | ||
end | ||
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,104 +1,103 @@ | ||
class UsersController < ApplicationController | ||
before_filter :skip_first_page, :only => :new | ||
before_filter :skip_first_page, :only => :new | ||
|
||
def new | ||
@bodyId = 'home' | ||
@is_mobile = mobile_device? | ||
def new | ||
@bodyId = 'home' | ||
@is_mobile = mobile_device? | ||
|
||
@user = User.new | ||
@user = User.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
end | ||
respond_to do |format| | ||
format.html # new.html.erb | ||
end | ||
end | ||
|
||
def create | ||
# Get user to see if they have already signed up | ||
@user = User.find_by_email(params[:user][:email]); | ||
|
||
# If user doesnt exist, make them, and attach referrer | ||
if @user.nil? | ||
|
||
cur_ip = IpAddress.find_by_address(request.env['HTTP_X_FORWARDED_FOR']) | ||
|
||
if !cur_ip | ||
cur_ip = IpAddress.create( | ||
:address => request.env['HTTP_X_FORWARDED_FOR'], | ||
:count => 0 | ||
) | ||
end | ||
|
||
if cur_ip.count > 2 | ||
return redirect_to root_path | ||
else | ||
cur_ip.count = cur_ip.count + 1 | ||
cur_ip.save | ||
end | ||
|
||
@user = User.new(:email => params[:user][:email]) | ||
|
||
@referred_by = User.find_by_referral_code(cookies[:h_ref]) | ||
|
||
puts '------------' | ||
puts @referred_by.email if @referred_by | ||
puts params[:user][:email].inspect | ||
puts request.env['HTTP_X_FORWARDED_FOR'].inspect | ||
puts '------------' | ||
|
||
if !@referred_by.nil? | ||
@user.referrer = @referred_by | ||
end | ||
|
||
@user.save | ||
end | ||
|
||
# Send them over refer action | ||
respond_to do |format| | ||
if !@user.nil? | ||
cookies[:h_email] = { :value => @user.email } | ||
format.html { redirect_to '/refer-a-friend' } | ||
else | ||
format.html { redirect_to root_path, :alert => "Something went wrong!" } | ||
end | ||
end | ||
end | ||
def create | ||
# Get user to see if they have already signed up | ||
@user = User.find_by_email(params[:user][:email]); | ||
|
||
def refer | ||
email = cookies[:h_email] | ||
# If user doesnt exist, make them, and attach referrer | ||
if @user.nil? | ||
|
||
@bodyId = 'refer' | ||
@is_mobile = mobile_device? | ||
cur_ip = IpAddress.find_by_address(request.env['HTTP_X_FORWARDED_FOR']) | ||
|
||
@user = User.find_by_email(email) | ||
if !cur_ip | ||
cur_ip = IpAddress.create( | ||
:address => request.env['HTTP_X_FORWARDED_FOR'], | ||
:count => 0 | ||
) | ||
end | ||
|
||
respond_to do |format| | ||
if !@user.nil? | ||
format.html #refer.html.erb | ||
else | ||
format.html { redirect_to root_path, :alert => "Something went wrong!" } | ||
end | ||
end | ||
end | ||
if cur_ip.count > 2 | ||
return redirect_to root_path | ||
else | ||
cur_ip.count = cur_ip.count + 1 | ||
cur_ip.save | ||
end | ||
|
||
@user = User.new(:email => params[:user][:email]) | ||
|
||
@referred_by = User.find_by_referral_code(cookies[:h_ref]) | ||
|
||
def policy | ||
|
||
end | ||
puts '------------' | ||
puts @referred_by.email if @referred_by | ||
puts params[:user][:email].inspect | ||
puts request.env['HTTP_X_FORWARDED_FOR'].inspect | ||
puts '------------' | ||
|
||
def redirect | ||
redirect_to root_path, :status => 404 | ||
if !@referred_by.nil? | ||
@user.referrer = @referred_by | ||
end | ||
|
||
@user.save | ||
end | ||
|
||
private | ||
|
||
def skip_first_page | ||
if !Rails.application.config.ended | ||
email = cookies[:h_email] | ||
if email and !User.find_by_email(email).nil? | ||
redirect_to '/refer-a-friend' | ||
else | ||
cookies.delete :h_email | ||
end | ||
end | ||
# Send them over refer action | ||
respond_to do |format| | ||
if !@user.nil? | ||
cookies[:h_email] = { :value => @user.email } | ||
format.html { redirect_to '/refer-a-friend' } | ||
else | ||
format.html { redirect_to root_path, :alert => "Something went wrong!" } | ||
end | ||
end | ||
end | ||
|
||
def refer | ||
email = cookies[:h_email] | ||
|
||
@bodyId = 'refer' | ||
@is_mobile = mobile_device? | ||
|
||
@user = User.find_by_email(email) | ||
|
||
respond_to do |format| | ||
if !@user.nil? | ||
format.html #refer.html.erb | ||
else | ||
format.html { redirect_to root_path, :alert => "Something went wrong!" } | ||
end | ||
end | ||
end | ||
|
||
def policy | ||
|
||
end | ||
|
||
def redirect | ||
redirect_to root_path, :status => 404 | ||
end | ||
|
||
private | ||
|
||
def skip_first_page | ||
if !Rails.application.config.ended | ||
email = cookies[:h_email] | ||
if email and !User.find_by_email(email).nil? | ||
redirect_to '/refer-a-friend' | ||
else | ||
cookies.delete :h_email | ||
end | ||
end | ||
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,10 +1,10 @@ | ||
class UserMailer < ActionMailer::Base | ||
default from: "Harry's <[email protected]>" | ||
default from: "Harry's <[email protected]>" | ||
|
||
def signup_email(user) | ||
@user = user | ||
@twitter_message = "#Shaving is evolving. Excited for @harrys to launch." | ||
def signup_email(user) | ||
@user = user | ||
@twitter_message = "#Shaving is evolving. Excited for @harrys to launch." | ||
|
||
mail(:to => user.email, :subject => "Thanks for signing up!") | ||
end | ||
mail(:to => user.email, :subject => "Thanks for signing up!") | ||
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
Oops, something went wrong.