You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
756 B
16 lines
756 B
module Api
|
|
module V1
|
|
class CalendarController < BaseController
|
|
def index
|
|
from = Date.iso8601(params.fetch(:from, Date.current.beginning_of_month.to_s))
|
|
to = Date.iso8601(params.fetch(:to, Date.current.end_of_month.to_s))
|
|
scope = current_user.entries.where(date: from..to).order(:date, :start_time)
|
|
scope = scope.where(praktikums_typ: params[:typ]) if params[:typ].present?
|
|
scope = scope.where(entry_art: params[:art]) if params[:art].present?
|
|
render json: scope.as_json(only: %i[id date hours minutes praktikums_typ entry_art beschreibung start_time end_time])
|
|
rescue Date::Error
|
|
render json: { error: "Ungültiger Datumsbereich" }, status: :bad_request
|
|
end
|
|
end
|
|
end
|
|
end
|