Skip to content

Commit

Permalink
Merge pull request #2079 from brave-intl/staging
Browse files Browse the repository at this point in the history
Release 2019-07-30
  • Loading branch information
yachtcaptain23 authored Jul 30, 2019
2 parents ea8132c + 220403e commit f6c6bf5
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}

.panel {
background: aliceblue;
background: Lavender;
flex: 1;
border-width: 1px;
border-radius: 15px;
Expand All @@ -21,6 +21,10 @@
background: white;
}

&--gray{
background: whitesmoke;
}

.panel--header {
font-size: 20px;
font-weight: bold;
Expand Down Expand Up @@ -145,4 +149,4 @@
}
}
}
}
}
16 changes: 11 additions & 5 deletions app/controllers/admin/unattached_promo_registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ def index
filter = params[:filter]
case filter
when "All codes", nil, ""
@promo_registrations = PromoRegistration.unattached_only.order("created_at DESC")
@promo_registrations = PromoRegistration.unattached_only.
paginate(page: params[:page]).
order("created_at DESC")
when "Not assigned"
@promo_registrations = PromoRegistration.unattached_only.where(promo_campaign_id: nil).order("created_at DESC")
@promo_registrations = PromoRegistration.unattached_only.
where(promo_campaign_id: nil).
paginate(page: params[:page]).
order("created_at DESC")
else
@promo_registrations = PromoRegistration.joins(:promo_campaign).
unattached_only.
where(promo_campaigns: {name: filter}).
paginate(page: params[:page]).
order("created_at DESC")
end
@current_campaign = params[:filter] || "All codes"
@campaigns = PromoCampaign.all.map {|campaign| campaign.name}
@campaigns = PromoCampaign.pluck(:name).sort
end

def create
Expand All @@ -37,7 +43,7 @@ def report
return redirect_to admin_unattached_promo_registrations_path(filter: params[:filter]),
alert: "Please check at least one of downloads, installs, or confirmations."
end

report_start_and_end_date = parse_report_dates(params[:referral_code_report_period], @reporting_interval)
report_csv = Promo::RegistrationStatsReportGenerator.new(referral_codes: referral_codes,
start_date: report_start_and_end_date[:start_date],
Expand Down Expand Up @@ -96,4 +102,4 @@ def parse_report_dates(report_period, reporting_interval)
def create_params
params.require(:number_of_codes_to_create)
end
end
end
39 changes: 8 additions & 31 deletions app/controllers/promo_registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
class PromoRegistrationsController < ApplicationController
include PromosHelper

before_action :find_publisher
before_action :authenticate_publisher!
before_action :require_publisher_promo_disabled, only: %(create)
before_action :require_promo_running, only: %i(create)

def index
@publisher = current_publisher
@publisher_promo_status = @publisher.promo_status(promo_running?)
@promo_enabled_channels = @publisher.channels.joins(:promo_registration)
end

def create
@publisher = current_publisher
@publisher.promo_enabled_2018q1 = true
@publisher.save!
@publisher_has_verified_channel = @publisher.has_verified_channel?
Expand All @@ -31,39 +34,13 @@ def create

def require_promo_running
unless promo_running?
render(:index)
redirect_to promo_registrations_path, action: "index"
end
end

def require_publisher_promo_disabled
if @publisher.promo_enabled_2018q1
render(:index)
end
end

def find_publisher
if current_publisher
@publisher = current_publisher
else
if params[:promo_token].present?
promo_token = params[:promo_token]
elsif params.dig(:publisher).dig(:promo_token).present?
promo_token = params[:publisher][:promo_token]
else
return redirect_to(root_path, alert: I18n.t("promo.publisher_not_found"))
end
if publisher = Publisher.find_by(promo_token_2018q1: promo_token)
@publisher = publisher
else
return redirect_to(root_path, alert: I18n.t("promo.publisher_not_found"))
end
if current_publisher.promo_enabled_2018q1
redirect_to promo_registrations_path, action: "index"
end

@publisher_promo_status = @publisher.promo_status(promo_running?)
@promo_enabled_channels = @publisher.channels.joins(:promo_registration)
rescue => e
require "sentry-raven"
Raven.capture_exception(e)
return redirect_to(root_path, alert: I18n.t("promo.publisher_not_found"))
end
end
2 changes: 1 addition & 1 deletion app/controllers/publishers/cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def new

def show
@case = Case.find_by(publisher: current_publisher)
@notes = CaseNote.where(case: @case)
@notes = CaseNote.where(case: @case, public: true)

redirect_to new_case_path if @case.blank? || @case.new?
end
Expand Down
5 changes: 3 additions & 2 deletions app/jobs/sync/zendesk/ticket_comments_to_notes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ def perform(zendesk_ticket_id, page_number = 0)
config.url = "#{Rails.application.secrets[:zendesk_url]}/api/v2" # e.g. https://mydesk.zendesk.com/api/v2

# Basic / Token Authentication
config.username = Rails.application.secrets[:zendesk_username]
config.username = "#{Rails.application.secrets[:zendesk_username]}/token"

# Choose one of the following depending on your authentication choice
# config.token = "your zendesk token"
config.token = Rails.application.secrets[:zendesk_access_token]
# config.password = "your zendesk password"

# OAuth Authentication
config.access_token = Rails.application.secrets[:zendesk_access_token]
# config.access_token = ""

# Optional:

Expand Down
6 changes: 3 additions & 3 deletions app/jobs/sync/zendesk/tickets_to_notes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ def perform(page_number = 0, start_date = nil)
config.url = "#{Rails.application.secrets[:zendesk_url]}/api/v2" # e.g. https://mydesk.zendesk.com/api/v2

# Basic / Token Authentication
config.username = Rails.application.secrets[:zendesk_username]
config.username = "#{Rails.application.secrets[:zendesk_username]}/token"

# Choose one of the following depending on your authentication choice
# config.token = "your zendesk token"
config.token = Rails.application.secrets[:zendesk_access_token]
# config.password = "your zendesk password"

# OAuth Authentication
config.access_token = Rails.application.secrets[:zendesk_access_token]
# config.access_token = ""

# Optional:

Expand Down
2 changes: 1 addition & 1 deletion app/services/promo/registrations_stats_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def perform
referral_code_events_by_date = JSON.parse(response.body)
referral_code_batch.each do |referral_code|
promo_registration = PromoRegistration.find_by_referral_code(referral_code)
next if referral_code.nil?
next if promo_registration.nil?
promo_registration.stats = referral_code_events_by_date.select { |referral_code_event_date|
referral_code_event_date["referral_code"] == referral_code
}.to_json
Expand Down
36 changes: 0 additions & 36 deletions app/services/publisher_promo_token_generator.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
= text_field_tag "campaign_name", nil, placeholder: "Campaign name"
= submit_tag "Create", class: "btn btn-info", style: "float: right"
.row
.panel.panel--white.panel--table
.panel.panel--gray.panel--table
.panel--header = "Manage"
. style="color: darkgrey; font-size: 14px; margin-bottom: 5px;"
- if Rails.cache.fetch('unattached_promo_registration_stats_last_synced_at').nil?
Expand All @@ -31,7 +31,7 @@
= form_tag admin_unattached_promo_registrations_path, method: :patch, id: "unattached-referral-code-form" do
table.table
tr
th
th
th = "Code"
th = "Campaign"
th = "Installer Type"
Expand Down Expand Up @@ -70,6 +70,8 @@
td = promo_registration_aggregate_stats[PromoRegistration::RETRIEVALS] || 0
td = promo_registration_aggregate_stats[PromoRegistration::FIRST_RUNS] || 0
td = promo_registration_aggregate_stats[PromoRegistration::FINALIZED] || 0
= will_paginate @promo_registrations
hr
.flex
.unattached-referral-code-form--submissions
.panel
Expand Down
2 changes: 1 addition & 1 deletion app/views/promo_registrations/create.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- if @publisher_has_verified_channel
= render "activated_verified", locals: @publisher
- else
= render "activated_unverified", locals: @publisher
= render "activated_unverified", locals: @publisher
1 change: 1 addition & 0 deletions config/excluded_site_channels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13389,6 +13389,7 @@
- "updateworkfreshandnew.space" # commerce
- "upfifacoins.com" # commerce
- "uphe.com" # commerce
- "uphold.com" # services
- "uplay.it" # services
- "uplds.com" # services
- "uploads.to" # services
Expand Down
4 changes: 4 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
cron: "0 1 * * *"
description: "Syncs the channel stats via youtube and twitch apis"
queue: low
Sync::Zendesk::StartJob:
cron: "0 1 * * *"
description: "Syncs zendesk tickets"
queue: low
Cache::PiwikDataJob:
cron: "45 2 * * *"
description: "Refreshes the redis cache for piwik information everyday at 2:45 AM"
Expand Down
25 changes: 0 additions & 25 deletions lib/tasks/launch_promo.rake

This file was deleted.

2 changes: 1 addition & 1 deletion public/creators-landing/src/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ h4 {
.top-swoop {
position: absolute;
top: -2px;
width: 100vw !important;
width: 100% !important;
}

.bottom-swoop {
Expand Down
34 changes: 2 additions & 32 deletions test/controllers/promo_registrations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class PromoRegistrationsControllerTest < ActionDispatch::IntegrationTest

# verify _over is rendered
post promo_registrations_path
follow_redirect!
assert_select("[data-test=promo-over]")

# verify publisher has not enabled promo
Expand All @@ -52,6 +53,7 @@ class PromoRegistrationsControllerTest < ActionDispatch::IntegrationTest

# verify _over is rendered
post promo_registrations_path
follow_redirect!
assert_select("[data-test=promo-active]")

# verify publisher has not enabled promo
Expand Down Expand Up @@ -131,38 +133,6 @@ class PromoRegistrationsControllerTest < ActionDispatch::IntegrationTest
assert_select("[data-test=promo-active]")
end

test "publisher can activate/visit promo without being signed in using promo token from email" do
publisher = publishers(:completed)

# ensure we use token, not session for promo auth
sign_out publisher

promo_token = PublisherPromoTokenGenerator.new(publisher: publisher).perform

# verify promo token auth takes you to _activate page
url = promo_registrations_path(promo_token: promo_token)
get url
assert_response 200
assert_select("[data-test=promo-activate]")

# verify the above does not enable the promo
assert_equal publisher.promo_enabled_2018q1, false

# verify promo auth allows promo activation, takes publisher to _activated_verified
post url
publisher.reload
assert_equal publisher.promo_enabled_2018q1, true
assert_select("[data-test=promo-activated-verified]")

# verify promo auth allows users to view active page once authorized
get url
assert_select("[data-test=promo-active]")

# verify publisher is not must reauth to visit dashboard
get home_publishers_path(publisher)
assert_response 401 # Unauthorized # TO DO: See screen this takes you to, ideally dashboard
end

test "all requests with no promo_token in params or publisher in the session redirect homepage" do
publisher = publishers(:completed)
sign_out publisher
Expand Down
Loading

0 comments on commit f6c6bf5

Please sign in to comment.