Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n portfolio #2142

Merged
merged 11 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Admin::Communication::Websites::Agenda::CategoriesController < Admin::Communication::Websites::Agenda::ApplicationController
load_and_authorize_resource class: 'Communication::Website::Agenda::Category',
load_and_authorize_resource class: 'Communication::Website::Agenda::Category',
through: :website,
through_association: :agenda_categories

Expand All @@ -19,11 +19,6 @@ def show
breadcrumb
end

def static
@about = @category
render_as_plain_text
end

def new
breadcrumb
end
Expand Down Expand Up @@ -68,7 +63,7 @@ def categories_class

def breadcrumb
super
add_breadcrumb Communication::Website::Agenda::Category.model_name.human(count: 2),
add_breadcrumb categories_class.model_name.human(count: 2),
admin_communication_website_agenda_categories_path
breadcrumb_for @category
end
Expand All @@ -80,7 +75,7 @@ def category_params
localizations_attributes: [
:id, :language_id,
:name, :meta_description, :summary, :slug,
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit
]
)
.merge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def breadcrumb

def categories
@website.agenda_categories
.for_language(current_language)
.tmp_original # TODO L10N : Remove tmp_original
.ordered
end

Expand All @@ -107,7 +107,7 @@ def event_params
category_ids: [],
localizations_attributes: [
:id, :title, :subtitle, :meta_description, :summary, :text,
:published, :published_at, :slug,
:published, :published_at, :slug,
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit,
:shared_image, :shared_image_delete, :shared_image_infos,
:language_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
class Admin::Communication::Websites::Portfolio::CategoriesController < Admin::Communication::Websites::Portfolio::ApplicationController
load_and_authorize_resource class: 'Communication::Website::Portfolio::Category',
load_and_authorize_resource class: 'Communication::Website::Portfolio::Category',
through: :website,
through_association: :portfolio_categories

include Admin::Localizable
include Admin::ActAsCategories
include Admin::HasStaticAction
include Admin::Localizable

def index
@root_categories = categories.root
@root_categories = categories.root.tmp_original # TODO L10N : To remove
@categories_class = categories_class
@feature_nav = 'navigation/admin/communication/website/portfolio'
breadcrumb
Expand All @@ -18,11 +19,6 @@ def show
breadcrumb
end

def static
@about = @category
render_as_plain_text
end

def new
breadcrumb
end
Expand All @@ -36,7 +32,7 @@ def create
@category.website = @website
@category.add_photo_import params[:photo_import]
if @category.save_and_sync
redirect_to admin_communication_website_portfolio_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s)
redirect_to admin_communication_website_portfolio_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
else
breadcrumb
render :new, status: :unprocessable_entity
Expand All @@ -46,7 +42,7 @@ def create
def update
@category.add_photo_import params[:photo_import]
if @category.update_and_sync(category_params)
redirect_to admin_communication_website_portfolio_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s)
redirect_to admin_communication_website_portfolio_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
breadcrumb
add_breadcrumb t('edit')
Expand All @@ -56,7 +52,7 @@ def update

def destroy
@category.destroy
redirect_to admin_communication_website_portfolio_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s)
redirect_to admin_communication_website_portfolio_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s_in(current_language))
end

