Sponsor dashboard added, with sponsor component for splash page

This commit is contained in:
Gopesh Tulsyan 2014-05-26 13:51:03 +05:30
parent 643b8b173a
commit ea119a8158
36 changed files with 549 additions and 12 deletions

View file

@ -0,0 +1,43 @@
class Admin::OrganizationsController < ApplicationController
before_filter :verify_organizer
respond_to :html
def index
@organizations = Organization.all
end
def new
@organization = Organization.new
end
def create
@organization = Organization.new(params[:organization])
flash[:notice] = 'Organization was successfully created.' if @organization.save
respond_with @organization, :location => admin_organizations_path
end
def show
@organization = Organization.find(params[:id])
end
def edit
@organization = Organization.find(params[:id])
end
def update
@organization = Organization.find(params[:id])
flash[:notice] = 'Organization was successfully updated' if @organization.update_attributes(params[:organization])
respond_with @organization, :location => admin_organizations_path
end
def delete
@organization = Organization.find(params[:id])
end
def destroy
@organization = Organization.find(params[:id])
@organization.destroy
redirect_to admin_organizations_path, :notice => "Organization got deleted"
end
end

View file

@ -0,0 +1,16 @@
class Admin::SponsorshipLevelsController < ApplicationController
before_filter :verify_organizer
def show
render :sponsorship_levels
end
def update
begin
@conference.update_attributes!(params[:conference])
redirect_to(admin_conference_sponsorship_levels_path(:conference_id => @conference.short_title), :notice => 'Sponsorship levels were successfully updated.')
rescue Exception => e
redirect_to(admin_conference_sponsorship_levels_path(:conference_id => @conference.short_title), :alert => "Sponsorship levels update failed: #{e.message}")
end
end
end

View file

@ -0,0 +1,17 @@
class Admin::SponsorshipsController < ApplicationController
before_filter :verify_organizer
def index
end
def create
params[:sponsorship_registration][:conference_id] = @conference.id
sponsorship = SponsorshipRegistration.new(params[:sponsorship_registration])
if sponsorship.save
redirect_to(admin_conference_sponsorships_path(:conference_id => @conference.short_title), :notice => "Sponsorship added")
else
redirect_to(admin_conference_sponsorships_path(:conference_id => @conference.short_title),
:alert => "Sponsorship creation failed.#{sponsorship.errors.full_messages.join('. ')}")
end
end
end

View file

@ -3,13 +3,16 @@
class Conference < ActiveRecord::Base
attr_accessible :title, :short_title, :social_tag, :contact_email, :timezone, :html_export_path,
:start_date, :end_date, :rooms_attributes, :tracks_attributes, :dietary_choices_attributes,
:use_dietary_choices, :use_supporter_levels, :supporter_levels_attributes, :social_events_attributes,
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
:dietary_choices_attributes,
:use_dietary_choices, :use_supporter_levels, :supporter_levels_attributes,
:social_events_attributes,
:event_types_attributes, :registration_start_date, :registration_end_date, :logo,
:questions_attributes, :question_ids, :answers_attributes, :answer_ids,
:difficulty_levels_attributes, :use_difficulty_levels,
:use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers,
:media_id, :media_type
:media_id, :media_type, :sponsorship_levels_attributes, :sponsor_email,
:sponsor_description
has_paper_trail
@ -30,6 +33,8 @@ class Conference < ActiveRecord::Base
has_many :vdays, :dependent => :destroy
has_many :vpositions, :dependent => :destroy
has_many :vchoices, :dependent => :destroy
has_many :sponsorship_levels, dependent: :destroy
has_many :sponsorship_registrations, dependent: :destroy
belongs_to :venue
@ -40,6 +45,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

@ -0,0 +1,16 @@
class Organization < ActiveRecord::Base
attr_accessible :title, :photo, :email_id, :description, :website_url
has_many :sponsorship_registrations, dependent: :destroy
has_attached_file :photo,
:styles => {:thumb => "100x100>", :large => "300x300>" }
validates_attachment_content_type :photo,
:content_type => [/jpg/, /jpeg/, /png/, /gif/],
:size => { :in => 0..500.kilobytes }
validates_presence_of :title,
:email_id,
:website_url
validates_uniqueness_of :email_id
end

View file

@ -0,0 +1,6 @@
class SponsorshipLevel < ActiveRecord::Base
attr_accessible :title, :description
belongs_to :conference
has_many :sponsorship_registrations
validates_presence_of :title
end

View file

@ -0,0 +1,11 @@
class SponsorshipRegistration < ActiveRecord::Base
attr_accessible :name, :email_id, :contact_no, :amount_donated, :method_of_donation,
:sponsorship_level_id, :conference_id, :organization_id
belongs_to :organization
belongs_to :sponsorship_level
belongs_to :conference
validates_presence_of :name, :email_id, :contact_no, :amount_donated,
:method_of_donation, :sponsorship_level,
:conference, :organization
validates_uniqueness_of :email_id
end

View file

