Sponsorship level dashboard

removed donation amount
removed explicit rendering of sponsor levels
This commit is contained in:
Gopesh Tulsyan 2014-06-05 14:52:44 +05:30
parent 8bce579283
commit f68ac7e032
11 changed files with 93 additions and 4 deletions

View file

@ -0,0 +1,17 @@
module Admin
class SponsorshipLevelsController < ApplicationController
before_filter :verify_organizer
def update
if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_sponsorship_levels_path(
conference_id: @conference.short_title),
notice: 'Sponsorship levels were successfully updated.')
else
redirect_to(admin_conference_sponsorship_levels_path(
conference_id: @conference.short_title),
alert: 'Sponsorship levels update failed')
end
end
end
end

View file

@ -10,7 +10,8 @@ class Conference < ActiveRecord::Base
:difficulty_levels_attributes, :use_difficulty_levels,
:use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers,
:media_id, :media_type, :color, :description,
:registration_description, :ticket_description
:registration_description, :ticket_description,
:sponsorship_levels_attributes
has_paper_trail
@ -42,6 +43,7 @@ class Conference < ActiveRecord::Base
accepts_nested_attributes_for :venue
accepts_nested_attributes_for :dietary_choices, :allow_destroy => true
accepts_nested_attributes_for :supporter_levels, :allow_destroy => true
accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true
accepts_nested_attributes_for :event_types, :allow_destroy => true
accepts_nested_attributes_for :email_settings
accepts_nested_attributes_for :questions, :allow_destroy => true

View file

@ -1,5 +1,5 @@
class SponsorshipLevel < ActiveRecord::Base
attr_accessible :title, :donation_amount
attr_accessible :title
validates_presence_of :title
belongs_to :conference
end

View file

@ -0,0 +1,6 @@
<div class="nested-fields">
<%= f.inputs do %>
<%= f.input :title %>
<%= remove_association_link :sponsorship_level, f %>
<% end %>
</div>

View file

@ -0,0 +1,4 @@
.col-md-9
= semantic_form_for(@conference, :url => admin_conference_sponsorship_level_path(@conference.short_title, @conference.sponsorship_levels)) do |f|
= dynamic_association :sponsorship_levels, "Sponsorship Levels", f
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -45,6 +45,10 @@
%ul.nav.nav-stacked.nav-pills.small.collapse.subNav
%li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))}
= link_to 'Rooms', admin_conference_rooms_path(@conference.short_title)
%li{:class=> active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))}
= link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do
%span.glyphicon.glyphicon-star
Sponsorship Levels
%li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) }
= link_to(admin_conference_supporter_levels_path(@conference.short_title)) do
Supporter Levels

View file

@ -28,6 +28,8 @@ Osem::Application.routes.draw do
resources :tracks, only: [:show, :update, :index]
resources :sponsorship_levels, only: [:show, :update, :index]
resources :eventtypes, only: [:show, :index] do
collection do
patch :update

View file

@ -2,7 +2,6 @@ class CreateSponsorshipLevels < ActiveRecord::Migration
def change
create_table :sponsorship_levels do |t|
t.string :title
t.string :donation_amount
t.belongs_to :conference
t.timestamps
end

View file

@ -3,7 +3,6 @@
FactoryGirl.define do
factory :sponsorship_level do
title 'Platin'
donation_amount '$100,000'
conference
end
end

View file

@ -0,0 +1,46 @@
require 'spec_helper'
feature SponsorshipLevel do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
shared_examples 'sponsorship levels' do |user|
scenario 'adds and updates sponsorship level', feature: true, js: true do
conference = create(:conference)
sign_in create(user)
visit admin_conference_sponsorship_levels_path(
conference_id: conference.short_title)
# Add sponsorship level
click_link 'Add sponsorship_level'
expect(page.all('div.nested-fields').count == 1).to be true
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
set('Example sponsorship level')
click_button 'Update Conference'
# Validations
expect(flash).to eq('Sponsorship levels were successfully updated.')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
value).to eq('Example sponsorship level')
# Remove sponsorship level
click_link 'Remove sponsorship_level'
expect(page.all('div.nested-fields').count == 0).to be true
click_button 'Update Conference'
expect(flash).to eq('Sponsorship levels were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
end
end
describe 'admin' do
it_behaves_like 'sponsorship levels', :admin
end
describe 'organizer' do
it_behaves_like 'sponsorship levels', :organizer
end
end

View file

@ -0,0 +1,10 @@
require 'spec_helper'
describe 'admin/sponsorship_levels/index' do
it 'renders sponsorship levels' do
@sponsorship_level = create(:sponsorship_level)
assign :conference, @sponsorship_level.conference
render
expect(rendered).to include('Platin')
end
end