-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ft create recurring events 129620817 #192
base: master
Are you sure you want to change the base?
Changes from all commits
4192ed2
25f458e
9c9828e
bde4681
14458ef
68cc17e
f8ad09e
8915a08
53365cc
00aec5f
077a096
b35dd30
8f93841
66d0060
a0b073a
9a2c7d1
742295e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,8 @@ public/uploads/tmp/* | |
|
||
/vendor/* | ||
|
||
.DS_Store | ||
# Ignore precompiled assets | ||
/public/assets/* | ||
|
||
#ignore test dir | ||
test |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,3 +447,6 @@ DEPENDENCIES | |
will_paginate (~> 3.0.6) | ||
will_paginate-materialize | ||
wkhtmltopdf-binary | ||
|
||
BUNDLED WITH | ||
1.12.5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
$(document).ready(function () { | ||
var event_date = $('.parallax-container').data('countdown'), | ||
end_date = $('.end_date').data('countdown'), | ||
start_time = $('.start_time').data('countdown'), | ||
end_time = $('.end_time').data('countdown'), | ||
prev_color = '', | ||
color = '', | ||
map; | ||
|
||
if (event_date) { countdown(convertDate(event_date)); } | ||
if (event_date) { countdown(convertDate(event_date, start_time), end_date, end_time); } | ||
|
||
$('.preview').click(function () { | ||
var map_val = $('#event_map_url').val(), | ||
start_date = $('#event_start_date').val(), | ||
end_date = $('#event_end_date').val(); | ||
end_date = $('#event_end_date').val(), | ||
start_time = $('#event_start_time').val(), | ||
end_time = $('#event_end_time').val(), | ||
frequency = $('#event_recurring_event_attributes_frequency').val(), | ||
week = $('#event_recurring_event_attributes_week').val(), | ||
day = $('#event_recurring_event_attributes_day').val(); | ||
|
||
var rec_text; | ||
if (frequency === 'Daily'){ | ||
rec_text = 'Every Day from '; | ||
} else if (frequency === 'Weekly'){ | ||
rec_text = 'Every ' + day + ' from '; | ||
} else if (frequency === 'Monthly'){ | ||
rec_text = 'Every ' + week + ' ' + day + ' of the Month, from '; | ||
} else { | ||
rec_text = ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can make use of |
||
} | ||
|
||
if (start_date) { countdown(convertDate(start_date, start_time), end_date, end_time); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NITPICK: This can be expanded out to more lines for better readability. |
||
|
||
if (start_date) { countdown(convertDate(start_date), end_date); } | ||
if (map_val) { | ||
map = map_val + '&output=embed'; | ||
} else { | ||
|
@@ -26,7 +46,13 @@ $(document).ready(function () { | |
var title = $('#event_title').val() === '' ? 'Event title goes here' : $('#event_title').val(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NITPICK: avoid evaluating a DOM obj repeatedly, |
||
$('.our-event-title').html(title); | ||
$('.our_event_description').html(description); | ||
$('.our-event-date').html(start_date + ' to ' + end_date); | ||
if (rec_text !== ''){ | ||
$('.our-event-date').html(start_date + ' - ' + end_date); | ||
$('.our-event-time').html(rec_text + start_time + ' to ' + end_time); | ||
} else { | ||
$('.our-event-date').html(start_date + ', ' + start_time + ' - ' + end_date + ', ' + end_time); | ||
$('.our-event-time').html(''); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NITPICK: |
||
} | ||
$('.landing2').removeClass(prev_color); | ||
$('.landing2').addClass(color); | ||
$('.our-event-map-url').attr({ 'src': map }); | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
$(document).ready( function () { | ||
|
||
$('.event-time-picker').pickatime({ twelvehour: true }); | ||
$('.event-time-picker').pickatime({ twelvehour: true }); | ||
|
||
$('.recur-lever').on('click', function (){ | ||
var status = !$('.recur-event').prop('checked'); | ||
if (status){ | ||
$('.recurring_event_space').removeClass('display-none'); | ||
} else { | ||
$('.recurring_event_space').addClass('display-none'); | ||
$('.week-frequency').addClass('display-none'); | ||
$('.day-frequency').addClass('display-none'); | ||
$('#event_recurring_event_attributes_frequency').val(''); | ||
$('#event_recurring_event_attributes_week').val(''); | ||
$('#event_recurring_event_attributes_day').val(''); | ||
} | ||
}); | ||
|
||
$('#event_recurring_event_attributes_frequency').on('change', function (){ | ||
if (this.value === 'Weekly'){ | ||
$('.week-frequency').addClass('display-none'); | ||
$('.day-frequency').removeClass('display-none'); | ||
$('#event_recurring_event_attributes_day').val(''); | ||
$('#event_recurring_event_attributes_week').val(''); | ||
} else if (this.value === 'Monthly') { | ||
$('.week-frequency').removeClass('display-none'); | ||
$('.day-frequency').removeClass('display-none'); | ||
$('#event_recurring_event_attributes_day').val(''); | ||
$('#event_recurring_event_attributes_week').val(''); | ||
} else { | ||
$('.week-frequency').addClass('display-none'); | ||
$('.day-frequency').addClass('display-none'); | ||
$('#event_recurring_event_attributes_day').val(''); | ||
$('#event_recurring_event_attributes_week').val(''); | ||
} | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ class EventsController < ApplicationController | |
|
||
def new | ||
@event = Event.new.decorate | ||
build_recurring_event | ||
@event.ticket_types.build | ||
@roles = Event.get_roles | ||
end | ||
|
@@ -35,13 +36,15 @@ def show | |
@booking = @event.bookings.new | ||
@booking.user = current_user | ||
@event_ticket = @event.ticket_types | ||
@recurring_event = @event.recurring_event unless @event.recurring_event.nil? | ||
1.times { @booking.user_tickets.build } | ||
respond_with @event | ||
end | ||
|
||
def edit | ||
@roles = Event.get_roles | ||
@highlights = @event.highlights | ||
build_recurring_event unless @event.recurring_event | ||
end | ||
|
||
def enable | ||
|
@@ -78,6 +81,7 @@ def create | |
flash[:notice] = if @event.save | ||
create_successful_message("event") | ||
else | ||
build_recurring_event | ||
@event.errors.full_messages.join("; ") | ||
end | ||
respond_with(@event) | ||
|
@@ -126,11 +130,23 @@ def search_params | |
|
||
def event_params | ||
params.require(:event).permit( | ||
:title, :description, :start_date, :end_date, :category_id, :location, | ||
:venue, :image, :template_id, :map_url, :event_template_id, | ||
:title, | ||
:description, | ||
:start_date, | ||
:end_date, | ||
:start_time, | ||
:end_time, | ||
:category_id, | ||
:location, | ||
:venue, | ||
:image, | ||
:template_id, | ||
:map_url, | ||
:event_template_id, | ||
ticket_types_attributes: [:id, :_destroy, :name, :quantity, :price], | ||
highlights_attributes: [:id, :_destroy, :day, :title, :description, | ||
:start_time, :end_time, :image, :image_title], | ||
recurring_event_attributes: [:id, :_destroy, :frequency, :day, :week], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Nice indentation. good readability. |
||
event_staffs_attributes: [:user_id, :role] | ||
) | ||
end | ||
|
@@ -158,4 +174,8 @@ def subscription_status | |
|
||
def loading | ||
end | ||
|
||
def build_recurring_event | ||
@event.build_recurring_event | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,6 @@ def index | |
respond_with @events | ||
end | ||
|
||
def about | ||
end | ||
|
||
def faq | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,12 @@ def image_url(version) | |
|
||
def start_date | ||
return object.start_date.strftime("%b %d %Y") if object.start_date? | ||
Time.zone.now.strftime("%b %d %Y") | ||
# Time.zone.now.strftime("%b %d %Y") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid commenting obsolete codes... this is a candidate for removal. |
||
end | ||
|
||
def start_time | ||
return object.start_time.strftime("%I:%M%p") if object.start_time? | ||
# Time.now.strftime("%I:%M%p") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid commenting obsolete codes... this is a candidate for removal. |
||
end | ||
|
||
def event_template | ||
|
@@ -28,7 +33,12 @@ def sponsors | |
|
||
def end_date | ||
return object.end_date.strftime("%b %d %Y") if object.end_date? | ||
Time.zone.now.strftime("%b %d %Y") | ||
# Time.zone.now.strftime("%b %d %Y") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid commenting obsolete codes... this is a candidate for removal. |
||
end | ||
|
||
def end_time | ||
return object.end_time.strftime("%I:%M%p") if object.end_time? | ||
# Time.now.strftime("%I:%M%p") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid commenting obsolete codes... this is a candidate for removal. |
||
end | ||
|
||
def get_event_staffs | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,17 @@ def cummulative_rating(event) | |
|
||
private | ||
|
||
def display_event_frequency(recurring_event) | ||
if recurring_event.frequency == "Daily" | ||
"Every Day from " | ||
elsif recurring_event.frequency == "Weekly" | ||
"Every " + recurring_event.day + " from " | ||
else | ||
"Every " + recurring_event.week + " " + | ||
recurring_event.day + " of the Month, from " | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can make use of |
||
end | ||
|
||
def converter(amt) | ||
number_to_currency(amt, unit: "$") | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ class Event < ActiveRecord::Base | |
has_many :ticket_types, dependent: :destroy | ||
has_many :event_staffs, dependent: :destroy | ||
has_many :highlights, dependent: :destroy | ||
has_one :recurring_event, dependent: :destroy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for readability purposes... similar associations can be grouped... all |
||
has_many :staffs, through: :event_staffs, source: "user" | ||
accepts_nested_attributes_for :ticket_types, | ||
allow_destroy: true, reject_if: :all_blank | ||
|
@@ -13,6 +14,8 @@ class Event < ActiveRecord::Base | |
reject_if: :invalid_staff_info | ||
accepts_nested_attributes_for :highlights, | ||
allow_destroy: true, reject_if: :all_blank | ||
accepts_nested_attributes_for :recurring_event, | ||
allow_destroy: true, reject_if: :all_blank | ||
has_many :bookings | ||
has_many :user_tickets, through: :bookings | ||
has_many :attendees, through: :bookings, source: "user" | ||
|
@@ -32,6 +35,8 @@ class Event < ActiveRecord::Base | |
validates :description, presence: true, length: { in: 20..1000 } | ||
validates :start_date, presence: true | ||
validates :end_date, presence: true | ||
validates :start_time, presence: true | ||
validates :end_time, presence: true | ||
validates :category_id, presence: true | ||
validates :ticket_types, presence: true | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class RecurringEvent < ActiveRecord::Base | ||
belongs_to :event | ||
|
||
FREQUENCY = %w(Daily Weekly Monthly).freeze | ||
WEEK = %w(First Second Third Fourth).freeze | ||
DAY = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday).freeze | ||
|
||
validates :day, presence: true, if: "frequency == 'Weekly'" | ||
validates :week, presence: true, if: "frequency == 'Monthly'" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NITPICK: This can be expanded out to more lines for better readability.