* VRFS-2972 - adding test purchase feature to jam-admin for buying all JamTracks (admin users only)
This commit is contained in:
parent
49368e2e66
commit
36b4179492
|
|
@ -1,6 +1,6 @@
|
|||
ActiveAdmin.register Cohort, :as => 'Cohorts' do
|
||||
|
||||
menu :label => 'Cohorts All-time', :parent => 'Analytics'
|
||||
menu :label => 'Cohorts All-time', :parent => 'Reports'
|
||||
|
||||
config.sort_order = 'group_start_desc'
|
||||
config.batch_actions = false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
ActiveAdmin.register Cohort, :as => 'Cohorts Monthly' do
|
||||
|
||||
menu :label => 'Cohorts Monthly', :parent => 'Analytics'
|
||||
menu :label => 'Cohorts Monthly', :parent => 'Reports'
|
||||
|
||||
config.sort_order = 'group_start_desc'
|
||||
config.batch_actions = false
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ ActiveAdmin.register JamRuby::CrashDump, :as => 'Crash Dump' do
|
|||
filter :timestamp
|
||||
filter :user_email, :as => :string
|
||||
filter :client_id
|
||||
menu :parent => 'Debug'
|
||||
menu :parent => 'Misc'
|
||||
|
||||
index do
|
||||
column "Timestamp" do |post|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
ActiveAdmin.register JamRuby::EmailBatch, :as => 'Batch Emails' do
|
||||
|
||||
menu :label => 'Batch Emails', :parent => 'Email'
|
||||
menu :label => 'Batch Emails', :parent => 'Misc'
|
||||
|
||||
config.sort_order = 'updated_at DESC'
|
||||
config.batch_actions = false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
ActiveAdmin.register JamRuby::EmailBatchScheduledSessions, :as => 'Daily Sessions' do
|
||||
|
||||
menu :label => 'Daily Sessions', :parent => 'Email'
|
||||
menu :label => 'Daily Sessions', :parent => 'Misc'
|
||||
|
||||
config.sort_order = 'updated_at DESC'
|
||||
config.filters = false
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
ActiveAdmin.register JamRuby::Event, :as => 'Event' do
|
||||
menu :parent => 'Events'
|
||||
menu :parent => 'Misc'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
ActiveAdmin.register JamRuby::EventSession, :as => 'Event Session' do
|
||||
menu :parent => 'Events'
|
||||
menu :parent => 'Misc'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
ActiveAdmin.register_page "Fake Purchaser" do
|
||||
menu :parent => 'Misc'
|
||||
|
||||
|
||||
page_action :bulk_jamtrack_purchase, :method => :post do
|
||||
|
||||
puts params.inspect
|
||||
|
||||
user_field = params[:jam_ruby_jam_track_right][:user]
|
||||
|
||||
if user_field.blank?
|
||||
redirect_to admin_fake_purchaser_path, :notice => "user not specified"
|
||||
return
|
||||
end
|
||||
|
||||
bits = user_field.strip.split(' ')
|
||||
|
||||
user = User.find_by_email(bits[0])
|
||||
if user.nil?
|
||||
redirect_to admin_fake_purchaser_path, :notice =>"no user with email #{bits[0]}"
|
||||
return
|
||||
end
|
||||
|
||||
if !user.admin
|
||||
redirect_to admin_fake_purchaser_path, :notice =>"user is not admin"
|
||||
return
|
||||
end
|
||||
|
||||
count = 0
|
||||
JamTrack.all.each do |jam_track|
|
||||
unless jam_track.right_for_user(user)
|
||||
|
||||
jam_track_right=JamTrackRight.new
|
||||
jam_track_right.user = user
|
||||
jam_track_right.jam_track = jam_track
|
||||
jam_track_right.is_test_purchase = true
|
||||
jam_track_right.save!
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to admin_fake_purchaser_path, :notice => "Bought #{count} jamtracks for #{user.email}"
|
||||
end
|
||||
|
||||
content do
|
||||
|
||||
semantic_form_for JamTrackRight.new, :url => admin_fake_purchaser_bulk_jamtrack_purchase_path, :builder => ActiveAdmin::FormBuilder do |f|
|
||||
f.inputs "Admin User to Fake JamTrack Purchases" do
|
||||
f.input :user, :as => :autocomplete, :url => autocomplete_user_email_admin_users_path, :input_html => { :id_element => "#jam_trak_right_user_id" }, hint: 'All JamTracks in the system will be \'bought\' for this user. No Recurly interaction occurs with this feature.'
|
||||
end
|
||||
f.actions
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,6 +2,6 @@ ActiveAdmin.register JamRuby::IspScoreBatch, :as => 'Isp Score Data' do
|
|||
|
||||
config.sort_order = 'created_at_desc'
|
||||
|
||||
menu :parent => 'Debug'
|
||||
menu :parent => 'Misc'
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
ActiveAdmin.register JamRuby::ArtifactUpdate, :as => 'Artifacts' do
|
||||
menu :label => 'Artifacts'
|
||||
menu :label => 'Artifacts', :parent => 'Operations'
|
||||
|
||||
config.sort_order = 'product,environment'
|
||||
#config.batch_actions = false
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
|
|||
User.select("email, first_name, last_name, id").where(["email ILIKE ? OR first_name ILIKE ? OR last_name ILIKE ?", "%#{parameters[:term]}%", "%#{parameters[:term]}%", "%#{parameters[:term]}%"])
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@jam_ruby_user = JamRuby::User.new(params[:jam_ruby_user])
|
||||
@jam_ruby_user.administratively_created = true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
ActiveAdmin.register JamRuby::PromoBuzz, :as => 'Buzz' do
|
||||
|
||||
menu :label => 'Buzz', :parent => 'Home Page'
|
||||
menu :label => 'Promo Buzz', :parent => 'Misc'
|
||||
|
||||
config.sort_order = 'position ASC aasm_state DESC updated_at DESC'
|
||||
config.batch_actions = false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do
|
||||
|
||||
menu :label => 'Latest', :parent => 'Home Page'
|
||||
menu :label => 'Promo Latest', :parent => 'Misc'
|
||||
|
||||
config.batch_actions = false
|
||||
config.sort_order = ''
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
ActiveAdmin.register_page "Download CSV" do
|
||||
menu :parent => 'Score'
|
||||
=begin
|
||||
ActiveAdmin.register_page "Download Score CSV" do
|
||||
menu :parent => 'Misc'
|
||||
|
||||
page_action :create_csv, :method => :post do
|
||||
|
||||
|
|
@ -95,4 +96,5 @@ ActiveAdmin.register_page "Download CSV" do
|
|||
#end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
=begin
|
||||
ActiveAdmin.register JamRuby::ScoreHistory, :as => 'Score History' do
|
||||
menu :parent => 'Score'
|
||||
|
||||
|
|
@ -80,3 +81,4 @@ ActiveAdmin.register JamRuby::ScoreHistory, :as => 'Score History' do
|
|||
column "To Client", :to_client_id
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
ActiveAdmin.register_page "Current Scoring Load" do
|
||||
menu :parent => 'Score'
|
||||
menu :parent => 'Misc'
|
||||
|
||||
content :title => "Current Scoring Load" do
|
||||
table_for GetWork.summary do
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ FactoryGirl.define do
|
|||
scoring_timeout Time.now
|
||||
sequence(:channel_id) { |n| "Channel#{n}"}
|
||||
association :user, factory: :user
|
||||
metronome_open false
|
||||
end
|
||||
|
||||
factory :artifact_update, :class => JamRuby::ArtifactUpdate do
|
||||
|
|
|
|||
|
|
@ -264,3 +264,4 @@ jam_track_redeemed.sql
|
|||
connection_metronome.sql
|
||||
preview_jam_track_tracks.sql
|
||||
cohorts.sql
|
||||
jam_track_right_admin_purchase.sql
|
||||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE jam_track_rights ADD COLUMN is_test_purchase BOOLEAN DEFAULT FALSE NOT NULL;
|
||||
|
|
@ -11,6 +11,8 @@ module JamRuby
|
|||
|
||||
validates :user, presence:true
|
||||
validates :jam_track, presence:true
|
||||
validates :is_test_purchase, inclusion: {in: [true, false]}
|
||||
|
||||
validate :verify_download_count
|
||||
after_save :after_save
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ class ApiRecurlyController < ApiController
|
|||
|
||||
def place_order
|
||||
error=nil
|
||||
puts "PLACING ORDER #{params.inspect}"
|
||||
response = {jam_tracks:[]}
|
||||
|
||||
# 1st confirm that all specified JamTracks exist
|
||||
|
|
|
|||
Loading…
Reference in New Issue