Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/openSUSE/osem into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushMalik committed Feb 13, 2018
2 parents 0cb5d2c + 7326bd1 commit 274b29c
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 33 deletions.
6 changes: 6 additions & 0 deletions app/assets/stylesheets/osem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,9 @@ p.comment-body {
float: right;
}
}

/* omniauth btn grp */
#openid-btn-grp{
display: flex;
justify-content: center;
}
6 changes: 6 additions & 0 deletions app/controllers/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def show
authorize! :show, @conference # TODO: reduce the 10 queries performed here

splashpage = @conference.splashpage

unless splashpage.present?
redirect_to admin_conference_splashpage_path(@conference.short_title) && return
end

if splashpage.include_cfp
cfps = @conference.program.cfps
@call_for_events = cfps.find { |call| call.cfp_type == 'events' }
Expand Down Expand Up @@ -50,6 +55,7 @@ def show
@sponsorship_levels = @conference.sponsorship_levels.eager_load(
:sponsors
).order('sponsorship_levels.position ASC', 'sponsors.name')
@sponsors = @conference.sponsors
end
end

Expand Down
8 changes: 7 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ def signed_in(user)

can [:new, :create], Registration do |registration|
conference = registration.conference
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
if conference.user_registered? user
false
elsif conference.program.speakers.confirmed.include?(user) && conference.registration_period
true
else
conference.registration_open? && !conference.registration_limit_exceeded?
end
end

can :index, Organization
Expand Down
6 changes: 5 additions & 1 deletion app/models/ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def self.total_price_user(conference, user, paid: false)

def tickets_turnover_total(id)
tickets = TicketPurchase.where(ticket_id: id).paid
tickets.inject(0){ |sum, ticket| sum + (ticket.amount_paid * ticket.quantity) }
if tickets.blank?
Money.new(0, Ticket.find(id).price_currency)
else
tickets.inject(Money.new(0, tickets.first.price_currency)){ |sum, ticket| sum + (ticket.amount_paid * ticket.quantity) }
end
end

def tickets_sold
Expand Down
5 changes: 3 additions & 2 deletions app/views/admin/organizations/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
.col-md-12
.page-header
%h1 Organizations
.btn-group.pull-right
= link_to 'Create Organization', new_admin_organization_path, class: 'btn btn-success pull-right'
- if can? :manage, :all
.btn-group.pull-right
= link_to 'Create Organization', new_admin_organization_path, class: 'btn btn-success pull-right'
%p.text-muted
Manage organizations in OSEM
.row
Expand Down
3 changes: 3 additions & 0 deletions app/views/conferences/_social_media.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- unless contact.googleplus.blank?
= link_to "#{ contact.googleplus }" do
%i.fa.fa-google-plus-square.fa-4x
- unless contact.mastodon.blank?
= link_to "#{ contact.mastodon }" do
%i.fa.icon-mastodon.fa-4x
- unless contact.email.blank?
= mail_to "#{ contact.email }" do
%i.fa.fa-envelope-o.fa-4x
21 changes: 0 additions & 21 deletions app/views/conferences/_social_media.html.haml

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/conferences/_sponsors.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%li
%a.smoothscroll{ href: '#sponsors' } Sponsors

- cache [conference, sponsorship_levels, '#splash#sponsors'] do
- cache [conference, sponsors, sponsorship_levels, '#splash#sponsors'] do
%section#sponsors
.container
- sponsorship_levels.each do |sponsorship_level|
Expand Down Expand Up @@ -31,6 +31,6 @@
= link_to(sponsorship_mailto(conference)) do
Contact us!

- sponsorship_levels.collect(&:sponsors).flatten.each do |sponsor|
- sponsors.each do |sponsor|
- content_for :modals do
= render 'modal_description', object: sponsor
3 changes: 2 additions & 1 deletion app/views/conferences/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
-# sponsorship
- if @conference.splashpage.include_sponsors
= render 'sponsors', conference: @conference,
sponsorship_levels: @sponsorship_levels
sponsorship_levels: @sponsorship_levels,
sponsors: @sponsors

-# footer
- if @conference.splashpage.include_social_media
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/shared/_openid_links.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.text-center
.btn-group.btn-group-lg
.btn-group.btn-group-lg#openid-btn-grp
- omniauth_configured.each do |provider|
= link_to "user_#{provider}_omniauth_authorize".to_sym, class: "btn btn-success btn-lg",
id: "omniauth-#{provider}",
Expand Down
1 change: 1 addition & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
use Rack::Deflater
run Osem::Application
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class Application < Rails::Application
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

# Set cache headers
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' }

config.active_job.queue_adapter = :delayed_job
end
end
4 changes: 4 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
# Generate digests for assets URLs
config.assets.digest = true

config.assets.css_compressor = :sass
config.assets.js_compressor = :uglifier
config.assets.gzip = true

# Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH

Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@
t.integer "user_id"
t.integer "payment_id"
t.integer "week"
t.float "amount_paid"
t.float "amount_paid", default: 0.0
end

