vrfs-927: admin editing buzz promotions

This commit is contained in:
Jonathan Kolyer 2013-12-22 10:19:39 -06:00
parent ec126793c7
commit 7212f20a0f
5 changed files with 223 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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