Skip to content
Snippets Groups Projects
Commit 4575f399 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Fix posts

parent 3765acd6
No related merge requests found
......@@ -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])
......
......@@ -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
......
......@@ -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}"
......
......@@ -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
......@@ -6,4 +6,5 @@
- slug: <%= post.slug %>
path: <%= post.path %>
url: <%= post.url %>
file: <%= post.hugo_path %>
<% end %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment