Skip to content
Snippets Groups Projects
Unverified Commit 43a468ad authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

author translation

parent 0896f53a
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,8 @@ class Admin::Communication::Websites::PostsController < Admin::Communication::We ...@@ -14,7 +14,8 @@ class Admin::Communication::Websites::PostsController < Admin::Communication::We
def index def index
@posts = apply_scopes(@posts).where(language_id: current_website_language.id).ordered.page params[:page] @posts = apply_scopes(@posts).where(language_id: current_website_language.id).ordered.page params[:page]
@authors = @website.authors.accessible_by(current_ability) @authors = @website.authors.where(language_id: current_website_language.id)
.accessible_by(current_ability)
.ordered .ordered
.page(params[:authors_page]) .page(params[:authors_page])
@root_categories = @website.categories.where(language_id: current_website_language.id).root.ordered @root_categories = @website.categories.where(language_id: current_website_language.id).root.ordered
...@@ -50,7 +51,9 @@ class Admin::Communication::Websites::PostsController < Admin::Communication::We ...@@ -50,7 +51,9 @@ class Admin::Communication::Websites::PostsController < Admin::Communication::We
def new def new
@post.website = @website @post.website = @website
@post.author_id = current_user.person&.id if current_user.person.present?
@post.author_id = current_user.person.find_or_translate!(current_website_language).id
end
breadcrumb breadcrumb
end end
......
...@@ -187,5 +187,6 @@ class Communication::Website::Post < ApplicationRecord ...@@ -187,5 +187,6 @@ class Communication::Website::Post < ApplicationRecord
translated_category = category.find_or_translate!(translation.language) translated_category = category.find_or_translate!(translation.language)
translation.categories << translated_category translation.categories << translated_category
end end
translation.update(author_id: author.find_or_translate!(translation.language).id) if author_id.present?
end end
end end
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
navigation.each_with_index do |object, index| navigation.each_with_index do |object, index|
next unless object[:ability] next unless object[:ability]
active = index.zero? ? object[:path] == request.path active = index.zero? ? controller_name == "websites" && action_name == "show"
: object[:path].in?(request.path) : object[:path].in?(request.path)
%> %>
<a class="list-group-item bg-transparent px-0 list-group-item-action<%= ' active' if active %>" href="<%= object[:path] %>"> <a class="list-group-item bg-transparent px-0 list-group-item-action<%= ' active' if active %>" href="<%= object[:path] %>">
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<% if @website.languages.many? %> <% if @website.languages.many? %>
<select class="form-control form-select mt-5" onchange="if (this.value) window.location.href=this.value"> <select class="form-control form-select mt-5" onchange="if (this.value) window.location.href=this.value">
<% @website.languages.each do |language| %> <% @website.languages.each do |language| %>
<% <%
label = I18n.t(language.iso_code, scope: :languages) label = I18n.t(language.iso_code, scope: :languages)
path = url_for request.params.merge(lang: language.iso_code) path = url_for request.params.merge(lang: language.iso_code)
selected = current_website_language == language selected = current_website_language == language
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<%= f.input :published_at, html5: true, as: :date %> <%= f.input :published_at, html5: true, as: :date %>
<% end %> <% end %>
<%= f.association :author, <%= f.association :author,
collection: current_university.people.where(language_id: current_university.default_language_id).ordered, collection: current_university.people.where(language_id: current_website_language.id).ordered,
label_method: :to_s_alphabetical %> label_method: :to_s_alphabetical %>
<%= f.input :slug, <%= f.input :slug,
as: :string, as: :string,
......
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