@ -1,3 +1,33 @@
.row
.col-md-8
%h1 Dashboard for #{@conference.title}
%h1 Dashboard for #{@conference.title}
.col-md-9
= semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f|
= f.input :title, :hint => "The full name of the conference, such as 'OpenSUSE Conference 2013'"
= f.input :short_title, :hint => "A short title, such as 'osc2013', to be used in URLs"
= f.input :social_tag, :hint => "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'"
= f.input :contact_email, :hint => "Contact email address for your conference. Will be used as reply-to address in emails sent out by the system."
= f.inputs :name => "Scheduling" do
= f.input :timezone, :as => :time_zone, :hint => "The conference time zone"
= f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }
= f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
= f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" }
= f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" }
= f.inputs :name => "Media" do
- if !@conference.logo.blank?
= image_tag @conference.logo(:thumb)
= f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page."
= f.input :media_type, :as => :select, :label => "Conference Promo Media Type", :class=>"form-control", :collection => Conference.media_types.values, :include_blank => false, :hint => "This media-item will be used to represent this conference at various places in OSEM."
= f.input :media_id, :label => "Conference Promo Media ID", :as => :string
%p{:class => "help-block media-type", :id => "youtube-help"} Go to your YouTube video, click on "share" and copy everything behind http://youtu.be/"
%p{:class => "help-block media-type", :id => "slideshare-help", :style => "display:none"} Go to your SlideShare, click on "share" -> "embed" and copy the id
%p{:class => "help-block media-type", :id => "flickr-help", :style => "display:none"} Go to your flickr image, click on "Grab the link" -> "Show short url" and copy everything behind https://flic.kr/p/
%p{:class => "help-block media-type", :id => "vimeo-help", :style => "display:none"} Go to your vimeo video, click on "share" and copy everything behind http://vimeo.com/
%p{:class => "help-block media-type", :id => "speakerdeck-help", :style => "display:none"} Go to your SpeakerDeck, click on "share" -> "embed" and copy the data-id
%p{:class => "help-block media-type", :id => "instagram-help", :style => "display:none"} Go to your Instagram photo page and copy everything behind instagram.com/p/ (without trailing /# hash symbol)
= f.input :sponsor_email, hint: 'This mail id is used by sponsors to contact organizers'
= f.input :sponsor_description, hint: 'This description will be displayed in sponsor section of splash page'
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
>>>>>>> Sponsor dashboard added, with sponsor component for splash page

View file

@ -0,0 +1,11 @@
= semantic_form_for [:admin, @organization] do |f|
= f.inputs "Basic Information" do
= f.input :title, as: :string
= f.input :email_id, as: :string
= f.input :website_url, as: :string
= f.input :description
- if !@organization.photo.blank?
= image_tag @organization.photo(:thumb)
= f.input :photo
= f.actions do
= f.action :submit, :button_html => {:class => "btn primary"}

View file

@ -0,0 +1,36 @@
.row
.col-md-12
.page-header
%h1
Organizations
- if @organizations
= "(#{@organizations.length})"
= link_to "New Organization", new_admin_organization_path, :class => "btn btn-success pull-right"
.row
.col-md-12
.well
%table.table.table-striped.table-bordered.table-hover#organization
%thead
%th
%b Title
%th
%b Email
%th
%th
%th
- @organizations.each do |organization|
%tr
%td= organization.title
%td= organization.email_id
%td= link_to "Edit", edit_admin_organization_path(organization)
%td= link_to "View", admin_organization_path(organization)
%td=link_to 'Delete',admin_organization_path(organization), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger"
:javascript
$(document).ready(function() {
$('#organization').dataTable( {
"bPaginate": false,
"bLengthChange": false
} );
} );

View file

@ -0,0 +1,26 @@
%table.table
%tr
%td
%b Title
%td
= @organization.title
%tr
%td
%b Email
%td
= @organization.email_id
%tr
%td
%b Logo
%td
= image_tag(@organization.photo(:thumb), class: 'img-responsive') if @organization.photo?
%tr
%td
%b Description
%td
= @organization.description
%tr
%td
%b Website Url
%td
= @organization.website_url

View file

@ -0,0 +1,7 @@
<div class="nested-fields">
<%= f.inputs do %>
<%= f.input :title %>
<%= f.input :description %>
<%= 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

@ -0,0 +1,45 @@
#new-sponsorship-dialog
= semantic_form_for :sponsorship_registration, :html => {:id => "sponsorship-add-form"} do |f|
= f.input :name, :label => "Sponsorship Name"
= f.input :email_id, :label => "Sponsorship Email"
= f.input :organization_id, as: :select, collection: Organization.all
= f.input :sponsorship_level_id, :as => :select, :collection => @conference.sponsorship_levels
= f.input :contact_no, :label => "Phone Number"
= f.input :amount_donated
= f.input :method_of_donation
= f.action :submit, :button_html => { :value => "Save", :class => "btn btn-primary" }
.row
.col-md-12
.pull-right{:style=>"margin-top:20px; margin-bottom:20px;"}
= link_to "New Sponsorship", "#", :id => "new-sponsorship-button", :class => "btn btn-success"
.row
.col-md-12
%h2 Sponsorships
.well
%table.table.table-striped#sponsorships
%thead
%th
Name
%th
Email
%th
Level
%th
Organization
%th
Phone Number
%th
Amount Donated
%th
Method of Donation
%tbody
- @conference.sponsorship_registrations.each do |u|
%tr
%td= u.name
%td= u.email_id
%td= u.sponsorship_level.title if u.sponsorship_level
%td= u.organization.title
%td= u.contact_no
%td= u.amount_donated
%td= u.method_of_donation

View file

@ -0,0 +1,20 @@
%div.container#sponsors.text-center
%div.row
%div.col-md-12
%h2 Sponsors
-if !@conference.sponsor_description.blank?
%p #{ @conference.sponsor_description }
-if !@conference.sponsor_email.blank?
%h3= mail_to "#{ @conference.sponsor_email }", 'Become a Sponsor'
- if !@conference.sponsorship_levels.blank?
- @conference.sponsorship_levels.each do |l|
- if !l.sponsorship_registrations.blank?
%div.row.multi-columns-row
%h4 #{l.title}
- l.sponsorship_registrations.each_with_index do |r,index|
%div.col-md-4
- if !r.organization.photo.blank?
= link_to image_tag(r.organization.photo(:large), class: 'img-responsive', alt: "#{r.organization.title} Logo", title: "#{r.organization.description}"), "http://#{r.organization.website_url}"
- unless index == 0
- if index%2 == 0
%div.clearfix.visible-md.visible-lg

View file

@ -1,3 +1,7 @@
= content_for :splash_logo do
= link_to @conference.title, "#", :class => 'navbar-brand'
= render :partial => "home/conference_details", :locals => {:conference => @conference}
= content_for :splash_header do
%ul.nav.navbar-nav
%li
%a{ href: '#sponsors' } Sponsors
= render 'sponsor'

View file

@ -24,6 +24,10 @@
= link_to(admin_conference_registrations_path(@conference.short_title)) do
%span.glyphicon.glyphicon-user
Registrations
%li{:class=> active_nav_li(admin_conference_sponsorships_path(@conference.short_title))}
= link_to(admin_conference_sponsorships_path(@conference.short_title)) do
%span.glyphicon.glyphicon-usd
Sponsorships
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
= link_to(admin_conference_events_path(@conference.short_title)) do
%span.glyphicon.glyphicon-comment
@ -31,7 +35,7 @@
%li{class: active_nav_li(admin_conference_schedule_path(@conference.short_title))}
= link_to(admin_conference_schedule_path(@conference.short_title), target: '_blank') do
%span.glyphicon.glyphicon-calendar
Shedule
Schedule
%hr
%li.nav-header
%a
@ -49,6 +53,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_emails_path(@conference.short_title))}
= link_to(admin_conference_emails_path(@conference.short_title)) do
%span.glyphicon.glyphicon-envelope