protected
Expand All @@ -75,9 +71,12 @@ def breadcrumb
def category_params
params.require(:communication_website_portfolio_category)
.permit(
:name, :meta_description, :summary, :slug,
:is_taxonomy,
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit
:is_taxonomy, :parent_id,
localizations_attributes: [
:id, :language_id,
:name, :meta_description, :summary, :slug,
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit
]
)
.merge(
university_id: current_university.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Admin::Communication::Websites::Portfolio::ProjectsController < Admin::Com
load_and_authorize_resource class: Communication::Website::Portfolio::Project,
through: :website

include Admin::HasStaticAction
include Admin::Localizable

# Allow to override the default load_filters from Admin::Filterable
Expand All @@ -11,7 +12,7 @@ class Admin::Communication::Websites::Portfolio::ProjectsController < Admin::Com
has_scope :for_category

def index
@projects = apply_scopes(@projects).for_language(current_language)
@projects = apply_scopes(@projects).tmp_original # TODO L10N : To remove
.ordered
.page(params[:page])
@feature_nav = 'navigation/admin/communication/website/portfolio'
Expand All @@ -29,11 +30,6 @@ def show
breadcrumb
end

def static
@about = @project
render_as_plain_text
end

def new
@categories = categories
breadcrumb
Expand All @@ -50,7 +46,7 @@ def create
@project.add_photo_import params[:photo_import]
if @project.save_and_sync
redirect_to admin_communication_website_portfolio_project_path(@project),
notice: t('admin.successfully_created_html', model: @project.to_s)
notice: t('admin.successfully_created_html', model: @project.to_s_in(current_language))
else
@categories = categories
breadcrumb
Expand All @@ -62,7 +58,7 @@ def update
@project.add_photo_import params[:photo_import]
if @project.update_and_sync(project_params)
redirect_to admin_communication_website_portfolio_project_path(@project),
notice: t('admin.successfully_updated_html', model: @project.to_s)
notice: t('admin.successfully_updated_html', model: @project.to_s_in(current_language))
else
@categories = categories
breadcrumb
Expand All @@ -73,13 +69,13 @@ def update

def duplicate
redirect_to [:admin, @project.duplicate],
notice: t('admin.successfully_duplicated_html', model: @project.to_s)
notice: t('admin.successfully_duplicated_html', model: @project.to_s_in(current_language))
end

def destroy
@project.destroy
redirect_to admin_communication_website_portfolio_projects_url,
notice: t('admin.successfully_destroyed_html', model: @project.to_s)
notice: t('admin.successfully_destroyed_html', model: @project.to_s_in(current_language))
end
protected

Expand All @@ -90,7 +86,7 @@ def breadcrumb

def categories
@website.portfolio_categories
.for_language(current_language)
.tmp_original # TODO L10N : Remove tmp_original
.ordered
end

Expand All @@ -105,10 +101,15 @@ def load_filters
def project_params
params.require(:communication_website_portfolio_project)
.permit(
:title, :meta_description, :summary, :published, :slug, :year,
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit,
:shared_image, :shared_image_delete,
category_ids: []
:year,
category_ids: [],
localizations_attributes: [
:id, :title, :meta_description, :summary,
:published, :published_at, :slug,
:featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit,
:shared_image, :shared_image_delete, :shared_image_infos,
:language_id
]
)
.merge(
university_id: current_university.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Communication::Website::Agenda::Category::Localization < ApplicationRecord
belongs_to :website,
class_name: 'Communication::Website',
foreign_key: :communication_website_id

validates :name, presence: true

before_validation :set_communication_website_id
Expand All @@ -67,15 +67,15 @@ def dependencies
def to_s
"#{name}"
end

protected

def slug_unavailable?(slug)
self.class
.unscoped
.where(
communication_website_id: self.communication_website_id,
language_id: language_id,
communication_website_id: self.communication_website_id,
language_id: language_id,
slug: slug
)
.where.not(id: self.id)
Expand Down
8 changes: 6 additions & 2 deletions app/models/communication/website/agenda/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@
class Communication::Website::Agenda::Event < ApplicationRecord
include AsDirectObject
include Contentful # TODO L10N : To remove
include Initials
include Sanitizable
include Shareable # TODO L10N : To remove
include Localizable
include WithAccessibility
include WithBlobs # TODO L10N : To remove
include WithDuplication
include WithFeaturedImage # TODO L10N : To remove
Expand Down Expand Up @@ -91,6 +89,7 @@ class Communication::Website::Agenda::Event < ApplicationRecord
)
.distinct
}
# TODO L10N : To adapt
scope :for_search_term, -> (term) {
where("
unaccent(communication_website_agenda_events.meta_description) ILIKE unaccent(:term) OR
Expand All @@ -110,6 +109,11 @@ def references
abouts_with_agenda_block
end

# TODO L10N : to remove
def translate_other_attachments(translation)
translate_attachment(translation, :shared_image) if shared_image.attached?
end

protected

def abouts_with_agenda_block
Expand Down
4 changes: 2 additions & 2 deletions app/models/communication/website/agenda/event/localization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class Communication::Website::Agenda::Event::Localization < ApplicationRecord

alias :event :about

delegate :archive?,
delegate :archive?,
:from_day, :from_hour,
:to_day, :to_hour,
:time_zone,
to: :event

has_summernote :text

validates :title, presence: true

before_validation :set_communication_website_id
Expand Down
4 changes: 2 additions & 2 deletions app/models/communication/website/permalink/with_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ module Communication::Website::Permalink::WithMapping
"Communication::Website::Agenda::Event::Localization" => Communication::Website::Permalink::Agenda::Event,
"Communication::Website::Agenda::Category::Localization" => Communication::Website::Permalink::Agenda::Category,
"Communication::Website::Page::Localization" => Communication::Website::Permalink::Page,
# "Communication::Website::Portfolio::Project::Localization" => Communication::Website::Permalink::Portfolio::Project,
# "Communication::Website::Portfolio::Category::Localization" => Communication::Website::Permalink::Portfolio::Category,
"Communication::Website::Portfolio::Project::Localization" => Communication::Website::Permalink::Portfolio::Project,
"Communication::Website::Portfolio::Category::Localization" => Communication::Website::Permalink::Portfolio::Category,
"Communication::Website::Post::Localization" => Communication::Website::Permalink::Post,
"Communication::Website::Post::Category::Localization" => Communication::Website::Permalink::Category,
# "Education::Diploma::Localization" => Communication::Website::Permalink::Diploma,
Expand Down
Loading
Loading