From 7212f20a0f1b1d0e17ae1d1659b0b4bd7f7403ee Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Sun, 22 Dec 2013 10:19:39 -0600 Subject: [PATCH] vrfs-927: admin editing buzz promotions --- admin/app/admin/promo_buzz.rb | 113 ++++++++++++++++++++++++ admin/app/admin/promo_latest.rb | 85 ++++++++++++++++++ admin/app/admin/user_progression.rb | 24 ++--- db/up/home_page_promos.sql | 2 - ruby/lib/jam_ruby/models/promotional.rb | 13 +++ 5 files changed, 223 insertions(+), 14 deletions(-) create mode 100644 admin/app/admin/promo_buzz.rb create mode 100644 admin/app/admin/promo_latest.rb diff --git a/admin/app/admin/promo_buzz.rb b/admin/app/admin/promo_buzz.rb new file mode 100644 index 000000000..d3c812d0c --- /dev/null +++ b/admin/app/admin/promo_buzz.rb @@ -0,0 +1,113 @@ +ActiveAdmin.register JamRuby::PromoBuzz, :as => 'Buzz' do + + menu :label => 'Home Page Buzz' + + config.sort_order = 'position ASC aasm_state DESC created_at DESC' + config.batch_actions = false + # config.clear_action_items! + config.filters = false + + form :partial => 'form' + + # index do + # column :email do |user| link_to(truncate(user.email, {:length => 12}), resource_path(user), {:title => "#{user.first_name} #{user.last_name} (#{user.email})"}) end + # column :updated_at do |uu| uu.updated_at.strftime(DATE_FORMAT) end + # column :created_at do |uu| uu.created_at.strftime(DATE_FORMAT) end + # column :city + # column :musician + # column 'Client DL' do |uu| + # if dd = uu.first_downloaded_client_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Client Run' do |uu| + # if dd = uu.first_ran_client_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Certified Gear' do |uu| + # if dd = uu.first_certified_gear_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Any Session' do |uu| + # if dd = uu.first_music_session_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Real Session' do |uu| + # if dd = uu.first_real_music_session_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Good Session' do |uu| + # if dd = uu.first_good_music_session_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Invited' do |uu| + # if dd = uu.first_invited_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Friended' do |uu| + # if dd = uu.first_friended_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Promoted' do |uu| + # if dd = uu.first_social_promoted_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Recorded' do |uu| + # uu.first_recording_at + # end + + # end + + show do + attributes_table do + row :text_short + row :text_long + row 'Status' do |obj| obj.aasm_state end + # row :image do + # image_tag(ad.image.url) + # end + end + end + + controller do + + def new + @promo = JamRuby::PromoBuzz.new + @promo.aasm_state = 'active' + super + end + + def create + promo = PromoBuzz.create_with_params(params[:jam_ruby_promo_buzz]) + super + end + + end + +end diff --git a/admin/app/admin/promo_latest.rb b/admin/app/admin/promo_latest.rb new file mode 100644 index 000000000..5e8435882 --- /dev/null +++ b/admin/app/admin/promo_latest.rb @@ -0,0 +1,85 @@ +ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do + + menu :label => 'Home Page Latest' + + config.sort_order = 'position ASC aasm_state DESC created_at DESC' + config.batch_actions = false + # config.clear_action_items! + config.filters = false + + # index do + # column :email do |user| link_to(truncate(user.email, {:length => 12}), resource_path(user), {:title => "#{user.first_name} #{user.last_name} (#{user.email})"}) end + # column :updated_at do |uu| uu.updated_at.strftime(DATE_FORMAT) end + # column :created_at do |uu| uu.created_at.strftime(DATE_FORMAT) end + # column :city + # column :musician + # column 'Client DL' do |uu| + # if dd = uu.first_downloaded_client_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Client Run' do |uu| + # if dd = uu.first_ran_client_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Certified Gear' do |uu| + # if dd = uu.first_certified_gear_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Any Session' do |uu| + # if dd = uu.first_music_session_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Real Session' do |uu| + # if dd = uu.first_real_music_session_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Good Session' do |uu| + # if dd = uu.first_good_music_session_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Invited' do |uu| + # if dd = uu.first_invited_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Friended' do |uu| + # if dd = uu.first_friended_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Promoted' do |uu| + # if dd = uu.first_social_promoted_at + # dd.strftime(DATE_FORMAT) + # else + # '' + # end + # end + # column 'Recorded' do |uu| + # uu.first_recording_at + # end + + # end + +end diff --git a/admin/app/admin/user_progression.rb b/admin/app/admin/user_progression.rb index 5f6e12ec0..0ae1413c2 100644 --- a/admin/app/admin/user_progression.rb +++ b/admin/app/admin/user_progression.rb @@ -1,5 +1,5 @@ ActiveAdmin.register JamRuby::User, :as => 'User Progression' do - DATE_FORMAT = '%Y-%m-%d %H:%M' + PROGRESSION_DATE = '%Y-%m-%d %H:%M' menu :label => 'User Progression' @@ -10,69 +10,69 @@ ActiveAdmin.register JamRuby::User, :as => 'User Progression' do index do column :email do |user| link_to(truncate(user.email, {:length => 12}), resource_path(user), {:title => "#{user.first_name} #{user.last_name} (#{user.email})"}) end - column :updated_at do |uu| uu.updated_at.strftime(DATE_FORMAT) end - column :created_at do |uu| uu.created_at.strftime(DATE_FORMAT) end + column :updated_at do |uu| uu.updated_at.strftime(PROGRESSION_DATE) end + column :created_at do |uu| uu.created_at.strftime(PROGRESSION_DATE) end column :city column :musician column 'Client DL' do |uu| if dd = uu.first_downloaded_client_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Client Run' do |uu| if dd = uu.first_ran_client_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Certified Gear' do |uu| if dd = uu.first_certified_gear_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Any Session' do |uu| if dd = uu.first_music_session_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Real Session' do |uu| if dd = uu.first_real_music_session_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Good Session' do |uu| if dd = uu.first_good_music_session_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Invited' do |uu| if dd = uu.first_invited_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Friended' do |uu| if dd = uu.first_friended_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end end column 'Promoted' do |uu| if dd = uu.first_social_promoted_at - dd.strftime(DATE_FORMAT) + dd.strftime(PROGRESSION_DATE) else '' end diff --git a/db/up/home_page_promos.sql b/db/up/home_page_promos.sql index 356fc59c8..c4c73f913 100644 --- a/db/up/home_page_promos.sql +++ b/db/up/home_page_promos.sql @@ -8,8 +8,6 @@ CREATE TABLE promotionals( aasm_state VARCHAR(64) DEFAULT 'hidden', /* order of promo within its types */ position integer NOT NULL DEFAULT 0, - /* optional expiration date */ - expires_at TIMESTAMP DEFAULT NULL, /* standard AR timestamps */ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/ruby/lib/jam_ruby/models/promotional.rb b/ruby/lib/jam_ruby/models/promotional.rb index ff87d7548..a48312516 100644 --- a/ruby/lib/jam_ruby/models/promotional.rb +++ b/ruby/lib/jam_ruby/models/promotional.rb @@ -8,6 +8,7 @@ class JamRuby::Promotional < ActiveRecord::Base HIDDEN_STATE = :hidden ACTIVE_STATE = :active EXPIRED_STATE = :expired + STATES = [HIDDEN_STATE, ACTIVE_STATE, EXPIRED_STATE] aasm do state HIDDEN_STATE, :initial => true @@ -37,6 +38,18 @@ end class JamRuby::PromoBuzz < JamRuby::Promotional attr_accessible :original_fpfile_photo, :photo_url, :text_short, :text_long + def self.create_with_params(params) + obj = self.new + obj.text_short = params[:text_short] + obj.text_long = params[:text_long] + obj.save! + obj + end + + def admin_title + "Buzz #{created_at.strftime('%Y-%m-%d %H-%M')}" + end + end class JamRuby::PromoLatest < JamRuby::Promotional