View file

@ -28,3 +28,8 @@
= link_to(admin_people_path) do
%span.glyphicon.glyphicon-star-empty
People
%li
= link_to(admin_organizations_path) do
%span.glyphicon.glyphicon-th
Organization

View file

@ -14,6 +14,7 @@
-if has_role?(current_user, "admin") || has_role?(current_user, "organizer")
%li.divider
%li
= link_to(admin_conference_index_path()) do
%span.glyphicon.glyphicon-home
Administration

View file

@ -1,12 +1,11 @@
Osem::Application.routes.draw do
get 'conference/show'
devise_for :users, :controllers => { :registrations => :registrations }, :path => 'accounts'
namespace :admin do
resources :users
resources :people
resources :organizations
resources :conference do
get "/schedule" => "schedule#show"
patch "/schedule" => "schedule#update"
@ -38,6 +37,8 @@ Osem::Application.routes.draw do
resources :supporter_levels, only: [:show, :update, :index]
resources :sponsorship_levels, only: [:show, :update, :index]
resources :emails, only: [:show, :update, :index]
resources :callforpapers, only: [:create] do
@ -59,7 +60,7 @@ Osem::Application.routes.draw do
end
resource :speaker, :only => [:edit, :update]
end
resources :sponsorships
resources :supporters
end
end

View file

@ -0,0 +1,10 @@
class CreateSponsorshipLevels < ActiveRecord::Migration
def change
create_table :sponsorship_levels do |t|
t.string :title
t.text :description
t.belongs_to :conference
t.timestamps
end
end
end

View file

@ -0,0 +1,15 @@
class CreateSponsorshipRegistrations < ActiveRecord::Migration
def change
create_table :sponsorship_registrations do |t|
t.string :name
t.string :email_id
t.string :contact_no
t.float :amount_donated
t.string :method_of_donation
t.belongs_to :organization
t.belongs_to :sponsorship_level
t.belongs_to :conference
t.timestamps
end
end
end

View file

@ -0,0 +1,14 @@
class CreateOrganizations < ActiveRecord::Migration
def change
create_table :organizations do |t|
t.string :title
t.string :email_id
t.text :description
t.string :photo_file_name
t.string :photo_content_type
t.integer :photo_file_size
t.datetime :photo_updated_at
t.timestamps
end
end
end

View file

@ -0,0 +1,5 @@
class AddSponsorEmailToConferences < ActiveRecord::Migration
def change
add_column :conferences, :sponsor_email, :string
end
end

View file

