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
def index
@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
.page(params[:authors_page])
@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
def new
@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
end
......
......@@ -187,5 +187,6 @@ class Communication::Website::Post < ApplicationRecord
translated_category = category.find_or_translate!(translation.language)
translation.categories << translated_category
end
translation.update(author_id: author.find_or_translate!(translation.language).id) if author_id.present?
end
end
......@@ -38,7 +38,7 @@
navigation.each_with_index do |object, index|
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)
%>
<a class="list-group-item bg-transparent px-0 list-group-item-action<%= ' active' if active %>" href="<%= object[:path] %>">
......@@ -53,7 +53,7 @@
<% if @website.languages.many? %>
<select class="form-control form-select mt-5" onchange="if (this.value) window.location.href=this.value">
<% @website.languages.each do |language| %>
<%
<%
label = I18n.t(language.iso_code, scope: :languages)
path = url_for request.params.merge(lang: language.iso_code)
selected = current_website_language == language
......
......@@ -40,7 +40,7 @@
<%= f.input :published_at, html5: true, as: :date %>
<% end %>
<%= 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 %>
<%= f.input :slug,
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