Skip to content

Commit

Permalink
Merge 890b01a into c86f542
Browse files Browse the repository at this point in the history
  • Loading branch information
jhackett1 committed Oct 31, 2022
2 parents c86f542 + 890b01a commit 4cafc70
Show file tree
Hide file tree
Showing 28 changed files with 151 additions and 75 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/partials/_layout.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "partials/colors";

#top {
margin-top: 82px;
margin-top: 96px;
}

.main-footer {
Expand Down
11 changes: 5 additions & 6 deletions app/controllers/admin/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def show
@address = AddressPresenter.new(@event.venue.address) if @event.venue.present?
@attending_students = InvitationPresenter.decorate_collection(@original_event.attending_students)
@attending_coaches = InvitationPresenter.decorate_collection(@original_event.attending_coaches)
@host_address = AddressPresenter.new(@event.venue.address)

return render text: @event.attendees_csv if request.format.csv?
end
Expand Down Expand Up @@ -74,11 +73,11 @@ def set_event

def event_params
params.require(:event).permit(
:name, :slug, :date_and_time, :begins_at, :ends_at, :description, :info, :schedule, :venue_id, :external_url,
:coach_spaces, :student_spaces, :email, :announce_only, :tito_url, :invitable, :student_questionnaire,
:confirmation_required, :surveys_required, :audience,
:coach_questionnaire, :show_faq, :display_coaches, :display_students,
bronze_sponsor_ids: [], silver_sponsor_ids: [], gold_sponsor_ids: [], sponsor_ids: [], chapter_ids: []
:virtual, :name, :slug, :date_and_time, :begins_at, :ends_at, :description, :info, :schedule, :venue_id,
:external_url, :coach_spaces, :student_spaces, :email, :announce_only, :tito_url, :invitable,
:student_questionnaire, :confirmation_required, :surveys_required, :audience, :coach_questionnaire,
:show_faq, :display_coaches, :display_students, bronze_sponsor_ids: [], silver_sponsor_ids: [],
gold_sponsor_ids: [], sponsor_ids: [], chapter_ids: []
)
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

include Pundit

rescue_from Exception do |ex|
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def show
event = Event.find_by(slug: params[:id])

@event = EventPresenter.new(event)
@host_address = AddressPresenter.new(@event.venue.address)
@host_address = AddressPresenter.new(@event.venue.address) if @event.venue.present?

return unless logged_in?

invitation = Invitation.find_by(member: current_user, event: event, attending: true)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index

def show
@event = EventPresenter.new(@invitation.event)
@host_address = AddressPresenter.new(@event.venue.address)
@host_address = AddressPresenter.new(@event.venue.address) if @event.venue.present?
@member = @invitation.member
end

Expand Down
23 changes: 23 additions & 0 deletions app/helpers/event_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module EventHelper
def venue_or_remote_must_be_present
if !virtual && !venue
errors.add(:venue, 'must be set, or event must be marked as virtual')
end
end

def sponsors_uniqueness
errors.add(:sponsors, :duplicated_sponsor) unless (sponsors.map(&:id) & duplicated_sponsors).empty?
end

def bronze_sponsors_uniqueness
errors.add(:bronze_sponsors, :duplicated_sponsor) unless (bronze_sponsors.map(&:id) & duplicated_sponsors).empty?
end

def silver_sponsors_uniqueness
errors.add(:silver_sponsors, :duplicated_sponsor) unless (silver_sponsors.map(&:id) & duplicated_sponsors).empty?
end

def gold_sponsors_uniqueness
errors.add(:gold_sponsors, :duplicated_sponsor) unless (gold_sponsors.map(&:id) & duplicated_sponsors).empty?
end
end
6 changes: 3 additions & 3 deletions app/mailers/event_invitation_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def invite_student(event, member, invitation)
@event = event
@member = member
@invitation = invitation
@host_address = AddressPresenter.new(@event.venue.address)
@host_address = AddressPresenter.new(@event.venue.address) if @event.venue.present?

subject = "Invitation: #{@event.name}"

Expand All @@ -19,7 +19,7 @@ def invite_coach(event, member, invitation)
@event = event
@member = member
@invitation = invitation
@host_address = AddressPresenter.new(@event.venue.address)
@host_address = AddressPresenter.new(@event.venue.address) if @event.venue.present?
@everyone_is_invited = !event.audience

mail(mail_args(member, @everyone_is_invited ? "Invitation: #{@event.name}" : "Coach Invitation: #{@event.name}"),
Expand All @@ -30,7 +30,7 @@ def attending(event, member, invitation)
@event = EventPresenter.new(event)
@member = member
@invitation = invitation
@host_address = AddressPresenter.new(@event.venue.address)
@host_address = AddressPresenter.new(@event.venue.address) if @event.venue.present?

require 'services/event_calendar'
attachments['codebar.ics'] = { mime_type: 'text/calendar',
Expand Down
18 changes: 2 additions & 16 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Event < ActiveRecord::Base
include Listable
include Invitable
include DateTimeConcerns
include EventHelper

attr_accessor :begins_at

Expand All @@ -25,6 +26,7 @@ class Event < ActiveRecord::Base
validate :bronze_sponsors_uniqueness
validate :silver_sponsors_uniqueness
validate :gold_sponsors_uniqueness
validate :venue_or_remote_must_be_present

before_save do
begins_at = Time.parse(self.begins_at)
Expand Down Expand Up @@ -110,20 +112,4 @@ def fetch_duplicated_sponsors
ids = sponsorships.reject(&:marked_for_destruction?).map(&:sponsor_id)
ids.select { |e| ids.count(e) > 1 }
end

def sponsors_uniqueness
errors.add(:sponsors, :duplicated_sponsor) unless (sponsors.map(&:id) & duplicated_sponsors).empty?
end

def bronze_sponsors_uniqueness
errors.add(:bronze_sponsors, :duplicated_sponsor) unless (bronze_sponsors.map(&:id) & duplicated_sponsors).empty?
end

def silver_sponsors_uniqueness
errors.add(:silver_sponsors, :duplicated_sponsor) unless (silver_sponsors.map(&:id) & duplicated_sponsors).empty?
end

def gold_sponsors_uniqueness
errors.add(:gold_sponsors, :duplicated_sponsor) unless (gold_sponsors.map(&:id) & duplicated_sponsors).empty?
end
end
4 changes: 3 additions & 1 deletion app/views/admin/events/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
.col-12
= f.input :schedule, input_html: { rows: 3 }
.col-12
= f.association :venue, input_html: { data: { placeholder: 'Select sponsors' }}, required: true
= f.association :venue, input_html: { data: { placeholder: 'Select sponsors' }}
.col-12
= f.input :virtual, label: t('events.virtual')

.col-12
%h3 Sponsors
Expand Down
4 changes: 3 additions & 1 deletion app/views/admin/events/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
.col-12
= f.input :schedule, input_html: { rows: 3 }
.col-12
= f.association :venue, input_html: { data: { placeholder: 'Select sponsors' }}, required: true
= f.association :venue, input_html: { data: { placeholder: 'Select sponsors' }}
.col-12
= f.input :virtual, label: t('events.virtual')
.col-12
%h3 Sponsors
%p
Expand Down
58 changes: 31 additions & 27 deletions app/views/admin/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,46 @@
= link_to edit_admin_event_path(@event), class: 'btn btn-primary py-3 rounded-0' do
%i.fas.fa-pencil-alt
%label.text-white Edit

- if !@event.date_and_time.future?
= link_to '#', class: 'btn btn-primary py-3 disabled', title: t('messages.already_taken_place') do
%i.fas.fa-paper-plane
%label.text-white Invite
- elsif @event.venue and @event.invitable?
- elsif @event.invitable?
= link_to admin_event_invite_path(@event), method: :post, class: 'btn btn-primary py-3' do
%i.fas.fa-paper-plane
%label.text-white Invite
- else
= link_to '#', class: 'btn btn-primary py-3 disabled', title: 'The event is not invitable.' do
%i.fas.fa-paper-plane
%label.text-white Invite

= link_to admin_event_attendees_emails_path(@event, format: 'text'), class: 'btn btn-primary py-3' do
%i.fas.fa-at
%label.text-white Emails

= link_to admin_event_path(@event, format: 'csv'), class: 'btn btn-primary py-3 rounded-0', title: 'CSV for labels' do
%i.fas.fa-users
%label.text-white Labels

.container.py-4.py-lg-5
.row
.col
.row.mb-4
.col-12
%h1= @event.to_s
%h2
%small #{humanize_date(@event.date_and_time, @event.ends_at, with_time: true)}
%span.badge.bg-primary #{@event.student_spaces} student spots, #{@event.coach_spaces} coach spots

.row
- if @event.venue.present?
.col-12.col-md-6
%span.badge.bg-primary #{@event.student_spaces} student spots, #{@event.coach_spaces} coach spots
%h4.mt-3 Chapters
%ul.list-inline.ml-0
- @event.chapters.each do |chapter|
%li.list-inline-item= link_to chapter.name, [:admin, chapter]

.row
- if @event.venue.present?
.col-6.col-md-3#host
%h4 Venue
%strong= @event.venue.name
%br
.col-12.col-md-6.col-lg-3.mb-4#host
%h4 Venue
- if @event.venue.present?
%p
%strong= @event.venue.name
%small
= @address.to_html
.col-6.col-md-3#sponsors
- elsif @event.virtual?
%p= "#{t('events.virtual')}."
.col-12.col-md-6.col-lg-3.mb-4#sponsors
%h4 Sponsors
- if @event.sponsors?
%h4 Sponsors
- if @event.sponsors?(:standard)
%h5 Standard
%ul.list-unstyled.ml-0
Expand Down Expand Up @@ -79,13 +70,26 @@
%li
%span
= link_to sponsor.name, [:admin, sponsor]
.col-12.col-md-6
- else
%p This event has no sponsors.
.col-12.col-md-6.col-lg-3.mb-4
%h4 Team
- @event.organisers.each do |organiser|
%span{'data-bs-toggle': 'tooltip', 'data-bs-placement': 'botton', title: organiser.full_name}
= image_tag(organiser.avatar(40), alt: organiser.full_name)
- if @event.organisers.any?
- @event.organisers.each do |organiser|
%span{'data-bs-toggle': 'tooltip', 'data-bs-placement': 'bottom', title: organiser.full_name}
= image_tag(organiser.avatar(40), alt: organiser.full_name)
- else
%p This event has no organisers.
.col-12.col-md-6.col-lg-3.mb-4
%h4 Chapters
- if @event.chapters.any?
%ul.list-inline.ml-0
- @event.chapters.each do |chapter|
%li.list-inline-item= link_to chapter.name, [:admin, chapter]
- else
%p This event has no chapters.

.row.mt-4
.row
.col
%p.lead= @event.description.html_safe

Expand Down
3 changes: 2 additions & 1 deletion app/views/event_invitation_mailer/attending.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

.content
%table
= render partial: 'shared_mailers/venue', locals: { host: @event.venue, address: @host_address }
- if @event.venue.present?
= render partial: 'shared_mailers/venue', locals: { host: @event.venue, address: @host_address }
%tr
%td
%p If you have any trouble finding the venue, give one of the organisers a call:
Expand Down
7 changes: 4 additions & 3 deletions app/views/event_invitation_mailer/invite_coach.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
%small #{humanize_date(@event.date_and_time, @event.ends_at, with_time: true)}
= link_to 'View invitation and RSVP', full_url_for(event_invitation_url(event_id: @event.slug, token: @invitation.token)), class: 'btn'

.content
%table
= render partial: 'shared_mailers/venue', locals: { host: @event.venue, address: @host_address }
- if @event.venue.present?
.content
%table
= render partial: 'shared_mailers/venue', locals: { host: @event.venue, address: @host_address }

.content
%table
Expand Down
7 changes: 4 additions & 3 deletions app/views/event_invitation_mailer/invite_student.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
%small #{humanize_date(@event.date_and_time, @event.ends_at, with_time: true)}
= link_to 'View invitation and RSVP', full_url_for(event_invitation_url(event_id: @event.slug, token: @invitation.token)), class: 'btn'

.content
%table
= render partial: 'shared_mailers/venue', locals: { host: @event.venue, address: @host_address }
- if @event.venue.present?
.content
%table
= render partial: 'shared_mailers/venue', locals: { host: @event.venue, address: @host_address }

.content
%table
Expand Down
5 changes: 4 additions & 1 deletion app/views/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
.py-4.py-lg-5.bg-light
.container
.row
= render partial: 'shared/venue', locals: { venue: @event.venue, address: @host_address}
- if @event.venue.present?
= render partial: 'shared/venue', locals: { venue: @event.venue, address: @host_address}
- else
%p= "#{t('events.virtual')}."

.row.mt-4
.col
Expand Down
21 changes: 12 additions & 9 deletions app/views/invitations/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,18 @@
= dot_markdown(@event.schedule)
.col-12.col-lg-6
%h3 Location
.row
.col-12.col-md-8
%address= @host_address.to_html
.col-12.col-md-4
= image_tag(@event.venue.avatar, class: 'small-image mw-100 mb-4', alt: @event.venue.name)
.row
.col
%iframe{ width: '100%', height: '250', frameborder: '0', scrolling: 'no', marginheight: '0', marginwidth: '0', src: %{https://maps.google.com/maps?f=q&source=s_q&hl=en&amp;geocode=&q=#{@host_address.for_map}&ie=UTF8&t=m&z=15&output=embed} }
= link_to 'View larger map', %{https://maps.google.com/maps?f=q&source=s_q&hl=en&amp;geocode=&q=#{@host_address.for_map}&ie=UTF8&hq=&t=m&z=15}, style: "color:#0000FF;text-align:left"
- if @event.venue.present?
.row
.col-12.col-md-8
%address= @host_address.to_html
.col-12.col-md-4
= image_tag(@event.venue.avatar, class: 'small-image mw-100 mb-4', alt: @event.venue.name)
.row
.col
%iframe{ width: '100%', height: '250', frameborder: '0', scrolling: 'no', marginheight: '0', marginwidth: '0', src: %{https://maps.google.com/maps?f=q&source=s_q&hl=en&amp;geocode=&q=#{@host_address.for_map}&ie=UTF8&t=m&z=15&output=embed} }
= link_to 'View larger map', %{https://maps.google.com/maps?f=q&source=s_q&hl=en&amp;geocode=&q=#{@host_address.for_map}&ie=UTF8&hq=&t=m&z=15}, style: "color:#0000FF;text-align:left"
- elsif @event.virtual?
%p= "#{t('events.virtual')}."

- if @event.show_faq
.py-4.py-lg-5.section
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ de:
schedule: "Zeitplan"
send_us_an_email: "Schreibe uns eine E-Mail"
not_open_for_rsvp: Die Anmeldung für diese Veranstaltung ist noch nicht geöffnet.
virtual: This is a virtual event
faq:
experience:
q: "Wie erfahren sollte ich sein, um am Workshop teilnehmen?"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ en:
schedule: "Schedule"
send_us_an_email: "send us an email"
not_open_for_rsvp: This event is not open for RSVP yet.
virtual: This is a virtual event
faq:
experience:
q: "How experienced should I be to join the workshop?"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en_AU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ en-AU:
schedule: "Schedule"
send_us_an_email: "send us an email"
not_open_for_rsvp: This event is not open for RSVP yet.
virtual: This is a virtual event
faq:
experience:
q: "How experienced should I be to join the workshop?"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en_GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ en-GB:
schedule: "Schedule"
send_us_an_email: "send us an email"
not_open_for_rsvp: This event is not open for RSVP yet.
virtual: This is a virtual event
faq:
experience:
q: "How experienced should I be to join the workshop?"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ en-US:
schedule: "Schedule"
send_us_an_email: "send us an email"
not_open_for_rsvp: This event is not open for RSVP yet.
virtual: This is a virtual event
faq:
experience:
q: "How experienced should I be to join the workshop?"
Expand Down
1 change: 1 addition & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ es:
schedule: "Calendario"
send_us_an_email: "envianos un email"
not_open_for_rsvp: "Este evento aún no está abierto para confirmar su asistencia."
virtual: This is a virtual event
faq:
experience:
q: "¿Qué experiencia necesito tener para unirme al taller?"
Expand Down
Loading

0 comments on commit 4cafc70

Please sign in to comment.