scinote-web/app/controllers/dashboard/calendars_controller.rb

40 lines
1.8 KiB
Ruby
Raw Normal View History

2020-02-21 00:02:38 +08:00
# frozen_string_literal: true
module Dashboard
class CalendarsController < ApplicationController
2020-02-26 00:19:11 +08:00
include IconsHelper
2020-05-08 17:56:29 +08:00
include MyModulesHelper
2020-02-26 00:19:11 +08:00
2020-02-21 00:02:38 +08:00
def show
date = params[:date].in_time_zone(current_user.time_zone)
start_date = date.at_beginning_of_month.utc - 8.days
end_date = date.at_end_of_month.utc + 15.days
due_dates = current_user.my_modules.readable_by_user(current_user).active.uncomplete
.joins(experiment: :project)
2020-03-03 23:10:52 +08:00
.where(experiments: { archived: false })
.where(projects: { archived: false })
.where('my_modules.due_date > ? AND my_modules.due_date < ?', start_date, end_date)
2020-03-03 23:10:52 +08:00
.joins(:protocols).where(protocols: { team_id: current_team.id })
.pluck(:due_date)
render json: { events: due_dates.map { |i| { date: i.to_date } } }
2020-02-21 00:02:38 +08:00
end
def day
date = params[:date].in_time_zone(current_user.time_zone)
start_date = date.utc
end_date = date.end_of_day.utc
my_modules = current_user.my_modules.readable_by_user(current_user).active.uncomplete
.joins(experiment: :project)
2020-03-03 23:10:52 +08:00
.where(experiments: { archived: false })
.where(projects: { archived: false })
.where('my_modules.due_date > ? AND my_modules.due_date < ?', start_date, end_date)
2020-03-03 23:10:52 +08:00
.where(projects: { team_id: current_team.id })
2020-02-21 00:02:38 +08:00
render json: {
html: render_to_string(partial: 'shared/my_modules_list_partial',
locals: { my_modules: my_modules },
formats: :html)
2020-02-21 00:02:38 +08:00
}
end
end
end