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.
37 lines
991 B
37 lines
991 B
module Api |
|
class JurisprudencesController < BaseController |
|
include JurisprudenceSearch |
|
|
|
authorize_resource :jurisprudence, class: "Cdao::Jurisprudence", only: %i[index] |
|
|
|
def index |
|
search = jurisprudence_search(search_params) |
|
|
|
@jurisprudences = search.results |
|
|
|
respond_with @jurisprudences |
|
end |
|
|
|
def show |
|
respond_with @jurisprudence |
|
end |
|
|
|
def years |
|
authorize! :index, Cdao::Jurisprudence |
|
|
|
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900" |
|
end_year = Cdao::Jurisprudence.order(year: :desc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year |
|
@years = (start_year..end_year).entries.reverse |
|
|
|
respond_with @years |
|
end |
|
|
|
private |
|
|
|
def search_params |
|
params.permit(:reference_number, :title, :short_title, :year, :citation_finder, |
|
:q, :page, :per_page, |
|
exclude_ids: []) |
|
end |
|
end |
|
end
|
|
|