Refactoring Admin menu #384
This commit is contained in:
parent
518e1cc62b
commit
d1f5b1e3cc
30 changed files with 865 additions and 190 deletions
|
|
@ -121,3 +121,50 @@ body {
|
|||
padding-top: 35px;
|
||||
padding-bottom: 35px;
|
||||
}
|
||||
|
||||
.dl-horizontal dt { white-space: normal; }
|
||||
|
||||
.equal, .equal > div[class*='col-'] {
|
||||
display: -webkit-box;
|
||||
display: -moz-box;
|
||||
display: -ms-flexbox;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
flex:1 0 auto;
|
||||
}
|
||||
|
||||
.row-flex, .row-flex > div[class*='col-'] {
|
||||
display: -webkit-box;
|
||||
display: -moz-box;
|
||||
display: -ms-flexbox;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
flex:1 1 auto;
|
||||
}
|
||||
|
||||
.row-flex-wrap {
|
||||
-webkit-flex-flow: row wrap;
|
||||
align-content: flex-start;
|
||||
flex:0;
|
||||
}
|
||||
|
||||
.row-flex > div[class*='col-'], .container-flex > div[class*='col-'] {
|
||||
margin:-.2px; /* hack adjust for wrapping */
|
||||
}
|
||||
|
||||
.container-flex > div[class*='col-'] div,.row-flex > div[class*='col-'] div {
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.flex-col {
|
||||
display: flex;
|
||||
display: -webkit-flex;
|
||||
flex: 1 100%;
|
||||
flex-flow: column nowrap;
|
||||
}
|
||||
|
||||
.flex-grow {
|
||||
display: flex;
|
||||
-webkit-flex: 2;
|
||||
flex: 2;
|
||||
}
|
||||
2
app/controllers/admin/conference_basics_controller.rb
Normal file
2
app/controllers/admin/conference_basics_controller.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
class Admin::ConferenceBasicsController < Admin::ConferenceController
|
||||
end
|
||||
2
app/controllers/admin/conference_contacts_controller.rb
Normal file
2
app/controllers/admin/conference_contacts_controller.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
class Admin::ConferenceContactsController < Admin::ConferenceController
|
||||
end
|
||||
|
|
@ -72,8 +72,8 @@ class Admin::ConferenceController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
@conference = Conference.find_by(short_title: params[:id])
|
||||
short_title = @conference.short_title
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
old_short_title = @conference.short_title
|
||||
@conference.assign_attributes(params[:conference])
|
||||
notify_on_conf_dates_updates = (@conference.start_date_changed? || @conference.end_date_changed?)\
|
||||
&& @conference.email_settings.send_on_updated_conference_dates\
|
||||
|
|
@ -85,13 +85,22 @@ class Admin::ConferenceController < ApplicationController
|
|||
&& !@conference.email_settings.updated_conference_registration_dates_subject.blank?\
|
||||
&& @conference.email_settings.updated_conference_registration_dates_template
|
||||
|
||||
# Change :return_to if short_title changed
|
||||
if @conference.short_title_changed?
|
||||
session[:return_to] =
|
||||
session[:return_to].gsub! old_short_title, params[:conference][:short_title] unless
|
||||
session[:return_to].blank?
|
||||
end
|
||||
|
||||
if @conference.update_attributes(params[:conference])
|
||||
Mailbot.delay.conference_date_update_mail(@conference) if notify_on_conf_dates_updates
|
||||
Mailbot.delay.conference_registration_date_update_mail(@conference) if notify_on_conf_reg_dates_updates
|
||||
redirect_to(edit_admin_conference_path(id: @conference.short_title),
|
||||
redirect_to(session[:return_to],
|
||||
notice: 'Conference was successfully updated.') && return unless session[:return_to].blank?
|
||||
redirect_to(admin_conference_path(id: @conference.short_title),
|
||||
notice: 'Conference was successfully updated.')
|
||||
else
|
||||
redirect_to(edit_admin_conference_path(id: short_title),
|
||||
redirect_to(:back,
|
||||
alert: 'Updating conference failed. ' \
|
||||
"#{@conference.errors.full_messages.join('. ')}.")
|
||||
end
|
||||
|
|
@ -165,8 +174,7 @@ class Admin::ConferenceController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@conferences = Conference.all
|
||||
@conference = Conference.find_by(short_title: params[:id])
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @conference.to_json }
|
||||
|
|
|
|||
63
app/controllers/admin/photos_controller.rb
Normal file
63
app/controllers/admin/photos_controller.rb
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
class Admin::PhotosController < ApplicationController
|
||||
before_action :set_conference
|
||||
before_action :set_photo, only: [:edit, :update, :destroy]
|
||||
|
||||
# GET /admin/photos
|
||||
def index
|
||||
@photos = @conference.photos.all
|
||||
end
|
||||
|
||||
# GET /admin/photos/new
|
||||
def new
|
||||
@photo = @conference.photos.build
|
||||
end
|
||||
|
||||
# GET /admin/photos/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /admin/photos
|
||||
def create
|
||||
@photo = @conference.photos.build(photo_params)
|
||||
|
||||
if @photo.save
|
||||
redirect_to admin_conference_photos_path, notice: 'Photo was successfully created.'
|
||||
else
|
||||
flash[:alert] = "A error prohibited this Photo from being saved: #{@photo.errors.full_messages.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /admin/photos/1
|
||||
def update
|
||||
if @photo.update(photo_params)
|
||||
redirect_to admin_conference_photos_path, notice: 'Photo was successfully updated.'
|
||||
else
|
||||
flash[:alert] = "A error prohibited this Photo from being saved: #{@photo.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /admin/photos/1
|
||||
def destroy
|
||||
@photo.destroy
|
||||
redirect_to admin_conference_photos_path, notice: 'Photo was successfully destroyed.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_conference
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
end
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_photo
|
||||
@photo = Photo.find_by(id: params[:id])
|
||||
end
|
||||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
def photo_params
|
||||
params[:photo]
|
||||
end
|
||||
end
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<div class="nested-fields">
|
||||
<%= f.inputs do %>
|
||||
<%= image_tag(f.object.picture(:thumb)) unless f.object.picture.blank? %>
|
||||
<%= f.input :picture, hint: 'This photo will appear in the gallery of the splash
|
||||
so please give photos of banner sizes' %>
|
||||
<%= f.input :description, :input_html => {:rows => 2 }, hint: 'This description will appear
|
||||
at the bottom of each photo' %>
|
||||
<%= remove_association_link :photo, f %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
= conference_progress['process'] + '%'
|
||||
%li{'class'=>class_for_todo(conference_progress['registration'])}
|
||||
%span{'class'=>icon_for_todo(conference_progress['registration'])}
|
||||
= link_to 'Set up registration period', edit_admin_conference_path(conference_progress['short_title'], :anchor => 'conference-end-datepicker')
|
||||
= link_to 'Set up registration period', edit_admin_conference_conference_basics_path(conference_progress['short_title'], :anchor => 'conference-end-datepicker')
|
||||
%li{'class'=>class_for_todo(conference_progress['cfp'])}
|
||||
%span{'class'=>icon_for_todo(conference_progress['cfp'])}
|
||||
= link_to 'Set up call for papers', admin_conference_callforpapers_path(conference_progress['short_title'])
|
||||
|
|
@ -29,4 +29,4 @@
|
|||
= link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title'])
|
||||
%li{class: class_for_todo(conference_progress['make_conference_public'])}
|
||||
%span{'class'=>icon_for_todo(conference_progress['make_conference_public'])}
|
||||
= link_to 'Make Splash Page Public for Visitors', edit_admin_conference_path(conference_progress['short_title'])
|
||||
= link_to 'Make Splash Page Public for Visitors', edit_admin_conference_conference_basics_path(conference_progress['short_title'])
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
.row
|
||||
.col-md-8
|
||||
= semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f|
|
||||
|
||||
= f.input :make_conference_public, hint: 'This will enable the visitors to view the splash page(the "View Conference" button will be visible now on the home page), it is recommended to enable this after you have finished setting up all the components for display'
|
||||
= f.input :include_program_in_splash, hint: 'On setting this true you will enable the program component to be displayed on the splash page.This component includes tracks, keynote speakers and the schedule'
|
||||
= 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.input :color, :hint => "The color will be used eg for the dashboard.", :input_html => {:size => 6, :type => "color"}
|
||||
= f.inputs name: 'Banner for Splash' do
|
||||
= f.input :include_banner_in_splash, hint: 'This enable the Banner Photo with description to be displayed on the splash'
|
||||
= f.input :banner_photo, hint: 'This will be the top most component of the splash.This background cover will contain start_date and end_date of the conference and the description'
|
||||
= f.input :description, hint: markdown_hint("This description will be shown at the bottom of the banner photo of the Splash."), input_html: { data: { provide: "markdown-editable" } }
|
||||
|
||||
= 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.inputs name: 'Registration' do
|
||||
= f.input :include_registrations_in_splash, hint: 'On setting this true you will enable the registrations to be displayed on the splash page'
|
||||
= 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.input :registration_description, hint: markdown_hint("This description will appear in registration segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
|
||||
= f.input :ticket_description, hint: markdown_hint("This will appear in the Tickets segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
|
||||
= f.input :sponsor_description, hint: markdown_hint("This will appear in the sponsor segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
|
||||
= f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers'
|
||||
= f.input :lodging_description, hint: markdown_hint("This will appear in the lodging segment of the splash."), input_html: { data: { provide: "markdown-editable" } }
|
||||
|
||||
= dynamic_association :photos, "Photos", f
|
||||
|
||||
= f.inputs :name => 'Social Media' do
|
||||
- if !@conference.logo.blank?
|
||||
= image_tag @conference.logo(:thumb)
|
||||
= f.input :include_social_media_in_splash, hint: 'On setting this true you will enable the social media links to be displayed on the splash page'
|
||||
= 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 :facebook_url, hint: 'This will appear in the social media section as link to the Facebook page of your Conference'
|
||||
= f.input :google_url, label: 'Google+ Url', hint: 'This will appear in the social media section as the link to the Google+ Page of your Conference'
|
||||
= f.input :twitter_url, hint: 'This will appear in the social media section as the link to the Twitter Page of your Conference'
|
||||
= f.input :instagram_url, hint: 'This will appear in the social media section as the link to the Instagram Page of your Conference'
|
||||
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
||||
30
app/views/admin/conference_basics/_form.html.haml
Normal file
30
app/views/admin/conference_basics/_form.html.haml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
.row
|
||||
.col-md-8
|
||||
= semantic_form_for(@conference, url: admin_conference_conference_basics_path(@conference.short_title), html: { multipart: true }) do |f|
|
||||
= f.input :make_conference_public, hint: 'This will enable the visitors to view the splash page(the "View Conference" button will be visible now on the home page), it is recommended to enable this after you have finished setting up all the components for display'
|
||||
= f.input :include_program_in_splash, hint: 'On setting this true you will enable the program component to be displayed on the splash page.This component includes tracks, keynote speakers and the schedule'
|
||||
= 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"
|
||||
%p{'style'=>'color: red;'} Attention: If you alter the short title of the conference, all URLs will also change!
|
||||
- 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 :color, hint: 'The color will be used on the dashboard (e.g. line / pie charts).', input_html: { size: 6, type: 'color' }
|
||||
= f.inputs name: 'Banner for Splash' do
|
||||
= f.input :include_banner_in_splash, hint: 'This enable the Banner Photo with description to be displayed on the splash'
|
||||
= f.input :banner_photo, hint: 'This will be the top most component of the splash.This background cover will contain start_date and end_date of the conference and the description'
|
||||
= f.input :description, hint: markdown_hint('This description will be shown at the bottom of the banner photo of the Splash.'), input_html: { rows: 5, data: { provide: '"markdown-editable" '} }
|
||||
= 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.inputs name: 'Media' do
|
||||
= 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.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
82
app/views/admin/conference_basics/_show.html.haml
Normal file
82
app/views/admin/conference_basics/_show.html.haml
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
.row{'style'=>'padding-top: 15px;'}
|
||||
.col-md-6
|
||||
%dl.dl-horizontal
|
||||
%dt
|
||||
Title
|
||||
%dd
|
||||
= @conference.title
|
||||
%dt
|
||||
Short Title
|
||||
%dd
|
||||
= @conference.short_title
|
||||
%dt
|
||||
Description
|
||||
%dd
|
||||
- unless @conference.description.blank?
|
||||
= markdown(@conference.description)
|
||||
- else
|
||||
Not set!
|
||||
%dt
|
||||
Date
|
||||
%dd
|
||||
= date_string(@conference.start_date, @conference.end_date)
|
||||
%dt
|
||||
Color
|
||||
%dd
|
||||
%div.text-center{'style'=>"width: 25px; height: 25px; background: #{@conference.color};"}
|
||||
.row.row-flex.row-flex-wrap
|
||||
.col-md-4
|
||||
.thumbnail.flex-col
|
||||
%h3.text-center
|
||||
Conference Logo
|
||||
- if @conference.logo?
|
||||
= image_tag(@conference.logo(:large), class: 'img-responsive')
|
||||
.caption.flex-grow
|
||||
.caption
|
||||
%p
|
||||
%dl.dl-horizontal
|
||||
%dt
|
||||
Filename
|
||||
%dd
|
||||
= @conference.logo_file_name
|
||||
-else
|
||||
%h4.text-center
|
||||
Not set!
|
||||
.col-md-4
|
||||
.thumbnail.flex-col
|
||||
%h3.text-center
|
||||
Conference Banner
|
||||
- if @conference.banner_photo?
|
||||
= image_tag(@conference.banner_photo(:large), class: 'img-responsive')
|
||||
.caption.flex-grow
|
||||
.caption
|
||||
%p
|
||||
%dl.dl-horizontal
|
||||
%dt
|
||||
Filename
|
||||
%dd
|
||||
= @conference.banner_photo_file_name
|
||||
- else
|
||||
%h4.text-center
|
||||
Not set!
|
||||
.col-md-4
|
||||
.thumbnail
|
||||
%h3.text-center
|
||||
Media
|
||||
- unless @conference.media_id.blank?
|
||||
.flexvideo
|
||||
= render partial: 'shared/media_item', locals: { media_type: @conference.media_type, media_id: @conference.media_id }
|
||||
.caption
|
||||
%p
|
||||
%dl.dl-horizontal
|
||||
%dt
|
||||
Media Type
|
||||
%dd
|
||||
= @conference.media_type
|
||||
%dt
|
||||
Media ID
|
||||
%dd
|
||||
= @conference.media_id
|
||||
- else
|
||||
%h4.text-center
|
||||
Not set!
|
||||
16
app/views/admin/conference_basics/edit.html.haml
Normal file
16
app/views/admin/conference_basics/edit.html.haml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
.row
|
||||
.col-md-12
|
||||
%ul.nav.nav-tabs{'role'=>'tablist'}
|
||||
%li.active
|
||||
%a{'href'=> '#show', 'role'=>'tab', 'data-toggle'=>'tab'}
|
||||
Show
|
||||
%li
|
||||
%a{'href'=> '#edit', 'role'=>'tab', 'data-toggle'=>'tab'}
|
||||
Edit
|
||||
.row
|
||||
.col-md-12
|
||||
.tab-content
|
||||
.tab-pane.active#show
|
||||
= render partial: 'show'
|
||||
.tab-pane#edit
|
||||
= render partial: 'form'
|
||||
13
app/views/admin/conference_contacts/_form.html.haml
Normal file
13
app/views/admin/conference_contacts/_form.html.haml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
.row
|
||||
.col-md-8
|
||||
= semantic_form_for(@conference, :url => admin_conference_conference_basics_path(@conference.short_title),:html => {:multipart => true}) do |f|
|
||||
= f.inputs :name => 'Contact' do
|
||||
= 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 => 'Social Media' do
|
||||
= f.input :include_social_media_in_splash, hint: 'On setting this true you will enable the social media links to be displayed on the splash page'
|
||||
= f.input :social_tag, hint: "The hashtag you'll use on Twitter and Google+. Don't include the '#' sign!'"
|
||||
= f.input :facebook_url, hint: 'This will appear in the social media section as link to the Facebook page of your Conference'
|
||||
= f.input :google_url, label: 'Google+ Url', hint: 'This will appear in the social media section as the link to the Google+ Page of your Conference'
|
||||
= f.input :twitter_url, hint: 'This will appear in the social media section as the link to the Twitter Page of your Conference'
|
||||
= f.input :instagram_url, hint: 'This will appear in the social media section as the link to the Instagram Page of your Conference'
|
||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
31
app/views/admin/conference_contacts/_show.html.haml
Normal file
31
app/views/admin/conference_contacts/_show.html.haml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
%ul.list-unstyled
|
||||
- unless @conference.contact_email.blank?
|
||||
%li
|
||||
= link_to "#{ @conference.contact_email }" do
|
||||
%i.fa.fa-envelope.fa-3x
|
||||
= @conference.contact_email
|
||||
- unless @conference.social_tag.blank?
|
||||
%li
|
||||
= link_to "#{ @conference.social_tag }" do
|
||||
%i.fa.fa-thumbs-o-up.fa-3x
|
||||
= "##{@conference.social_tag}"
|
||||
- unless @conference.facebook_url.blank?
|
||||
%li
|
||||
= link_to "#{ @conference.facebook_url }" do
|
||||
%i.fa.fa-facebook-square.fa-3x
|
||||
= @conference.facebook_url
|
||||
- unless @conference.twitter_url.blank?
|
||||
%li
|
||||
= link_to "#{ @conference.twitter_url }" do
|
||||
%i.fa.fa-twitter.fa-3x
|
||||
= @conference.twitter_url
|
||||
- unless @conference.instagram_url.blank?
|
||||
%li
|
||||
= link_to "#{ @conference.instagram_url }" do
|
||||
%i.fa.fa-instagram.fa-3x
|
||||
= @conference.instagram_url
|
||||
- unless @conference.google_url.blank?
|
||||
%li
|
||||
= link_to "#{ @conference.google_url }" do
|
||||
%i.fa.fa-google.fa-3x
|
||||
= @conference.google_url
|
||||
16
app/views/admin/conference_contacts/edit.html.haml
Normal file
16
app/views/admin/conference_contacts/edit.html.haml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
.row
|
||||
.col-md-12
|
||||
%ul.nav.nav-tabs{'role'=>'tablist'}
|
||||
%li.active
|
||||
%a{'href'=> '#show', 'role'=>'tab', 'data-toggle'=>'tab'}
|
||||
Show
|
||||
%li
|
||||
%a{'href'=> '#edit', 'role'=>'tab', 'data-toggle'=>'tab'}
|
||||
Edit
|
||||
.row
|
||||
.col-md-12
|
||||
.tab-content
|
||||
.tab-pane.active#show
|
||||
= render partial: 'show'
|
||||
.tab-pane#edit
|
||||
= render partial: 'form'
|
||||
7
app/views/admin/photos/_form.html.haml
Normal file
7
app/views/admin/photos/_form.html.haml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
= f.inputs do
|
||||
- if !f.object.errors
|
||||
= image_tag(f.object.picture(:thumb)) unless f.object.picture.blank?
|
||||
= f.input :picture, hint: 'This photo will appear in the gallery of the splash so please give photos of banner sizes.'
|
||||
= f.input :description, :input_html => {:rows => 2 }, hint: 'This description will appear at the bottom of each photo.'
|
||||
.actions
|
||||
= f.button 'Save Photo', :class => 'btn btn-primary'
|
||||
6
app/views/admin/photos/edit.html.haml
Normal file
6
app/views/admin/photos/edit.html.haml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%h1 Editing Photo
|
||||
|
||||
= semantic_form_for @photo, url: admin_conference_photo_path(conference_id: @conference.short_title, id: @photo.id) do |f|
|
||||
= render 'form', f: f
|
||||
|
||||
= link_to 'Back', admin_conference_photos_path
|
||||
20
app/views/admin/photos/index.html.haml
Normal file
20
app/views/admin/photos/index.html.haml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%h1 Photos
|
||||
- @photos.each_slice(3) do |slice|
|
||||
.row.row-flex.row-flex-wrap
|
||||
- slice.each do |photo|
|
||||
.col-md-4
|
||||
.thumbnail.flex-col
|
||||
%h3.text-center
|
||||
= photo.picture_file_name
|
||||
= image_tag(photo.picture(:large), class: 'img-responsive', title: photo.description)
|
||||
.caption.flex-grow
|
||||
.caption
|
||||
= link_to edit_admin_conference_photo_path(@conference.short_title, photo.id), class: 'btn btn-primary' do
|
||||
%i.fa.fa-pencil-square-o
|
||||
Edit
|
||||
= link_to admin_conference_photo_path(@conference.short_title, photo.id), method: :delete, class: 'btn btn-danger' do
|
||||
%i.fa.fa-times-circle
|
||||
Delete
|
||||
.row{'style'=>'padding-top: 10px;'}
|
||||
.col-md-12
|
||||
= link_to 'New Photo', new_admin_conference_photo_path, class: 'btn btn-primary'
|
||||
6
app/views/admin/photos/new.html.haml
Normal file
6
app/views/admin/photos/new.html.haml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%h1 New Photo
|
||||
|
||||
= semantic_form_for @photo, url: admin_conference_photos_path(conference_id: @conference.short_title) do |f|
|
||||
= render 'form', f: f
|
||||
|
||||
= link_to 'Back', admin_conference_photos_path
|
||||
|
|
@ -20,10 +20,24 @@
|
|||
%span.glyphicon.glyphicon-plus
|
||||
New Conference
|
||||
%hr
|
||||
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
|
||||
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))}"}
|
||||
= link_to(admin_conference_path(@conference.short_title)) do
|
||||
%span.glyphicon.glyphicon-dashboard
|
||||
Manage
|
||||
%span.fa.fa-tachometer
|
||||
Dashboard
|
||||
%li{:class=> "#{active_nav_li(edit_admin_conference_conference_basics_path(@conference.short_title))}"}
|
||||
= link_to(edit_admin_conference_conference_basics_path(@conference.short_title)) do
|
||||
%span.fa.fa-home
|
||||
Basics
|
||||
%ul
|
||||
%li{:class=> "#{active_nav_li(edit_admin_conference_conference_contacts_path(@conference.short_title))}"}
|
||||
= link_to(edit_admin_conference_conference_contacts_path(@conference.short_title)) do
|
||||
%span.fa.fa-envelope-o
|
||||
Contact
|
||||
%li{:class=> "#{active_nav_li(admin_conference_photos_path(@conference.short_title))}"}
|
||||
= link_to(admin_conference_photos_path(@conference.short_title)) do
|
||||
%span.fa.fa-file-image-o
|
||||
Photos
|
||||
%hr
|
||||
%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
|
||||
|
|
@ -41,10 +55,6 @@
|
|||
%span.glyphicon.glyphicon-bullhorn
|
||||
Campaigns
|
||||
%hr
|
||||
%li{:class=> "#{active_nav_li(edit_admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
|
||||
= link_to(edit_admin_conference_path(@conference.short_title)) do
|
||||
%span.glyphicon.glyphicon-cog
|
||||
Settings
|
||||
%li{:class=> "#{active_nav_li(admin_conference_targets_path(@conference.short_title))}"}
|
||||
= link_to(admin_conference_targets_path(@conference.short_title)) do
|
||||
%span.glyphicon.glyphicon-flag
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@ Osem::Application.routes.draw do
|
|||
namespace :admin do
|
||||
resources :users
|
||||
resources :people
|
||||
resources :conference do
|
||||
resources :conference, except: [:edit, :update] do
|
||||
|
||||
resource :conference_basics, only: [:edit, :update]
|
||||
resource :conference_contacts, only: [:edit, :update]
|
||||
|
||||
resource :schedule, only: [:show, :update]
|
||||
get '/stats' => 'stats#index'
|
||||
get '/venue' => 'venue#show', as: 'venue_info'
|
||||
|
|
@ -43,6 +47,8 @@ Osem::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :photos, except: [:show]
|
||||
|
||||
resources :social_events, only: [:show, :update, :index]
|
||||
|
||||
resources :supporter_levels, only: [:show, :update, :index]
|
||||
|
|
|
|||
177
spec/controllers/admin/conference_basics_controller_spec.rb
Normal file
177
spec/controllers/admin/conference_basics_controller_spec.rb
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::ConferenceBasicsController 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) }
|
||||
|
||||
let(:conference) { create(:conference) }
|
||||
let(:admin) { create(:admin) }
|
||||
let(:organizer) { create(:organizer) }
|
||||
let(:participant) { create(:participant) }
|
||||
|
||||
shared_examples 'access as administration or organizer' do
|
||||
|
||||
before(:each) do
|
||||
request.env['HTTP_REFERER'] = 'http://test.host'
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
|
||||
context 'valid attributes' do
|
||||
|
||||
it 'locates the requested conference' do
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
expect(assigns(:conference)).to eq(conference)
|
||||
end
|
||||
|
||||
it 'changes conference attributes' do
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: 'ExCon')
|
||||
|
||||
conference.reload
|
||||
expect(conference.title).to eq('Example Con')
|
||||
expect(conference.short_title).to eq('ExCon')
|
||||
end
|
||||
|
||||
it 'redirects to the updated conference' do
|
||||
session[:return_to] = request.env['HTTP_REFERER'] +
|
||||
edit_admin_conference_conference_contacts_path(conference.short_title)
|
||||
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
conference.reload
|
||||
expect(response).to redirect_to edit_admin_conference_conference_contacts_path(
|
||||
conference.short_title)
|
||||
end
|
||||
|
||||
it 'redirects to conference show if no :return_to is specified' do
|
||||
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
conference.reload
|
||||
expect(response).to redirect_to admin_conference_path(
|
||||
conference.short_title)
|
||||
end
|
||||
|
||||
it 'sends email notification on conference date update' do
|
||||
mailer = double
|
||||
allow(mailer).to receive(:deliver)
|
||||
conference.email_settings = create(:email_settings)
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days)
|
||||
conference.reload
|
||||
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
||||
end
|
||||
|
||||
it 'sends email notification on conference registration date update' do
|
||||
mailer = double
|
||||
allow(mailer).to receive(:deliver)
|
||||
conference.email_settings = create(:email_settings)
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, registration_start_date: Date.today + 2.days, registration_end_date: Date.today + 4.days)
|
||||
conference.reload
|
||||
allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
|
||||
end
|
||||
end
|
||||
|
||||
context 'invalid attributes' do
|
||||
it 'does not change conference attributes' do
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
|
||||
conference.reload
|
||||
expect(flash[:alert]).
|
||||
to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(conference.title).to eq('The dog and pony show')
|
||||
expect(conference.short_title).to eq("#{conference.short_title}")
|
||||
end
|
||||
|
||||
it 're-renders the #show template' do
|
||||
request.env['HTTP_REFERER'] = request.env['HTTP_REFERER'] +
|
||||
edit_admin_conference_conference_contacts_path(conference.short_title)
|
||||
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
|
||||
expect(flash[:alert]).
|
||||
to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(response).to redirect_to edit_admin_conference_conference_contacts_path(
|
||||
conference.short_title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested conference to conference' do
|
||||
get :edit, conference_id: conference.short_title
|
||||
expect(assigns(:conference)).to eq conference
|
||||
end
|
||||
|
||||
it 'renders the show template' do
|
||||
get :edit, conference_id: conference.short_title
|
||||
expect(response).to render_template :edit
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'administrator access' do
|
||||
|
||||
before do
|
||||
sign_in(admin)
|
||||
end
|
||||
|
||||
it_behaves_like 'access as administration or organizer'
|
||||
|
||||
end
|
||||
|
||||
describe 'organizer access' do
|
||||
|
||||
before(:each) do
|
||||
sign_in(organizer)
|
||||
end
|
||||
|
||||
it_behaves_like 'access as administration or organizer'
|
||||
|
||||
end
|
||||
|
||||
shared_examples 'access as participant or guest' do |success_path|
|
||||
describe 'GET #edit' do
|
||||
it 'requires admin privileges' do
|
||||
get :edit, conference_id: conference.short_title
|
||||
expect(response).to redirect_to(send(success_path))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
it 'requires admin privileges' do
|
||||
patch :update, conference_id: conference.short_title,
|
||||
conference: attributes_for(:conference,
|
||||
short_title: 'ExCon')
|
||||
expect(response).to redirect_to(send(success_path))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'participant access' do
|
||||
before(:each) do
|
||||
sign_in(participant)
|
||||
end
|
||||
|
||||
it_behaves_like 'access as participant or guest', :root_path
|
||||
|
||||
end
|
||||
|
||||
describe 'guest access' do
|
||||
|
||||
it_behaves_like 'access as participant or guest', :new_user_session_path
|
||||
|
||||
end
|
||||
end
|
||||
177
spec/controllers/admin/conference_contacts_controller_spec.rb
Normal file
177
spec/controllers/admin/conference_contacts_controller_spec.rb
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::ConferenceContactsController 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) }
|
||||
|
||||
let(:conference) { create(:conference) }
|
||||
let(:admin) { create(:admin) }
|
||||
let(:organizer) { create(:organizer) }
|
||||
let(:participant) { create(:participant) }
|
||||
|
||||
shared_examples 'access as administration or organizer' do
|
||||
|
||||
before(:each) do
|
||||
request.env['HTTP_REFERER'] = 'http://test.host'
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
|
||||
context 'valid attributes' do
|
||||
|
||||
it 'locates the requested conference' do
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
expect(assigns(:conference)).to eq(conference)
|
||||
end
|
||||
|
||||
it 'changes conference attributes' do
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: 'ExCon')
|
||||
|
||||
conference.reload
|
||||
expect(conference.title).to eq('Example Con')
|
||||
expect(conference.short_title).to eq('ExCon')
|
||||
end
|
||||
|
||||
it 'redirects to the updated conference' do
|
||||
session[:return_to] = request.env['HTTP_REFERER'] +
|
||||
edit_admin_conference_conference_basics_path(conference.short_title)
|
||||
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
conference.reload
|
||||
expect(response).to redirect_to edit_admin_conference_conference_basics_path(
|
||||
conference.short_title)
|
||||
end
|
||||
|
||||
it 'redirects to conference show if no :return_to is specified' do
|
||||
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
conference.reload
|
||||
expect(response).to redirect_to admin_conference_path(
|
||||
conference.short_title)
|
||||
end
|
||||
|
||||
it 'sends email notification on conference date update' do
|
||||
mailer = double
|
||||
allow(mailer).to receive(:deliver)
|
||||
conference.email_settings = create(:email_settings)
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days)
|
||||
conference.reload
|
||||
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
||||
end
|
||||
|
||||
it 'sends email notification on conference registration date update' do
|
||||
mailer = double
|
||||
allow(mailer).to receive(:deliver)
|
||||
conference.email_settings = create(:email_settings)
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, registration_start_date: Date.today + 2.days, registration_end_date: Date.today + 4.days)
|
||||
conference.reload
|
||||
allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
|
||||
end
|
||||
end
|
||||
|
||||
context 'invalid attributes' do
|
||||
it 'does not change conference attributes' do
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
|
||||
conference.reload
|
||||
expect(flash[:alert]).
|
||||
to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(conference.title).to eq('The dog and pony show')
|
||||
expect(conference.short_title).to eq("#{conference.short_title}")
|
||||
end
|
||||
|
||||
it 're-renders the #show template' do
|
||||
request.env['HTTP_REFERER'] = request.env['HTTP_REFERER'] +
|
||||
edit_admin_conference_conference_basics_path(conference.short_title)
|
||||
|
||||
patch :update, conference_id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
|
||||
expect(flash[:alert]).
|
||||
to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(response).to redirect_to edit_admin_conference_conference_basics_path(
|
||||
conference.short_title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested conference to conference' do
|
||||
get :edit, conference_id: conference.short_title
|
||||
expect(assigns(:conference)).to eq conference
|
||||
end
|
||||
|
||||
it 'renders the show template' do
|
||||
get :edit, conference_id: conference.short_title
|
||||
expect(response).to render_template :edit
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'administrator access' do
|
||||
|
||||
before do
|
||||
sign_in(admin)
|
||||
end
|
||||
|
||||
it_behaves_like 'access as administration or organizer'
|
||||
|
||||
end
|
||||
|
||||
describe 'organizer access' do
|
||||
|
||||
before(:each) do
|
||||
sign_in(organizer)
|
||||
end
|
||||
|
||||
it_behaves_like 'access as administration or organizer'
|
||||
|
||||
end
|
||||
|
||||
shared_examples 'access as participant or guest' do |success_path|
|
||||
describe 'GET #edit' do
|
||||
it 'requires admin privileges' do
|
||||
get :edit, conference_id: conference.short_title
|
||||
expect(response).to redirect_to(send(success_path))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
it 'requires admin privileges' do
|
||||
patch :update, conference_id: conference.short_title,
|
||||
conference: attributes_for(:conference,
|
||||
short_title: 'ExCon')
|
||||
expect(response).to redirect_to(send(success_path))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'participant access' do
|
||||
before(:each) do
|
||||
sign_in(participant)
|
||||
end
|
||||
|
||||
it_behaves_like 'access as participant or guest', :root_path
|
||||
|
||||
end
|
||||
|
||||
describe 'guest access' do
|
||||
|
||||
it_behaves_like 'access as participant or guest', :new_user_session_path
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -14,81 +14,6 @@ describe Admin::ConferenceController do
|
|||
|
||||
shared_examples 'access as administration or organizer' do
|
||||
|
||||
describe 'PATCH #update' do
|
||||
|
||||
context 'valid attributes' do
|
||||
|
||||
it 'locates the requested conference' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
expect(assigns(:conference)).to eq(conference)
|
||||
end
|
||||
|
||||
it 'changes conference attributes' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: 'ExCon')
|
||||
|
||||
conference.reload
|
||||
expect(conference.title).to eq('Example Con')
|
||||
expect(conference.short_title).to eq('ExCon')
|
||||
end
|
||||
|
||||
it 'redirects to the updated conference' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
conference.reload
|
||||
expect(response).to redirect_to edit_admin_conference_path(
|
||||
conference.short_title)
|
||||
end
|
||||
|
||||
it 'sends email notification on conference date update' do
|
||||
mailer = double
|
||||
allow(mailer).to receive(:deliver)
|
||||
conference.email_settings = create(:email_settings)
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days)
|
||||
conference.reload
|
||||
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
||||
end
|
||||
|
||||
it 'sends email notification on conference registration date update' do
|
||||
mailer = double
|
||||
allow(mailer).to receive(:deliver)
|
||||
conference.email_settings = create(:email_settings)
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, registration_start_date: Date.today + 2.days, registration_end_date: Date.today + 4.days)
|
||||
conference.reload
|
||||
allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
|
||||
end
|
||||
end
|
||||
|
||||
context 'invalid attributes' do
|
||||
it 'does not change conference attributes' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
|
||||
conference.reload
|
||||
expect(flash[:alert]).
|
||||
to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(conference.title).to eq('The dog and pony show')
|
||||
expect(conference.short_title).to eq("#{conference.short_title}")
|
||||
end
|
||||
|
||||
it 're-renders the #show template' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
|
||||
expect(flash[:alert]).
|
||||
to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(response).to redirect_to edit_admin_conference_path(
|
||||
conference.short_title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid attributes' do
|
||||
it 'saves the conference to the database' do
|
||||
|
|
@ -142,18 +67,6 @@ describe Admin::ConferenceController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested conference to conference' do
|
||||
get :show, id: conference.short_title
|
||||
expect(assigns(:conference)).to eq conference
|
||||
end
|
||||
|
||||
it 'renders the show template' do
|
||||
get :show, id: conference.short_title
|
||||
expect(response).to render_template :show
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested conference to conference' do
|
||||
get :show, id: conference.short_title
|
||||
|
|
@ -263,14 +176,6 @@ describe Admin::ConferenceController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
it 'requires admin privileges' do
|
||||
patch :update, id: conference.short_title,
|
||||
conference: attributes_for(:conference,
|
||||
short_title: 'ExCon')
|
||||
expect(response).to redirect_to(send(success_path))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'participant access' do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
include ActionDispatch::TestProcess
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :photo do
|
||||
picture { fixture_file_upload(Rails.root.join('spec', 'fixtures', 'suse.jpg'), 'image/jpg') }
|
||||
picture_file_name 'rails.png'
|
||||
picture_content_type 'image/png'
|
||||
picture_file_size '1024'
|
||||
|
|
|
|||
|
|
@ -19,13 +19,12 @@ feature Conference do
|
|||
|
||||
select('(GMT+01:00) Berlin', from: 'conference[timezone]')
|
||||
|
||||
today = Date.today - 1
|
||||
page.
|
||||
execute_script("$('#conference-start-datepicker').val('" +
|
||||
"#{today.strftime('%d/%m/%Y')}')")
|
||||
"#{1.weeks.from_now.strftime('%d/%m/%Y')}')")
|
||||
page.
|
||||
execute_script("$('#conference-end-datepicker').val('" +
|
||||
"#{(today + 7).strftime('%d/%m/%Y')}')")
|
||||
"#{2.weeks.from_now.strftime('%d/%m/%Y')}')")
|
||||
|
||||
click_button 'Create Conference'
|
||||
|
||||
|
|
@ -34,15 +33,26 @@ feature Conference do
|
|||
expect(Conference.count).to eq(expected_count)
|
||||
end
|
||||
|
||||
scenario 'update conference', feature: true, js: true do
|
||||
scenario 'update basic conference settings', feature: true, js: true do
|
||||
conference = create(:conference)
|
||||
expected_count = Conference.count
|
||||
sign_in create(user)
|
||||
|
||||
visit edit_admin_conference_path(conference.short_title)
|
||||
visit edit_admin_conference_conference_basics_path(conference.short_title)
|
||||
click_link 'Edit'
|
||||
fill_in 'conference_title', with: 'New Con'
|
||||
fill_in 'conference_short_title', with: 'NewCon'
|
||||
fill_in 'conference_social_tag', with: 'NewCon'
|
||||
|
||||
fill_in 'conference_description', with: 'Lorem ipsum dolorem...'
|
||||
select('YouTube', from: 'conference_media_type')
|
||||
fill_in 'conference_media_id', with: '123456'
|
||||
|
||||
page.
|
||||
execute_script("$('#conference-start-datepicker').val('" +
|
||||
"#{2.weeks.from_now.strftime('%d/%m/%Y')}')")
|
||||
page.
|
||||
execute_script("$('#conference-end-datepicker').val('" +
|
||||
"#{3.weeks.from_now.strftime('%d/%m/%Y')}')")
|
||||
|
||||
click_button 'Update Conference'
|
||||
expect(flash).
|
||||
|
|
@ -50,8 +60,43 @@ feature Conference do
|
|||
|
||||
conference.reload
|
||||
expect(conference.title).to eq('New Con')
|
||||
expect(conference.description).to eq('Lorem ipsum dolorem...')
|
||||
expect(conference.media_type).to eq('YouTube')
|
||||
expect(conference.media_id).to eq('123456')
|
||||
expect(conference.start_date).to eq(2.weeks.from_now.to_date)
|
||||
expect(conference.end_date).to eq(3.weeks.from_now.to_date)
|
||||
expect(conference.short_title).to eq('NewCon')
|
||||
expect(conference.social_tag).to eq('NewCon')
|
||||
|
||||
expect(Conference.count).to eq(expected_count)
|
||||
end
|
||||
|
||||
scenario 'update contact conference settings', feature: true, js: true do
|
||||
conference = create(:conference)
|
||||
expected_count = Conference.count
|
||||
sign_in create(user)
|
||||
|
||||
visit edit_admin_conference_conference_contacts_path(conference.short_title)
|
||||
click_link 'Edit'
|
||||
|
||||
fill_in 'conference_contact_email', with: 'example@example.de'
|
||||
fill_in 'conference_social_tag', with: '#social-tag'
|
||||
fill_in 'conference_facebook_url', with: 'http://www.facebook.com'
|
||||
fill_in 'conference_google_url', with: 'http://www.google.com'
|
||||
fill_in 'conference_twitter_url', with: 'http://www.twitter.com'
|
||||
fill_in 'conference_instagram_url', with: 'http://www.instagram.com'
|
||||
|
||||
click_button 'Update Conference'
|
||||
expect(flash).
|
||||
to eq('Conference was successfully updated.')
|
||||
|
||||
conference.reload
|
||||
expect(conference.contact_email).to eq('example@example.de')
|
||||
expect(conference.social_tag).to eq('#social-tag')
|
||||
expect(conference.facebook_url).to eq('http://www.facebook.com')
|
||||
expect(conference.google_url).to eq('http://www.google.com')
|
||||
expect(conference.twitter_url).to eq('http://www.twitter.com')
|
||||
expect(conference.instagram_url).to eq('http://www.instagram.com')
|
||||
|
||||
expect(Conference.count).to eq(expected_count)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
76
spec/features/photo_spec.rb
Normal file
76
spec/features/photo_spec.rb
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature Photo 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 'add and update photo' do |user|
|
||||
scenario 'adds a new photo', feature: true, js: true do
|
||||
expected_count = Photo.count + 1
|
||||
conference = create(:conference)
|
||||
sign_in create(user)
|
||||
|
||||
visit new_admin_conference_photo_path(conference.short_title)
|
||||
|
||||
file_path = Rails.root + 'spec/fixtures/suse.jpg'
|
||||
attach_file('photo_picture', file_path)
|
||||
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
|
||||
|
||||
click_button 'Save Photo'
|
||||
|
||||
expect(flash).
|
||||
to eq('Photo was successfully created.')
|
||||
expect(Photo.count).to eq(expected_count)
|
||||
end
|
||||
|
||||
scenario 'updates a photo', feature: true, js: true do
|
||||
expected_count = Photo.count + 1
|
||||
conference = create(:conference)
|
||||
photo = create(:photo)
|
||||
sign_in create(user)
|
||||
|
||||
visit edit_admin_conference_photo_path(conference.short_title, photo.id)
|
||||
|
||||
file_path = Rails.root + 'spec/fixtures/suse_pinguin.png'
|
||||
attach_file('photo_picture', file_path)
|
||||
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
|
||||
|
||||
click_button 'Save Photo'
|
||||
|
||||
expect(flash).
|
||||
to eq('Photo was successfully updated.')
|
||||
expect(Photo.count).to eq(expected_count)
|
||||
end
|
||||
|
||||
scenario 'adds a text file', feature: true, js: true do
|
||||
expected_count = Photo.count
|
||||
conference = create(:conference)
|
||||
sign_in create(user)
|
||||
|
||||
visit new_admin_conference_photo_path(conference.short_title)
|
||||
|
||||
file_path = Rails.root + 'spec/fixtures/test.txt'
|
||||
attach_file('photo_picture', file_path)
|
||||
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
|
||||
|
||||
click_button 'Save Photo'
|
||||
|
||||
expect(flash).
|
||||
to eq("A error prohibited this Photo from being saved: Picture has an extension that does not match its contents. "\
|
||||
"Picture is invalid. Picture content type is invalid.")
|
||||
expect(Photo.count).to eq(expected_count)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin' do
|
||||
it_behaves_like 'add and update photo', :admin
|
||||
end
|
||||
|
||||
describe 'organizer' do
|
||||
it_behaves_like 'add and update photo', :organizer
|
||||
end
|
||||
|
||||
end
|
||||
BIN
spec/fixtures/suse.jpg
vendored
Normal file
BIN
spec/fixtures/suse.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 189 KiB |
BIN
spec/fixtures/suse_pinguin.png
vendored
Normal file
BIN
spec/fixtures/suse_pinguin.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
0
spec/fixtures/test.txt
vendored
Normal file
0
spec/fixtures/test.txt
vendored
Normal file
|
|
@ -1,12 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/conference/edit' do
|
||||
|
||||
it 'renders conference details which are editable' do
|
||||
@conference = create(:conference, title: 'OpenSUSE')
|
||||
assign :conference, @conference
|
||||
render template: 'admin/conference/edit.html.haml'
|
||||
expect(rendered).to include('OpenSUSE')
|
||||
expect(rendered).to include("#{@conference.contact_email}")
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue