* VRFS-1098 - fixed case where registering as a musician in the native interface sends you to downloads (goofy). Also refactoder is_native_client? into a helper

This commit is contained in:
Seth Call 2014-02-13 18:27:38 +00:00
parent 763538e136
commit 240967f7ce
7 changed files with 53 additions and 21 deletions

View File

@ -1,18 +1,22 @@
SimpleCov.start do
add_filter "/test/"
add_filter "/bin/"
add_filter "/scripts/"
add_filter "/tmp/"
add_filter "/vendor/"
end
if ENV['COVERAGE'] == "1"
#SimpleCov.coverage_dir 'coverage/'
all_files = Dir['**/*.rb']
SimpleCov.start do
add_filter "/test/"
add_filter "/bin/"
add_filter "/scripts/"
add_filter "/tmp/"
add_filter "/vendor/"
add_filter "/spec/"
end
all_files = Dir['**/*.rb']
base_result = {}
all_files.each do |file|
absolute = File::expand_path(file)
lines = File.readlines(absolute, :encoding => 'UTF-8')
base_result[absolute] = lines.map do |l|
l.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')
l.encode!('UTF-8', 'UTF-16')
l.strip!
l.empty? || l =~ /^end$/ || l[0] == '#' ? nil : 0
end
@ -29,3 +33,4 @@ end
result.format!
end
end

View File

@ -1,5 +1,6 @@
class ClientsController < ApplicationController
include ClientHelper
include UsersHelper
def index
@ -19,15 +20,7 @@ class ClientsController < ApplicationController
gon.allow_force_native_client = Rails.application.config.allow_force_native_client
# is this the native client or browser?
user_agent = request.env["HTTP_USER_AGENT"]
@nativeClient = !user_agent.blank? && user_agent.downcase.include?("jamkazam")
# allow override of the client type if configured to so, and if we find the override cookie in place
if Rails.application.config.allow_force_native_client
unless cookies[:act_as_native_client].nil?
@nativeClient = (cookies[:act_as_native_client] == "true") ? true : false
end
end
@nativeClient = is_native_client?
# let javascript have access to the server's opinion if this is a native client
gon.isNativeClient = @nativeClient

View File

@ -3,10 +3,15 @@
require 'builder'
class UsersController < ApplicationController
include ClientHelper
before_filter :signed_in_user,
only: [:index, :edit, :update, :destroy]
before_filter :correct_user, only: [:edit, :update]
before_filter :admin_user, only: :destroy
before_filter :is_native_client
rescue_from 'JamRuby::PermissionError' do |exception|
@exception = exception
@ -326,6 +331,10 @@ class UsersController < ApplicationController
private
def is_native_client
@nativeClient = is_native_client?
end
def correct_user
@user = User.find(params[:id])
redirect_to(root_url) unless current_user?(@user)

View File

@ -0,0 +1,18 @@
module ClientHelper
# is this the native client (or browser emulating native client with CTRL+SHIFT+0), or browser?
def is_native_client?
# is this the native client or browser?
user_agent = request.env["HTTP_USER_AGENT"]
is_native_client = !user_agent.blank? && user_agent.downcase.include?("jamkazam")
# allow override of the client type if configured to so, and if we find the override cookie in place
if Rails.application.config.allow_force_native_client
unless cookies[:act_as_native_client].nil?
is_native_client = (cookies[:act_as_native_client] == "true") ? true : false
end
end
is_native_client
end
end

View File

@ -3,7 +3,7 @@
<div class="w100 ">
<div class="spinner-large"></div>
<div class="w70 left downloads-blurb">
<
</div>
</div>

View File

@ -4,7 +4,7 @@
<p>You have successfully registered as a JamKazam fan.</p>
<div class="proceed"><%= link_to "PROCEED TO JAMKAZAM SITE", root_path, :class =>"button-orange m0" %></div>
<div class="proceed"><%= link_to "PROCEED TO JAMKAZAM SITE", client_path, :class =>"button-orange m0" %></div>
<script type="text/javascript">
window.congratulations.initialize(false, jQuery.QueryString["type"]);

View File

@ -1,6 +1,13 @@
<% provide(:title, 'Congratulations') %>
<%= render "users/downloads" %>
<% if @nativeClient %>
<div class="tagline">Congratulations!</div>
<p>You have successfully registered as a musician.</p>
<div class="proceed"><%= link_to "PROCEED TO JAMKAZAM SITE", client_path, :class =>"button-orange m0" %></div>
<% else %>
<%= render "users/downloads" %>
<% end %>
<script type="text/javascript">
window.congratulations.initialize(true, jQuery.QueryString["type"]);