Skip to content
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

Revert default currency branch #379

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
1cfa242
Merge branch '18712145-add-ticket-purchase-currency-selector' of gith…
Edge7481 Mar 15, 2024
f90435e
Update .codeclimate.yml
warrenlet Feb 23, 2024
29b0d55
merge
warrenlet Mar 15, 2024
a1c116d
Merge branch '187121440_Materials_Bulk_Upload'
warrenlet Mar 15, 2024
4c6c4ee
Merge branch '187153142-impl-currency-for-payments-page'
warrenlet Mar 15, 2024
4537e98
Merge remote-tracking branch 'origin/187153142-impl-currency-for-paym…
warrenlet Mar 15, 2024
bf76578
merge
warrenlet Mar 15, 2024
f19a779
Merge branch 'main' of github.com:cs169/snapcon
warrenlet Mar 18, 2024
4a4df63
Add upload csv schedule button
warrenlet Mar 19, 2024
2022ffb
Add comment code to enable button funcionality
warrenlet Mar 28, 2024
b1375b5
added enable_public_submission to event_types model need to implement…
tiffanylamm Apr 1, 2024
784d50f
admin vs non-admin dropdown and descriptions event types working
tiffanylamm Apr 5, 2024
23cbde8
Merge pull request #31 from cs169/187153142-impl-currency-for-payment…
Edge7481 Apr 12, 2024
a988487
finished applying enable-public-submission plus tests
tiffanylamm Apr 12, 2024
b932d80
Merge branch 'main' of github.com:cs169/snapcon
warrenlet Apr 14, 2024
28e75c6
Migrate include_committee to splash pages
warrenlet Apr 14, 2024
8a8f9de
proposals work for not signed in user
tiffanylamm Apr 15, 2024
d4061ac
Add organizers pic on the splashpage
warrenlet Apr 15, 2024
adc8282
Merge pull request #28 from cs169/187121440_Materials_Bulk_Upload
warrenlet Apr 15, 2024
81b174e
add profile link to organizer
warrenlet Apr 15, 2024
773adb5
Merge branch 'main' of github.com:cs169/snapcon
warrenlet Apr 15, 2024
ecba0fb
Update .rubocop_todo.yml
warrenlet Apr 16, 2024
a41141f
Update .rubocop_todo.yml
warrenlet Apr 16, 2024
4b1555c
Set up button and style
Edge7481 Apr 16, 2024
1e4a646
add javascript to scroll to closest event
Edge7481 Apr 16, 2024
2a721c5
Merge branch 'main' into 187217062-enable-public-submission-event-types
tiffanylamm Apr 17, 2024
3b847b6
add test and fix error
Edge7481 Apr 18, 2024
8370e05
Merge branch 'main' of github.com:cs169/snapcon
warrenlet Apr 21, 2024
fb3950a
parse upload url to check if it is a embeddable snap project
Edge7481 Apr 22, 2024
6a89df6
Upload CSV Added
Apr 22, 2024
ba130c8
Merge pull request #33 from cs169/187217062-enable-public-submission-…
tiffanylamm Apr 22, 2024
2591edb
add test coverage for snap embed message. Fix cases where url is nil
Edge7481 Apr 22, 2024
78844a0
feature working need to fix some tests
tiffanylamm Apr 22, 2024
3c73c95
remove unused import
Edge7481 Apr 22, 2024
4389a31
add upload CSV function
Apr 23, 2024
8d10eca
fixed CI error in controller
tiffanylamm Apr 23, 2024
af0754b
fixed multiple ticket at registration view
tiffanylamm Apr 24, 2024
1b7a9ae
added testing for conference_registration_controller
tiffanylamm Apr 24, 2024
e66a075
fixed ticket_turnover_total failing model spec
tiffanylamm Apr 24, 2024
aef231a
spelling mistake
tiffanylamm Apr 24, 2024
f514259
Merge branch 'main' into 187376318-ticket-purchases-curr-conversion
tiffanylamm Apr 24, 2024
99f5306
Merge pull request #34 from cs169/187391447-schedule-jump-to-time-button
Edge7481 Apr 26, 2024
25f99fb
Merge pull request #35 from cs169/187436622-commercials-embed-snap
Edge7481 Apr 26, 2024
25e381f
Resolve merge conflicts by regenerating schema.rb
Apr 26, 2024
4fb8f3f
Merge pull request #36 from cs169/187376318-ticket-purchases-curr-con…
Edge7481 Apr 27, 2024
0e228b8
Fix RuboCop offenses in schedules controller
Apr 28, 2024
645f95a
Fix RuboCop offenses in schedules controller2
Apr 28, 2024
3842184
Fix RuboCop offenses in schedules controller3
Apr 28, 2024
6ba98dd
Refactored for add event by csv
Apr 28, 2024
c847c3a
Fix RuboCop offenses in schedules controller
Apr 28, 2024
cf52a84
Fix code style issues
Apr 28, 2024
b7999bc
Fix code style issues
Apr 28, 2024
9e65549
Merge pull request #38 from cs169/187216987_add_event_by_CSV
owennny Apr 28, 2024
9eb8779
Merge branch 'main' of github.com:cs169/snapcon
warrenlet Apr 28, 2024
66d3fe5
Merge branch 'main' into 187391225_Add_committees_info
warrenlet Apr 15, 2024
ec4603a
Merge branch 'main' into 187391225_Add_committees_info
warrenlet Apr 28, 2024
e3a8b0b
Merge pull request #32 from cs169/187391225_Add_committees_info
warrenlet Apr 28, 2024
62ff980
delete event enable
warrenlet Apr 21, 2024
8aab77e
rubocop styling fix
warrenlet Apr 28, 2024
76cb323
Merge pull request #40 from cs169/187460419_Support_delete_event
warrenlet Apr 29, 2024
1787ba7
Revert "Revert "187121499 enable default currency""
owennny Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions app/assets/javascripts/osem-schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,35 @@ $(document).ready( function() {
$('.unscheduled-events .schedule-event-delete-button').hide();
$('.non_schedulable .schedule-event-delete-button').hide();

$('#current-event-btn').on('click', function() {
var now = new Date();
var closestEventId = null;
var smallestDiff = Infinity;
var i = 0;

$('.event-item').each(function() {

var eventTimeStr = $(this).data('time');

if (eventTimeStr) {
var eventTime = new Date(eventTimeStr);
var diff = Math.abs(eventTime - now);

if (diff < smallestDiff) {
smallestDiff = diff;
closestEventId = $(this).attr('class').split(' ')[1];
}
}
});

if (closestEventId) {
//Instead of relying on hash it's probably better to scroll using javascript
//Since the users and click button->scroll->click again, which won't re-scroll
$('.highlighted').removeClass('highlighted');
$('.' + closestEventId).addClass('highlighted').get(0).scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});

// set events as draggable
$('.schedule-event').not('.non_schedulable').draggable({
snap: '.schedule-room-slot',
Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/osem-schedule.scss
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,10 @@
h3.event-panel-title small {
line-height: 1.4;
}

#current-event-btn {
position: fixed;
bottom: 40px;
right: 40px;
z-index: 1000;
}
36 changes: 25 additions & 11 deletions app/controllers/admin/commercials_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,44 @@ def render_commercial
# Received a file from user
# Reads file and creates commercial for event
# File content example:
# EventID:MyURL
# EventID, Title, URL
def mass_upload
errors = Commercial.read_file(params[:file]) if params[:file]

if !params[:file]
flash[:error] = 'Empty file detected while adding materials to Event'
elsif errors.all? { |_k, v| v.blank? }
flash[:notice] = 'Successfully added materials.'
else
errors_text = ''
errors_text += 'Unable to find event with ID: ' + errors[:no_event].join(', ') + '. ' if errors[:no_event].any?
if errors[:validation_errors].any?
errors_text += 'There were some errors: ' + errors[:validation_errors].join('. ')
end
elsif errors.present?
errors_text = aggregate_errors(errors)
flash[:notice] = if errors_text.length > 4096
'Errors are too long to be displayed. Please check the logs.'
else
errors_text
end

flash[:error] = errors_text
else
flash[:notice] = 'Successfully added materials.'
end
redirect_back(fallback_location: root_path)
end

private

# Aggregate errors and ensure that they do not exceed 4 KB in total size
def aggregate_errors(errors)
errors_text = ''
if errors[:no_event].any?
errors_text += 'Unable to find events with IDs: ' + errors[:no_event].join(', ') + '. '
end
if errors[:validation_errors].any?
errors_text += 'Validation errors: ' + errors[:validation_errors].join('. ')
end
errors_text
end

def commercial_params
params.require(:commercial).permit(:title, :url)
params.require(:commercial).permit(:title, :url).tap do |params|
params[:url] = Commercial.generate_snap_embed(params[:url]) if params[:url]
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/event_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def destroy

def event_type_params
params.require(:event_type).permit(:title, :length, :minimum_abstract_length, :maximum_abstract_length,
:submission_template, :color, :conference_id, :description)
:submission_template, :color, :conference_id, :description, :enable_public_submission)
end
end
end
11 changes: 11 additions & 0 deletions app/controllers/admin/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ def toggle_attendance
end
end

def destroy
@event = Event.find(params[:id])
if @event.destroy
flash[:notice] = 'Event successfully deleted.'
redirect_to admin_conference_program_events_path(@conference.short_title)
else
flash[:alert] = 'Event could not be deleted.'
redirect_to admin_conference_program_event_path(@conference.short_title, @event)
end
end

private

def event_params
Expand Down
56 changes: 56 additions & 0 deletions app/controllers/admin/schedules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Admin
class SchedulesController < Admin::BaseController
# By authorizing 'conference' resource, we can ensure there will be no unauthorized access to
# the schedule of a conference, which should not be accessed in the first place
before_action :set_conference
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :program, through: :conference, singleton: true
load_and_authorize_resource :schedule, through: :program, except: %i[new create]
Expand Down Expand Up @@ -68,8 +69,63 @@ def destroy
end
end

def upload_csv
authorize! :update, @conference
return flash[:alert] = 'No file was attached!' unless file_present?

if process_csv
flash[:notice] = 'Schedule uploaded successfully!'
else
flash[:alert] = 'Failed to process CSV file.'
end

redirect_to admin_conference_schedules_path(@conference)
end

private

def set_conference
@conference = Conference.find_by!(short_title: params[:conference_id])
end

def file_present?
params[:schedule] && params[:schedule][:file].present?
end

def process_csv
file = params[:schedule][:file]
CSV.foreach(file.path, headers: true) do |row|
process_row(row)
end
true
rescue StandardError => e
Rails.logger.error "CSV Processing Error: #{e.message}"
false
end

def process_row(row)
event_date = parse_date(row['Date'])
event_time = parse_time(row['Start_Time'])
event_start_time = combine_datetime(event_date, event_time)

room = Room.find_or_create_by(name: row['Room'])
event = Event.find_by(id: row['Event_ID'])

event&.update(start_time: event_start_time, room: room)
end

def parse_date(date_str)
Date.strptime(date_str, '%m/%d/%y')
end

def parse_time(time_str)
Time.parse(time_str)
end

def combine_datetime(date, time)
DateTime.new(date.year, date.month, date.day, time.hour, time.min, time.sec, time.zone)
end

def schedule_params
params.require(:schedule).permit(:track_id) if params[:schedule]
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/admin/splashpages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def splashpage_params
:include_venue, :include_registrations,
:include_tickets, :include_lodgings,
:include_sponsors, :include_social_media,
:include_booths, :include_happening_now)
:include_booths, :include_happening_now,
:include_committee)
end
end
end
15 changes: 10 additions & 5 deletions app/controllers/conference_registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ def new
end

def show
@total_price = Ticket.total_price_user(@conference, current_user, paid: true)
@tickets = current_user.ticket_purchases.by_conference(@conference).paid
@total_price_per_ticket = @tickets.group(:ticket_id).sum('amount_paid * quantity')
@ticket_payments = @tickets.group_by(&:ticket_id)
@total_quantity = @tickets.group(:ticket_id).sum(:quantity)
@purchases = current_user.ticket_purchases.by_conference(@conference).paid
summed_per_ticket_per_currency = @purchases.group(:ticket_id, :currency).sum('amount_paid_cents * quantity')
@total_price_per_ticket_per_currency = summed_per_ticket_per_currency.each_with_object({}) do |((ticket_id, currency), amount), hash|
hash[[ticket_id, currency]] = Money.new(amount, currency)
end
@total_quantity = @purchases.group(:ticket_id, :currency).sum(:quantity)
sum_total_currency = @purchases.group(:currency).sum('amount_paid_cents * quantity')
@total_price_per_currency = sum_total_currency.each_with_object({}) do |(currency, amount), hash|
hash[currency] = Money.new(amount, currency)
end
end

def edit; end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def index
end

# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
def show
# load conference with header content
@conference = Conference.unscoped.eager_load(
Expand Down Expand Up @@ -65,8 +66,12 @@ def show
).order('sponsorship_levels.position ASC', 'sponsors.name')
@sponsors = @conference.sponsors
end
if @splashpage.include_committee?
@organizers = User.with_role(:organizer, @conference)
end
end
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/PerceivedComplexity

def calendar
respond_to do |format|
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def new
@has_registration_ticket = params[:has_registration_ticket]
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)

