diff --git a/app/controllers/admin/education/programs_controller.rb b/app/controllers/admin/education/programs_controller.rb index d934aee75f0c2f0ec38103e27d18cc6857a8916b..af4c1e463bcab4bdd0da052a704535f0aa795b4b 100644 --- a/app/controllers/admin/education/programs_controller.rb +++ b/app/controllers/admin/education/programs_controller.rb @@ -7,6 +7,7 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro has_scope :for_search_term has_scope :for_diploma + has_scope :for_school def index @programs = apply_scopes(@programs).ordered_by_name.page(params[:page]) diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 5f9cae573da89c6c0b86ba56391f696dd6c9d383..53e3967265e58aaaea7a6c873dc594f419d2af42 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -84,13 +84,18 @@ class Communication::Website::Post < ApplicationRecord ", term: "%#{sanitize_sql_like(term)}%") } + # Is it used? def path # used in menu_item#static_target "/#{published_at.strftime "%Y/%m/%d"}/#{slug}" end def git_path(website) - "content/posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" if published && published_at + "content/posts/#{hugo_path}.html" if published && published_at + end + + def hugo_path + "#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}" end def template_static diff --git a/app/models/education/program.rb b/app/models/education/program.rb index ec001f173341c6854b6033dcdfb165c6ff764bff..a645756376a1e916c14e84cb7d2e89f0af00deae 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -184,6 +184,11 @@ class Education::Program < ApplicationRecord ", term: "%#{sanitize_sql_like(term)}%") } scope :for_diploma, -> (diploma_id) { where(diploma_id: diploma_id) } + scope :for_school, -> (school_id) { + joins(:schools) + .where(education_schools: { id: school_id }) + .distinct + } def to_s "#{name}" diff --git a/app/services/filters/admin/education/programs.rb b/app/services/filters/admin/education/programs.rb index e6eb599cb12ec41ddc99c510e890020d8c19375f..fc15d2de188c16aafe0d9c692150f15305e752c5 100644 --- a/app/services/filters/admin/education/programs.rb +++ b/app/services/filters/admin/education/programs.rb @@ -9,6 +9,12 @@ module Filters 'filters.attributes.element', element: Education::Diploma.model_name.human.downcase ) + add :for_school, + user.university.education_schools, + I18n.t( + 'filters.attributes.element', + element: Education::School.model_name.human.downcase + ) end end end diff --git a/app/views/admin/communication/blocks/templates/posts/_static.html.erb b/app/views/admin/communication/blocks/templates/posts/_static.html.erb index 938875fd76d408a14434fd005fc7bce7b605d762..2a06e65264fa0e2ea94344aadf03ddbcc3d77559 100644 --- a/app/views/admin/communication/blocks/templates/posts/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/posts/_static.html.erb @@ -6,4 +6,5 @@ - slug: <%= post.slug %> path: <%= post.path %> url: <%= post.url %> + file: <%= post.hugo_path %> <% end %>