Skip to content

Commit

Permalink
clean controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
SebouChu committed Jan 27, 2025
1 parent 5c010df commit 4ecbbe8
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def edit
end

def create
@l10n.add_photo_import params[:photo_import]
if @post.save
redirect_to admin_communication_extranet_post_path(@post),
notice: t('admin.successfully_created_html', model: @post.to_s_in(current_language))
Expand All @@ -46,8 +45,6 @@ def create

def update
if @post.update(post_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_communication_extranet_post_path(@post),
notice: t('admin.successfully_updated_html', model: @post.to_s_in(current_language))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def edit
end

def create
@l10n.add_photo_import params[:photo_import]
if @category.save
redirect_to admin_communication_media_category_path(@category),
notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
Expand All @@ -45,8 +44,6 @@ def create

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_communication_media_category_path(@category),
notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def edit

def create
if @collection.save
@l10n.add_photo_import params[:photo_import]
redirect_to admin_communication_media_collection_path(@collection),
notice: t('admin.successfully_created_html', model: @collection.to_s_in(current_language))
else
Expand All @@ -39,8 +38,6 @@ def create

def update
if @collection.update(collection_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_communication_media_collection_path(@collection),
notice: t('admin.successfully_updated_html', model: @collection.to_s_in(current_language))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@ def edit

def create
@category.website = @website
@l10n.add_photo_import params[:photo_import]
if @category.save_and_sync
redirect_to admin_communication_website_agenda_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
redirect_to admin_communication_website_agenda_category_path(@category),
notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
else
breadcrumb
render :new, status: :unprocessable_entity
end
end

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@category.sync_with_git
redirect_to admin_communication_website_agenda_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
if @category.update_and_sync(category_params)
redirect_to admin_communication_website_agenda_category_path(@category),
notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
load_invalid_localization
breadcrumb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def edit
def create
@event.website = @website
@event.created_by = current_user
@l10n.add_photo_import params[:photo_import]
if @event.save_and_sync
redirect_to admin_communication_website_agenda_event_path(@event),
notice: t('admin.successfully_created_html', model: @event.to_s_in(current_language))
Expand All @@ -50,10 +49,7 @@ def create
end

def update
if @event.update(event_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@event.sync_with_git
if @event.update_and_sync(event_params)
redirect_to admin_communication_website_agenda_event_path(@event),
notice: t('admin.successfully_updated_html', model: @event.to_s_in(current_language))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@ def edit

def create
@category.website = @website
@l10n.add_photo_import params[:photo_import]
if @category.save_and_sync
redirect_to admin_communication_website_page_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
redirect_to admin_communication_website_page_category_path(@category),
notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
else
breadcrumb
render :new, status: :unprocessable_entity
end
end

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@category.sync_with_git
redirect_to admin_communication_website_page_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
if @category.update_and_sync(category_params)
redirect_to admin_communication_website_page_category_path(@category),
notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
load_invalid_localization
breadcrumb
Expand Down
12 changes: 5 additions & 7 deletions app/controllers/admin/communication/websites/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def edit

def create
@page.website = @website
@l10n.add_photo_import params[:photo_import]
if @page.save_and_sync
redirect_to admin_communication_website_page_path(@page), notice: t('admin.successfully_created_html', model: @page.to_s_in(current_language))
redirect_to admin_communication_website_page_path(@page),
notice: t('admin.successfully_created_html', model: @page.to_s_in(current_language))
else
@categories = categories
breadcrumb
Expand All @@ -109,11 +109,9 @@ def create
end

def update
if @page.update(page_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@page.sync_with_git
redirect_to admin_communication_website_page_path(@page), notice: t('admin.successfully_updated_html', model: @page.to_s_in(current_language))
if @page.update_and_sync(page_params)
redirect_to admin_communication_website_page_path(@page),
notice: t('admin.successfully_updated_html', model: @page.to_s_in(current_language))
else
load_invalid_localization
@categories = categories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@ def edit

def create
@category.website = @website
@l10n.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_in(current_language))
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
end
end

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@category.sync_with_git
redirect_to admin_communication_website_portfolio_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
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_in(current_language))
else
load_invalid_localization
breadcrumb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def edit
def create
@project.website = @website
@project.created_by = current_user
@l10n.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_in(current_language))
Expand All @@ -50,10 +49,7 @@ def create
end

def update
if @project.update(project_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@project.sync_with_git
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_in(current_language))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ def edit

def create
@category.website = @website
@l10n.add_photo_import params[:photo_import]
if @category.save_and_sync
redirect_to admin_communication_website_post_category_path(@category), notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
redirect_to admin_communication_website_post_category_path(@category),
notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
else
breadcrumb
render :new, status: :unprocessable_entity
end
end

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@category.sync_with_git
redirect_to admin_communication_website_post_category_path(@category), notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
if @category.update_and_sync(category_params)
redirect_to admin_communication_website_post_category_path(@category),
notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
load_invalid_localization
breadcrumb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def edit
def create
@post.website = @website
if @post.save
@l10n.add_photo_import params[:photo_import]
@post.sync_with_git
redirect_to admin_communication_website_post_path(@post),
notice: t('admin.successfully_created_html', model: @post.to_s_in(current_language))
Expand All @@ -70,10 +69,7 @@ def create
end

def update
if @post.update(post_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@post.sync_with_git
if @post.update_and_sync(post_params)
redirect_to admin_communication_website_post_path(@post),
notice: t('admin.successfully_updated_html', model: @post.to_s_in(current_language))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def edit
end

def create
@l10n.add_photo_import params[:photo_import]
if @category.save
redirect_to admin_education_program_category_path(@category),
notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
Expand All @@ -47,8 +46,6 @@ def create

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_education_program_category_path(@category),
notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/admin/education/programs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def edit
end

def create
@l10n.add_photo_import params[:photo_import]
if @program.save
redirect_to [:admin, @program],
notice: t('admin.successfully_created_html', model: @program.to_s_in(current_language))
Expand All @@ -68,9 +67,6 @@ def create
def update
load_part
if @program.update(program_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@program.touch # to ensure it send the photo_import picture
redirect_to after_update_path,
notice: t('admin.successfully_updated_html', model: @program.to_s_in(current_language))
else
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/admin/research/journals/volumes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ def edit
end

def create
@l10n.add_photo_import params[:photo_import]
@volume.assign_attributes(
journal: @journal
)
@volume.journal = @journal
if @volume.save
redirect_to admin_research_journal_volume_path(@volume), notice: t('admin.successfully_created_html', model: @volume.to_s_in(current_language))
else
Expand All @@ -49,9 +46,6 @@ def create

def update
if @volume.update(volume_params)
load_localization
@l10n.add_photo_import params[:photo_import]
@volume.touch # to ensure it send the photo_import picture
redirect_to admin_research_journal_volume_path(@volume), notice: t('admin.successfully_updated_html', model: @volume.to_s_in(current_language))
else
load_invalid_localization
Expand All @@ -77,7 +71,7 @@ def breadcrumb
def volume_params
params.require(:research_journal_volume)
.permit(
:number,
:number,
localizations_attributes: [
:id, :language_id,
:title, :slug, :keywords, :published, :published_at, :meta_description, :summary, :text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def edit
end

def create
@l10n.add_photo_import params[:photo_import]
if @category.save
redirect_to admin_university_organization_category_path(@category),
notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
Expand All @@ -44,8 +43,6 @@ def create

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_university_organization_category_path(@category),
notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/admin/university/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def edit

def create
if @organization.save
@l10n.add_photo_import params[:photo_import]
redirect_to admin_university_organization_path(@organization),
notice: t('admin.successfully_created_html', model: @organization.to_s_in(current_language))
else
Expand All @@ -59,8 +58,6 @@ def create

def update
if @organization.update(organization_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_university_organization_path(@organization),
notice: t('admin.successfully_updated_html', model: @organization.to_s_in(current_language))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def edit
end

def create
@l10n.add_photo_import params[:photo_import]
if @category.save
redirect_to admin_university_person_category_path(@category),
notice: t('admin.successfully_created_html', model: @category.to_s_in(current_language))
Expand All @@ -46,8 +45,6 @@ def create

def update
if @category.update(category_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_university_person_category_path(@category),
notice: t('admin.successfully_updated_html', model: @category.to_s_in(current_language))
else
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/admin/university/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def edit

def create
if @person.save
@l10n.add_photo_import params[:photo_import]
redirect_to admin_university_person_path(@person),
notice: t('admin.successfully_created_html', model: @person.to_s_in(current_language))
else
Expand All @@ -66,8 +65,6 @@ def create

def update
if @person.update(person_params)
load_localization
@l10n.add_photo_import params[:photo_import]
redirect_to admin_university_person_path(@person),
notice: t('admin.successfully_updated_html', model: @person.to_s_in(current_language))
else
Expand Down
Loading

0 comments on commit 4ecbbe8

Please sign in to comment.