@ -0,0 +1,5 @@
class AddSponsorDescriptionToConferences < ActiveRecord::Migration
def change
add_column :conferences, :sponsor_description, :text
end
end

View file

@ -0,0 +1,5 @@
class AddWebsiteUrlToOrganization < ActiveRecord::Migration
def change
add_column :organizations, :website_url, :string
end
end

View file

@ -9,5 +9,10 @@ FactoryGirl.define do
contact_email 'admin@example.com'
start_date Date.today
end_date Date.tomorrow
factory :conference_with_sponsorship_level do
after(:build) do |conference|
conference.sponsorship_levels << build(:sponsorship_level, conference: conference)
end
end
end
end

View file

@ -0,0 +1,9 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :organization do
title 'Example Organization'
sequence(:email_id) { |n| "example#{n}@example.com" }
website_url 'www.example.com'
end
end

View file

@ -0,0 +1,9 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :sponsorship_level do
title 'Platin'
description 'Lorem Ipsum'
conference
end
end

View file

@ -0,0 +1,19 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :sponsorship_registration do
name 'Example Person'
sequence(:email_id) { |n| "example#{n}@example.com" }
contact_no '90000000000'
amount_donated '$1,00,000'
method_of_donation 'Cheque'
conference
sponsorship_level
organization
after(:build) do |sponsorship_registration|
sponsorship_registration.sponsorship_level =
build(:sponsorship_level,
conference: sponsorship_registration.conference)
end
end
end

View file

@ -2,7 +2,7 @@
FactoryGirl.define do
factory :user do
email 'example@example.com'
sequence(:email) { |n| "example#{n}@example.com" }
password 'changeme'
password_confirmation 'changeme'
confirmed_at Time.now

View file

@ -0,0 +1,52 @@
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')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
set('Lorem Ipsum Dolsum')
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')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
value).to eq('Lorem Ipsum Dolsum')
# 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,21 @@
require 'spec_helper'
describe Organization do
describe 'validations' do
it 'has a valid factory' do
expect(build(:organization)).to be_valid
end
it 'is not valid without a title' do
should validate_presence_of(:title)
end
it 'is not valid without a email id' do
should validate_presence_of(:email_id)
end
it 'is not valid with a duplicate email_id' do
should validate_uniqueness_of(:email_id)
end
end
end

View file

@ -0,0 +1,12 @@
require 'spec_helper'
describe SponsorshipLevel do
describe 'validations' do
it 'it has valid factory' do
expect(build(:sponsorship_level)).to be_valid
end
it 'is not valid without a title' do
should validate_presence_of(:title)
end
end
end

View file

@ -0,0 +1,41 @@
require 'spec_helper'
describe SponsorshipRegistration do
describe 'validations' do
it 'has a valid factory' do
expect(build(:sponsorship_registration)).to be_valid
end
it 'is not valid without a name' do
should validate_presence_of(:name)
end
it 'is not valid without a email_id' do
should validate_presence_of(:email_id)
end
it 'is not valid without a contact number' do
should validate_presence_of(:contact_no)
end
it 'is not valid without a amount donated' do
should validate_presence_of(:amount_donated)
end
it 'is not valid without a method of donation' do
should validate_presence_of(:method_of_donation)
end
it 'is not valid without a sponsorship level' do
should validate_presence_of(:sponsorship_level)
end
it 'is not valid without a organization' do
should validate_presence_of(:organization)
end
it 'is not valid without a conference' do
should validate_presence_of(:conference)
end
end
end

View file

@ -1,10 +1,12 @@
require 'spec_helper'
describe 'conference/show.html.haml' do
it 'renders conference details' do
@conference = create(:conference)
@sponsorship_registration = create(:sponsorship_registration)
@conference = @sponsorship_registration.conference
assign :conference, @conference
render
expect(render).to include("#{@conference.title}")
expect(view).to render_template(:partial => "conference/_sponsor")
expect(rendered).to include("#{@sponsorship_registration.sponsorship_level.title}")
end
end