@converted_prices = {}
@unpaid_ticket_purchases.each do |ticket_purchase|
@converted_prices[ticket_purchase.id] = ticket_purchase.amount_paid
end
@currency = selected_currency
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ def event_params
end

def user_params
params.require(:user).permit(:email, :password, :password_confirmation, :username)
params.require(:user).permit(:email, :password, :password_confirmation, :username, :is_admin)
end
end
7 changes: 6 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class UsersController < ApplicationController
before_action :authenticate_user!, only: :search
before_action :set_currency_options, only: [:edit, :new, :create, :update]
load_and_authorize_resource

# GET /users/1
Expand Down Expand Up @@ -40,7 +41,7 @@ def search

def user_params
params[:user][:timezone] = params[:user][:timezone].presence || nil
params.require(:user).permit(:name, :biography, :nickname, :affiliation,
params.require(:user).permit(:name, :biography, :nickname, :affiliation, :default_currency,
:picture, :picture_cache, :timezone)
end

Expand All @@ -49,5 +50,9 @@ def user_params
def load_user
@user ||= (params[:id] && params[:id] != 'current' && User.find(params[:id])) || current_user
end

# rubocop:enable Naming/MemoizedInstanceVariableName
def set_currency_options
@currency_options = CurrencyConversion::VALID_CURRENCIES.map { |currency| [currency, currency] }
end
end
8 changes: 6 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ def volunteer_links(event)
end, ', ')
end

def event_types_sentence(conference)
conference.event_types.map { |et| et.title.pluralize }.to_sentence
def event_types_sentence(conference, is_admin)
if is_admin
conference.event_types.map { |et| et.title.pluralize }.to_sentence
else
conference.event_types.available_for_public.map { |et| et.title.pluralize }.to_sentence
end
end

def sign_in_path
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/event_types_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def event_type_select_options(event_types = {})
"#{type.title} - #{show_time(type.length)}",
type.id,
{ data: {
min_words: type.minimum_abstract_length,
max_words: type.maximum_abstract_length,
instructions: type.submission_template
min_words: type.minimum_abstract_length,
max_words: type.maximum_abstract_length,
template: type.submission_template
} }
]
end
Expand Down
Loading
Loading