From 52eb777a4434d7208e958a506e0d49bf7a7d3cbc Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Fri, 17 Oct 2014 21:05:26 +0300 Subject: [PATCH 1/4] Add rejection notification --- app/mailers/event_mailer.rb | 6 ++++++ app/models/event.rb | 4 ++++ .../event_mailer/rejection_notification.text.erb | 11 +++++++++++ 3 files changed, 21 insertions(+) create mode 100644 app/views/event_mailer/rejection_notification.text.erb diff --git a/app/mailers/event_mailer.rb b/app/mailers/event_mailer.rb index b28000c..b3e4a3d 100644 --- a/app/mailers/event_mailer.rb +++ b/app/mailers/event_mailer.rb @@ -10,4 +10,10 @@ class EventMailer < ActionMailer::Base I18n.locale = @event.language mail to: @event.user.email, from: 'program@openfest.org', subject: I18n.t('event_mailer.acceptance_notification.subject', conference: @event.conference.title, submission_type: @event.class.model_name.human.mb_chars.downcase.to_s, title: @event.title) end + + def rejection_notification(event) + @event = event + I18n.locale = 'bg' # XXX Change this when per-user locale is introduced in the user + mail to: @event.user.email, from: 'program@openfest.org', subject: "Предложението ви за #{@event.conference.title} за #{event.class.model_name.human.mb_chars.downcase.to_s} „#{@event.title}“ не е одобрено" + end end diff --git a/app/models/event.rb b/app/models/event.rb index 426c4f5..a7d9391 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -25,6 +25,10 @@ class Event < ActiveRecord::Base touch :acceptance_notification_sent_at end + def send_rejection_notification! + EventMailer.rejection_notification(self).deliver + end + def confirmed? !!confirmed_at end diff --git a/app/views/event_mailer/rejection_notification.text.erb b/app/views/event_mailer/rejection_notification.text.erb new file mode 100644 index 0000000..4b74180 --- /dev/null +++ b/app/views/event_mailer/rejection_notification.text.erb @@ -0,0 +1,11 @@ +Здравейте, + +За съжаление, поради големия брой предложения за лекции, които получихме тази година, както и ограниченото време и брой зали, с които разполагаме, вашето предложение за <%= @event.class.model_name.human.mb_chars.downcase.to_s %> на тема „<%= @event.title %>“ не влезе в основната програма. + +Тъй като темата звучи интересно, бихме ви предложили да се включите с лекция (15-40 минути) в дните на конференцията, като форматът ще е малко по-различен. Повече може да прочетете на http://www.openfest.org/bg/2014/10/17/light-conferences/ + +Темите тази година ще са: + + Събота, 11:15-13:15, зала Пловдив - Управление и маркетинг на open-source проекти (социалната страна на open-source проектите) + Събота, 14:30-17:30, зала Пловдив - Събиране на системни и мрежови администратори + Неделя, 14:30-17:30, зала Бургас - Civic hacking From 21f854ea56efb06b903f95df8c836230540df787 Mon Sep 17 00:00:00 2001 From: Vasil Kolev Date: Mon, 20 Oct 2014 22:31:57 +0300 Subject: [PATCH 2/4] second mailing text --- .../acceptance_second_notification.bg.text.erb | 18 ++++++++++++++++++ .../acceptance_second_notification.en.text.erb | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 app/views/event_mailer/acceptance_second_notification.bg.text.erb create mode 100644 app/views/event_mailer/acceptance_second_notification.en.text.erb diff --git a/app/views/event_mailer/acceptance_second_notification.bg.text.erb b/app/views/event_mailer/acceptance_second_notification.bg.text.erb new file mode 100644 index 0000000..f128c7d --- /dev/null +++ b/app/views/event_mailer/acceptance_second_notification.bg.text.erb @@ -0,0 +1,18 @@ +Здравейте, + +Напомняме Ви, че предложението ви за участие в <%= @event.conference.title %> с <%= @event.class.model_name.human.mb_chars.downcase.to_s %> на тема „<%= @event.title %>“ беше одобрено. + +Моля, потвърдете участието си възможно най-скоро като кликнете на следния линк: +<% if @event.is_a? Lecture %> +<%= confirm_lecture_url(@event) %> +<% elsif @event.is_a? Workshop %> +<%= confirm_workshop_url(@event) %> +<% end %> + +Отговорете на този email, ако възникнат някакви въпроси. + +Първоначален вариант на програмата можете да видите тук: +http://wwwt.openfest.org/bg/programa/ + +Поздрави, +Екипът на <%= @event.conference.title %> diff --git a/app/views/event_mailer/acceptance_second_notification.en.text.erb b/app/views/event_mailer/acceptance_second_notification.en.text.erb new file mode 100644 index 0000000..68228e0 --- /dev/null +++ b/app/views/event_mailer/acceptance_second_notification.en.text.erb @@ -0,0 +1,18 @@ +Hello, + +We want to remind you that that your request for participation in <%= @event.conference.title %> with the <%= @event.class.model_name.human.mb_chars.downcase.to_s %> titled "<%= @event.title %>" was approved. + +Please confirm your participation as soon as you can by following the following link: +<% if @event.is_a? Lecture %> +<%= confirm_lecture_url(@event, locale: 'en') %> +<% elsif @event.is_a? Workshop %> +<%= confirm_workshop_url(@event, locale: 'en') %> +<% end %> + +Please respond to this email in case you have any questions. + +The initial conference schedule can be found here: +http://wwwt.openfest.org/en/schedule/ + +Regards, +The <%= @event.conference.title %> Team From 26e523dc2f76194b4652d5cd90a93fea08f5dc5d Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Mon, 20 Oct 2014 22:36:21 +0300 Subject: [PATCH 3/4] Add Event#send_acceptance_second_notification --- app/mailers/event_mailer.rb | 6 ++++++ app/models/event.rb | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/mailers/event_mailer.rb b/app/mailers/event_mailer.rb index b3e4a3d..f20abc2 100644 --- a/app/mailers/event_mailer.rb +++ b/app/mailers/event_mailer.rb @@ -11,6 +11,12 @@ class EventMailer < ActionMailer::Base mail to: @event.user.email, from: 'program@openfest.org', subject: I18n.t('event_mailer.acceptance_notification.subject', conference: @event.conference.title, submission_type: @event.class.model_name.human.mb_chars.downcase.to_s, title: @event.title) end + def acceptance_second_notification(event) + @event = event + I18n.locale = @event.language + mail to: @event.user.email, from: 'program@openfest.org', subject: I18n.t('event_mailer.acceptance_notification.subject', conference: @event.conference.title, submission_type: @event.class.model_name.human.mb_chars.downcase.to_s, title: @event.title) + end + def rejection_notification(event) @event = event I18n.locale = 'bg' # XXX Change this when per-user locale is introduced in the user diff --git a/app/models/event.rb b/app/models/event.rb index a7d9391..f8615d9 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -25,6 +25,11 @@ class Event < ActiveRecord::Base touch :acceptance_notification_sent_at end + def send_acceptance_second_notification! + EventMailer.acceptance_second_notification(self).deliver + touch :acceptance_notification_sent_at + end + def send_rejection_notification! EventMailer.rejection_notification(self).deliver end From b5cd1ff8f1d5df6936b53cc8c3fb6fbf5d5c2a3f Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Fri, 31 Oct 2014 12:54:11 +0200 Subject: [PATCH 4/4] Add a json export of the schedule --- app/controllers/schedule.rb | 25 +++++++++++++++++++++++++ app/controllers/schedules_controller.rb | 10 ++++++++++ app/models/conference.rb | 1 + app/models/hall.rb | 1 + config/routes.rb | 2 ++ 5 files changed, 39 insertions(+) create mode 100644 app/controllers/schedule.rb create mode 100644 app/controllers/schedules_controller.rb diff --git a/app/controllers/schedule.rb b/app/controllers/schedule.rb new file mode 100644 index 0000000..3a0f3f2 --- /dev/null +++ b/app/controllers/schedule.rb @@ -0,0 +1,25 @@ +class Schedule + include ActiveModel::Model + attr_accessor :hall, :slots + + def self.for_conference(conference) + schedule = {} + conference.halls.each do |hall| + schedule[hall.id] = hall.slots.includes(:event, event: [:speakers]).where('starts_at < ?', Date.tomorrow).where.not(event_id: nil).order(:starts_at).map do |slot| + { + title: slot.event.title, + subtitle: slot.event.subtitle, + startTime: slot.starts_at, + endTime: slot.ends_at, + speakers: slot.event.speakers.map do |speaker| + { + name: speaker.name, + description: speaker.biography + } + end + } + end + end + schedule + end +end diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb new file mode 100644 index 0000000..564a93e --- /dev/null +++ b/app/controllers/schedules_controller.rb @@ -0,0 +1,10 @@ +class SchedulesController < ApplicationController + def show + @schedule = Schedule.for_conference Conference.current + headers['Access-Control-Allow-Origin'] = '*' + headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' + headers['Access-Control-Max-Age'] = "1728000" + + respond_to { |format| format.json { render json: @schedule.to_json } } + end +end diff --git a/app/models/conference.rb b/app/models/conference.rb index 224a408..7d9955f 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -11,6 +11,7 @@ class Conference < ActiveRecord::Base has_many :tracks, -> { order('id asc') } has_many :events, through: :tracks has_many :candidate_speakers, through: :events + has_many :halls scope :future, -> { where('start_date >= ?', Date.today).order('start_date ASC') } diff --git a/app/models/hall.rb b/app/models/hall.rb index 9661672..22cb339 100644 --- a/app/models/hall.rb +++ b/app/models/hall.rb @@ -1,3 +1,4 @@ class Hall < ActiveRecord::Base belongs_to :conference + has_many :slots end diff --git a/config/routes.rb b/config/routes.rb index 636156f..b4cb7f1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,8 @@ Rails.application.routes.draw do end end + resource :schedule, only: [:show] + devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'} namespace :management do