create_table "ticket_scannings", force: :cascade do |t|
Expand Down
126 changes: 123 additions & 3 deletions spec/models/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,131 @@
let(:other_self_organized_track) { create(:track, :self_organized) }

it{ should be_able_to(:manage, user) }

it{ should be_able_to(:manage, registration_public) }
it{ should be_able_to(:manage, registration_not_public) }
it{ should_not be_able_to(:new, Registration.new(conference_id: conference_with_closed_registration.id))}
it{ should_not be_able_to(:create, Registration.new(conference_id: conference_with_closed_registration.id))}

# Test for user can register or not
context 'when user is not a speaker with event confirmed' do
let(:conference) { create(:conference) }

context 'when the registration is closed' do
before :each do
create(:registration_period, conference: conference, start_date: Date.current - 6.days, end_date: Date.current - 6.days)
end

it{ should_not be_able_to(:new, Registration.new(conference: conference)) }
it{ should_not be_able_to(:create, Registration.new(conference: conference)) }
end

context 'when the registration period is not set' do
it{ should_not be_able_to(:new, Registration.new(conference: conference)) }
it{ should_not be_able_to(:create, Registration.new(conference: conference)) }
end

context 'when user has already registered' do
before :each do
create(:registration, conference: conference, user: user)
end

it{ should_not be_able_to(:new, Registration.new(conference: conference)) }
it{ should_not be_able_to(:create, Registration.new(conference: conference)) }
end

context 'when registrations are open' do
before :each do
create(:registration_period, conference: conference)
end

it{ should be_able_to(:new, Registration.new(conference: conference)) }
it{ should be_able_to(:create, Registration.new(conference: conference)) }

context 'when user has not registered with no registration_limit_exceeded' do
before :each do
conference.registration_limit = 1
end

it{ should be_able_to(:new, Registration.new(conference: conference)) }
it{ should be_able_to(:create, Registration.new(conference: conference)) }
end

context 'when user has not registered with registration_limit_exceeded' do
before :each do
conference.registration_limit = 1
create(:registration, conference: conference, user: user2)
end

it{ should_not be_able_to(:new, Registration.new(conference: conference)) }
it{ should_not be_able_to(:create, Registration.new(conference: conference)) }
end
end
end

context 'when user is a speaker with event confirmed' do
let(:conference_with_speaker_confirmed) { create(:conference) }
let(:event_with_speaker_confirmed) { create(:event, state: 'confirmed', program: conference_with_speaker_confirmed.program) }

before :each do
event_with_speaker_confirmed.speakers << user
end

context 'when registration period is not set' do
it{ should_not be_able_to(:new, Registration.new(conference: conference_with_speaker_confirmed)) }
it{ should_not be_able_to(:create, Registration.new(conference: conference_with_speaker_confirmed)) }
end

context 'when speaker has already registered' do
before :each do
create(:registration, conference: conference_with_speaker_confirmed, user: user)
end

it{ should_not be_able_to(:new, Registration.new(conference: conference_with_speaker_confirmed)) }
it{ should_not be_able_to(:create, Registration.new(conference: conference_with_speaker_confirmed)) }
end

context 'when registration period is set' do
before :each do
create(:registration_period, conference: conference_with_speaker_confirmed)
end

context 'when registrations are open' do
context 'when speaker has not registered' do
it{ should be_able_to(:new, Registration.new(conference: conference_with_speaker_confirmed)) }
it{ should be_able_to(:create, Registration.new(conference: conference_with_speaker_confirmed)) }
end

context 'when registration_limit_exceeded' do
before :each do
conference_with_speaker_confirmed.registration_limit = 1
create(:registration, conference: conference_with_speaker_confirmed, user: user2)
end

it{ should be_able_to(:new, Registration.new(conference: conference_with_speaker_confirmed)) }
it{ should be_able_to(:create, Registration.new(conference: conference_with_speaker_confirmed)) }
end
end

context 'when registrations are closed' do
before :each do
create(:registration_period, conference: conference_with_speaker_confirmed, start_date: Date.current - 6.days, end_date: Date.current - 6.days)
end

context 'when speaker has not registered' do
it{ should be_able_to(:new, Registration.new(conference: conference_with_speaker_confirmed)) }
it{ should be_able_to(:create, Registration.new(conference: conference_with_speaker_confirmed)) }
end

context 'with registration_limit_exceeded' do
before :each do
conference_with_speaker_confirmed.registration_limit = 1
create(:registration, conference: conference_with_speaker_confirmed, user: user2)
end

it{ should be_able_to(:new, Registration.new(conference: conference_with_speaker_confirmed)) }
it{ should be_able_to(:create, Registration.new(conference: conference_with_speaker_confirmed)) }
end
end
end
end

it{ should be_able_to(:index, Ticket) }
it{ should be_able_to(:manage, TicketPurchase.new(user_id: user.id)) }
Expand Down

0 comments on commit 274b29c

Please sign in to comment.