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

Fix posts

parent 3765acd6
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro ...@@ -7,6 +7,7 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro
has_scope :for_search_term has_scope :for_search_term
has_scope :for_diploma has_scope :for_diploma
has_scope :for_school
def index def index
@programs = apply_scopes(@programs).ordered_by_name.page(params[:page]) @programs = apply_scopes(@programs).ordered_by_name.page(params[:page])
......
...@@ -84,13 +84,18 @@ class Communication::Website::Post < ApplicationRecord ...@@ -84,13 +84,18 @@ class Communication::Website::Post < ApplicationRecord
", term: "%#{sanitize_sql_like(term)}%") ", term: "%#{sanitize_sql_like(term)}%")
} }
# Is it used?
def path def path
# used in menu_item#static_target # used in menu_item#static_target
"/#{published_at.strftime "%Y/%m/%d"}/#{slug}" "/#{published_at.strftime "%Y/%m/%d"}/#{slug}"
end end
def git_path(website) 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 end
def template_static def template_static
......
...@@ -184,6 +184,11 @@ class Education::Program < ApplicationRecord ...@@ -184,6 +184,11 @@ class Education::Program < ApplicationRecord
", term: "%#{sanitize_sql_like(term)}%") ", term: "%#{sanitize_sql_like(term)}%")
} }
scope :for_diploma, -> (diploma_id) { where(diploma_id: diploma_id) } 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 def to_s
"#{name}" "#{name}"
......
...@@ -9,6 +9,12 @@ module Filters ...@@ -9,6 +9,12 @@ module Filters
'filters.attributes.element', 'filters.attributes.element',
element: Education::Diploma.model_name.human.downcase 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 end
end end
...@@ -6,4 +6,5 @@ ...@@ -6,4 +6,5 @@
- slug: <%= post.slug %> - slug: <%= post.slug %>
path: <%= post.path %> path: <%= post.path %>
url: <%= post.url %> url: <%= post.url %>
file: <%= post.hugo_path %>
<% end %> <% 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