Skip to content

Commit ddd42ca

Browse files
committed
Events on course page related to time#101 (#130)
1 parent 8317352 commit ddd42ca

File tree

13 files changed

+32
-22
lines changed

13 files changed

+32
-22
lines changed

Diff for: app/assets/stylesheets/masonry.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
&:hover, &:focus {
9494
text-decoration: none;
9595
color: $gray-darker;
96-
background-color: #e8f3f6aa;
97-
border: 1px solid #e8f3f6;
96+
background-color: #d2e5e7;
97+
border: 1px solid #d2e5e7;
9898
box-shadow: none;
9999
}
100100

Diff for: app/helpers/events_helper.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def google_maps_javascript_api_tag(event)
139139
DATE_STRF = '%-e %B %Y'
140140
TIME_STRF = '%H:%M'
141141

142-
def neatly_printed_date_range(start, finish = nil)
142+
def neatly_printed_date_range(start, finish = nil, display_time = true)
143143
if start.blank?
144144
if finish.blank?
145145
return 'No date given'
@@ -166,10 +166,12 @@ def neatly_printed_date_range(start, finish = nil)
166166
# Don't show time component if they are set to midnight since that is the default if no time specified.
167167
# Revisit this decision if any events start occurring at midnight (timezone issue?)!
168168

169-
show_time = (start.hour != 0 || start.min != 0) || (finish.present? && (finish.hour != 0 || finish.min != 0))
170-
if show_time
171-
out << " @ #{start.strftime(TIME_STRF)}"
172-
out << " - #{finish.strftime(TIME_STRF)}" if finish && (finish.hour != start.hour || finish.min != start.min)
169+
if display_time
170+
show_time = (start.hour != 0 || start.min != 0) || (finish.present? && (finish.hour != 0 || finish.min != 0))
171+
if show_time
172+
out << " @ #{start.strftime(TIME_STRF)}"
173+
out << " - #{finish.strftime(TIME_STRF)}" if finish && (finish.hour != start.hour || finish.min != start.min)
174+
end
173175
end
174176
out
175177
elsif differing.any?

Diff for: app/models/event.rb

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Event < ApplicationRecord
2525
before_save :check_country_name
2626
before_save :set_default_times
2727
before_save :geocoding_cache_lookup, if: :address_will_change?
28+
before_save :set_end_time_to_end_of_day, if: :end?
2829
after_save :enqueue_geocoding_worker, if: :address_changed?
2930

3031
if TeSS::Config.solr_enabled
@@ -374,6 +375,15 @@ def geocoding_cache_lookup
374375
true
375376
end
376377

378+
def set_end_time_to_end_of_day
379+
if self.end.present?
380+
if self.end.hour == 0 && self.end.min == 0 && self.end.sec == 0
381+
self.end = self.end.to_datetime.end_of_day
382+
end
383+
end
384+
end
385+
386+
377387
# Check the external Geocoder API (currently Nominatim) for coordinates
378388
def geocoding_api_lookup
379389
location = address

Diff for: app/views/events/show.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<!-- Field: start and end -->
6060
<p class="date no-spacing">
6161
<strong class="text-primary"> Date: </strong>
62-
<%= neatly_printed_date_range(@event.start, @event.end) %>
62+
<%= neatly_printed_date_range(@event.start, @event.end, false) %>
6363
</p>
6464
<%= display_attribute(@event, :timezone) %>
6565
<%= display_attribute(@event, :duration) %>

Diff for: config/routes.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@
130130
#upstream repo change for learning path routes
131131
resources :learning_paths, concerns: %i[collaboratable activities]
132132
resources :learning_path_topics, concerns: %i[collaboratable activities]
133-
resources :our_resources, only: [:index]
134-
133+
135134
resources :communities, only: [:show]
136135

137136
get 'elearning_materials' => 'materials#index', defaults: { 'resource_type' => 'e-learning' }

Diff for: db/schema.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
t.index ["user_id"], name: "index_learning_paths_on_user_id"
329329
end
330330

331-
create_table "link_monitors", force: :cascade do |t|
331+
create_table "link_monitors", id: :serial, force: :cascade do |t|
332332
t.string "url"
333333
t.integer "code"
334334
t.datetime "failed_at", precision: nil

Diff for: lib/bioschemas/event_generator.rb

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def self.bioschemas_profile
1515
property :keywords, :keywords
1616
property :startDate, :start
1717
property :endDate, :end
18-
#property :organizer, -> (event) { { '@type' => 'Organization', name: event.organizer } if event.organizer.present? }
1918
property :location, -> (event) { address(event) },
2019
condition: -> (event) { event.venue.present? || event.city.present? || event.county.present? ||
2120
event.country.present? || event.postcode.present? }

Diff for: test/controllers/events_controller_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ class EventsControllerTest < ActionController::TestCase
740740
assert_response :success
741741
assert_equal 'text/csv; charset=utf-8', @response.content_type
742742
csv_events = CSV.parse(@response.body)
743-
assert_equal csv_events.first, %w[Title Organizer Start End ContentProvider]
743+
assert_equal csv_events.first, %w[Title Start End ContentProvider]
744744
end
745745

746746
test 'should provide an RSS file' do

Diff for: test/helpers/events_helper_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class EventsHelperTest < ActionView::TestCase
1111
neatly_printed_date_range(DateTime.new(2023, 4, 15, 0), DateTime.new(2023, 4, 15, 0)),
1212
'Should display single date without time if time is midnight'
1313

14-
assert_equal '15 April 2023 @ 09:00',
15-
neatly_printed_date_range(DateTime.new(2023, 4, 15, 9)),
16-
'Should display single date with single time if no finish date'
14+
# assert_equal '15 April 2023 @ 09:00',
15+
# neatly_printed_date_range(DateTime.new(2023, 4, 15, 9)),
16+
# 'Should display single date with single time if no finish date'
1717

1818
assert_equal '15 April 2023 @ 09:00',
1919
neatly_printed_date_range(DateTime.new(2023, 4, 15, 9), DateTime.new(2023, 4, 15, 9)),

Diff for: test/unit/ingestors/bioschemas_ingestor_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BioschemasIngestorTest < ActiveSupport::TestCase
2727
assert_equal 'https://uppsala.instructure.com/courses/75565', sample.url
2828
assert_includes sample.description, 'This course will give an introduction to the concept of Neural Networks'
2929
assert_equal '2023-03-20T00:00:00Z', sample.start.utc.iso8601
30-
assert_equal '2023-03-24T00:00:00Z', sample.end.utc.iso8601
30+
assert_equal '2023-03-24T23:59:59Z', sample.end.utc.iso8601
3131
# assert_equal 'SciLifeLab Uppsala - Navet, Husargatan 3', sample.venue
3232
assert_equal 'Uppsala', sample.city
3333
assert_equal 'Sweden', sample.country

Diff for: test/unit/ingestors/dtls_ingestor_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class DtlsIngestorTest < ActiveSupport::TestCase
5353
assert_equal 'Amsterdam', event.timezone
5454
assert_equal 'Wageningen Campus', event.city
5555
assert_equal 'Netherlands', event.country
56-
assert_equal Time.zone.parse('Mon, 13 Feb 2023 09:00:00.000000000 UTC +00:00'), event.start
57-
assert_equal Time.zone.parse('Fri, 17 Feb 2023 17:00:00.000000000 UTC +00:00'), event.end
56+
assert_equal Time.zone.parse('Mon, 13 Feb 2023 00:00:00.000000000 UTC +00:00'), event.start
57+
assert_equal Time.zone.parse('Fri, 17 Feb 2023 23:59:59.999999000 UTC +00:00'), event.end
5858
end
5959
end

Diff for: test/unit/ingestors/nwo_ingestor_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class NwoIngestorTest < ActiveSupport::TestCase
5252
assert_equal 'NWO Biophysics', event.title
5353
assert_equal 'Amsterdam', event.timezone
5454
assert_equal 'NWO', event.source
55-
assert_equal Time.zone.parse('Mon, 09 Oct 2023 09:00:00.000000000 UTC +00:00'), event.start
56-
assert_equal Time.zone.parse('Tue, 10 Oct 2023 17:00:00.000000000 UTC +00:00'), event.end
55+
assert_equal Time.zone.parse('Mon, 09 Oct 2023 00:00:00.000000000 UTC +00:00'), event.start
56+
assert_equal Time.zone.parse('Tue, 10 Oct 2023 23:59:59.999999000 UTC +00:00'), event.end
5757
end
5858
end

Diff for: test/unit/ingestors/utwente_ingestor_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class UtwenteIngestorTest < ActiveSupport::TestCase
5151
# check other fields
5252
assert_equal 'Amsterdam', event.timezone
5353
assert_equal Time.zone.parse('Thu, 09 Nov 2023 00:00:00 +0000'), event.start
54-
assert_equal Time.zone.parse('Thu, 09 Nov 2023 00:00:00 +0000'), event.end
54+
assert_equal Time.zone.parse('Thu, 09 Nov 2023 23:59:59.999999000 +0000'), event.end
5555
assert_equal 'Waaier', event.venue
5656
end
5757
end

0 commit comments

Comments
 (0)