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

Staging #328

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.12.1
v16.15.0
13 changes: 10 additions & 3 deletions app/controllers/admin/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ def show; end
def edit; end

def update
if @event.update(event_params)
if @event.update(event_params.except(:time_zone))
@event.start = @event.start + event_params[:time_zone].to_i * 60 # timezones are in minutes
@event.ends = @event.ends + event_params[:time_zone].to_i * 60 # timezones are in minutes
@event.save

redirect_to [:admin, @event], notice: 'The event was successfully updated.'
else
render :edit
end
end

def create
@event = Event.new(event_params)
@event = Event.new(event_params.except(:time_zone))
@event.start = @event.start + event_params[:time_zone].to_i * 60 # timezones are in minutes
@event.ends = @event.ends + event_params[:time_zone].to_i * 60 # timezones are in minutes

if @event.save
redirect_to admin_events_url, notice: 'Event was successfully created.'
Expand Down Expand Up @@ -59,7 +65,8 @@ def event_params
:start,
:ends,
:location,
:link
:link,
:time_zone
).to_h
end
end
1 change: 1 addition & 0 deletions app/javascript/components/DatasetsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ DatasetsModal.propTypes = {
history: PropTypes.object.isRequired,
layers: PropTypes.array.isRequired,
categories: PropTypes.array.isRequired,
classes: PropTypes.object,
}

export default withRouter(injectSheet(styles)(DatasetsModal))
11 changes: 8 additions & 3 deletions app/views/admin/events/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
.form-group
.field
= f.label :start
= f.datetime_field :start, class: 'form-control'
= f.datetime_field :start, class: 'form-control time-field'
.form-group
.field
= f.label :ends
= f.datetime_field :ends, class: 'form-control'
= f.datetime_field :ends, class: 'form-control time-field'
.form-group
.field
= f.label :location
Expand All @@ -28,4 +28,9 @@
.actions = f.submit class: 'btn btn-primary'

javascript:
document.getElementById('event_time_zone').value = new Date().getTimezoneOffset();
document.getElementById('event_time_zone').value = new Date().getTimezoneOffset()
document.querySelectorAll('.time-field').forEach(d => {
const offsetMins = new Date().getTimezoneOffset()
const localTime = new Date(new Date(d.value).getTime() - 2*(offsetMins * 60 * 1000))
d.value = localTime.toISOString().slice(0, 16)
})
7 changes: 5 additions & 2 deletions app/views/admin/events/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ div
= @event.title
p
strong> Start:
= @event.start
span.time-field = @event.start

p
strong> Ends:
= @event.ends
span.time-field = @event.ends

p
strong> Location
Expand All @@ -30,3 +30,6 @@ div
=> link_to 'Edit', edit_admin_event_path(@event)
'|
=< link_to 'Back', admin_events_path

javascript:
document.querySelectorAll('.time-field').forEach(d => { d.innerText = new Date(d.innerText) })
2 changes: 1 addition & 1 deletion config/deploy/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

set :branch, `git rev-parse --abbrev-ref HEAD`.chomp

set :default_env, { PATH: '$HOME/.nvm/versions/node/v20.12.1/bin/:$PATH' }
set :default_env, { PATH: '$HOME/.nvm/versions/node/v16.15.0/bin/:$PATH' }

set :rvm_custom_path, '/home/ubuntu/.rvm'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEA046B569821848616F97378C571A98E5F085CE2DA64CAABE83761A81EE826F
comodoca.com
17f285e51030db9
28 changes: 28 additions & 0 deletions test/fixtures/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,32 @@ third:
ends: 2023-12-12 22:00:00
location: Dubai
link:

fourth:
title: Test event
start: 2024-07-16 20:41:00
ends: 2024-07-18 20:41:00
location: Dubai
link:

fifth:
title: Test event
start: 2024-07-20 20:41:00
ends: 2024-07-22 20:41:00
location: Dubai
link:

Sixth:
title: Test event Sixth
start: 2024-07-16 20:41:00
ends: 2024-07-22 20:41:00
location: Dubai
link:

Seventh:
title: Test event Sixth
start: 2024-07-16 20:41:00
ends: 2024-07-18 21:03:00
location: Dubai
link:

Loading