diff --git a/admin/app/admin/promo_latest.rb b/admin/app/admin/promo_latest.rb index 5e8435882..d846ec630 100644 --- a/admin/app/admin/promo_latest.rb +++ b/admin/app/admin/promo_latest.rb @@ -2,84 +2,51 @@ ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do menu :label => 'Home Page Latest' - config.sort_order = 'position ASC aasm_state DESC created_at DESC' + config.sort_order = 'position ASC aasm_state DESC updated_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 + form :partial => 'form' + + index do + column 'State' do |pp| pp.aasm_state end + column 'Position' do |pp| pp.position end + column 'Updated' do |pp| pp.updated_at end + default_actions + end + + show do + attributes_table do + row 'State' do |obj| obj.aasm_state end + row 'Position' do |obj| obj.position end + row 'Updated' do |obj| obj.updated_at 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_latest]) + super + end + + def edit + @promo = resource + super + end + + def update + super + end + + end - # end end diff --git a/admin/app/views/admin/latests/_form.html.erb b/admin/app/views/admin/latests/_form.html.erb new file mode 100644 index 000000000..b05d0140e --- /dev/null +++ b/admin/app/views/admin/latests/_form.html.erb @@ -0,0 +1,7 @@ +<%= semantic_form_for([:admin, @promo], :html => {:multipart => true}, :url => @promo.new_record? ? admin_latests_path : "/admin/latests/#{@promo.id}") do |f| %> + <%= f.inputs do %> + <%= f.input(:position, :label => "Position", :input_html => {:maxlength => 4}) %> + <%= f.input(:aasm_state, :as => :select, :collection => Promotional::STATES, :label => 'Status') %> + <% end %> + <%= f.actions %> +<% end %> diff --git a/ruby/lib/jam_ruby/models/promotional.rb b/ruby/lib/jam_ruby/models/promotional.rb index 20d83f1d0..7cecf0ac8 100644 --- a/ruby/lib/jam_ruby/models/promotional.rb +++ b/ruby/lib/jam_ruby/models/promotional.rb @@ -1,6 +1,5 @@ class JamRuby::Promotional < ActiveRecord::Base self.table_name = :promotionals - self.abstract_class = true attr_accessible :expires_at, :position, :aasm_state