Skip to content

Commit

Permalink
Fix calendar view
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Feb 12, 2024
1 parent d055ae6 commit 08d832b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions app/controllers/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ def index
@entries = current_user.entries.includes(:inspiration).where("date >= '#{params[:group]}-01-01'::DATE AND date <= '#{params[:group]}-12-31'::DATE").sort_by(&:date)
rescue
Sentry.capture_message("Doing expensive lookup based on ID for entry", level: :info, extra: { params: params })
entry = current_user.entries.find(params[:group])
return redirect_to day_entry_path(year: entry.date.year, month: entry.date.month, day: entry.date.day)
entry = current_user.entries.where(id: params[:group]).first
if entry.present?
return redirect_to day_entry_path(year: entry.date.year, month: entry.date.month, day: entry.date.day)
else
flash[:alert] = "No entry found."
return redirect_to entries_path
end
end
@title = "Entries from #{params[:group]}"
elsif params[:format] != "json"
@entries = current_user.entries.includes(:inspiration)
@title = 'All Entries'
else
flash[:alert] = "Page not accessible."
redirect_to root_path and return
end

if @entries.present?
Expand Down Expand Up @@ -323,6 +325,8 @@ def set_entry
else
@entry = current_user.entries.includes(:inspiration).where(id: params[:id]).first
end
rescue
flash[:alert] = "Entry not found."
end

def require_entry_permission
Expand Down
2 changes: 1 addition & 1 deletion app/views/entries/calendar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
:javascript
$(document).ready(function() {
$('#calendar').fullCalendar('gotoDate', "#{params[:day]}");
});
});

0 comments on commit 08d832b

Please sign in to comment.