-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature * wip * refactor features in traits * add controllers * views wip * wip * projects ! * done! * fix
- Loading branch information
1 parent
b3d1876
commit faebcdd
Showing
53 changed files
with
1,186 additions
and
40 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
app/controllers/admin/communication/websites/portfolio/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Admin::Communication::Websites::Portfolio::ApplicationController < Admin::Communication::Websites::ApplicationController | ||
|
||
protected | ||
|
||
def breadcrumb | ||
super | ||
add_breadcrumb Communication::Website::Portfolio.model_name.human(count: 2), | ||
admin_communication_website_portfolio_projects_path | ||
end | ||
end |
85 changes: 85 additions & 0 deletions
85
app/controllers/admin/communication/websites/portfolio/categories_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
class Admin::Communication::Websites::Portfolio::CategoriesController < Admin::Communication::Websites::Portfolio::ApplicationController | ||
load_and_authorize_resource class: 'Communication::Website::Portfolio::Category', | ||
through: :website, | ||
through_association: :portfolio_categories | ||
|
||
include Admin::Translatable | ||
include Admin::Categorizable | ||
|
||
def index | ||
@root_categories = categories.root | ||
@categories_class = categories_class | ||
breadcrumb | ||
end | ||
|
||
def show | ||
@projects = @category.projects.ordered.page(params[:page]) | ||
breadcrumb | ||
end | ||
|
||
def static | ||
@about = @category | ||
render_as_plain_text | ||
end | ||
|
||
def new | ||
breadcrumb | ||
end | ||
|
||
def edit | ||
breadcrumb | ||
add_breadcrumb t('edit') | ||
end | ||
|
||
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) | ||
else | ||
breadcrumb | ||
render :new, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
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) | ||
else | ||
breadcrumb | ||
add_breadcrumb t('edit') | ||
render :edit, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
@category.destroy | ||
redirect_to admin_communication_website_portfolio_categories_url, notice: t('admin.successfully_destroyed_html', model: @category.to_s) | ||
end | ||
|
||
protected | ||
|
||
def categories_class | ||
Communication::Website::Portfolio::Category | ||
end | ||
|
||
def breadcrumb | ||
super | ||
add_breadcrumb categories_class.model_name.human(count: 2), | ||
admin_communication_website_portfolio_categories_path | ||
breadcrumb_for @category | ||
end | ||
|
||
def category_params | ||
params.require(:communication_website_portfolio_category) | ||
.permit( | ||
: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, | ||
language_id: current_website_language.id | ||
) | ||
end | ||
end |
104 changes: 104 additions & 0 deletions
104
app/controllers/admin/communication/websites/portfolio/projects_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
class Admin::Communication::Websites::Portfolio::ProjectsController < Admin::Communication::Websites::Portfolio::ApplicationController | ||
load_and_authorize_resource class: Communication::Website::Portfolio::Project, | ||
through: :website | ||
|
||
include Admin::Translatable | ||
|
||
def index | ||
@projects = apply_scopes(@projects).for_language(current_website_language) | ||
.ordered | ||
.page(params[:page]) | ||
@root_categories = categories.root | ||
@categories_class = Communication::Website::Portfolio::Category | ||
breadcrumb | ||
end | ||
|
||
def publish | ||
@project.published = true | ||
@project.save_and_sync | ||
redirect_back fallback_location: admin_communication_website_portfolio_project_path(@project), | ||
notice: t('admin.communication.website.publish.notice') | ||
end | ||
|
||
def show | ||
breadcrumb | ||
end | ||
|
||
def static | ||
@about = @project | ||
render_as_plain_text | ||
end | ||
|
||
def new | ||
@categories = categories | ||
breadcrumb | ||
end | ||
|
||
def edit | ||
@categories = categories | ||
breadcrumb | ||
add_breadcrumb t('edit') | ||
end | ||
|
||
def create | ||
@project.website = @website | ||
@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) | ||
else | ||
@categories = categories | ||
breadcrumb | ||
render :new, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
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) | ||
else | ||
@categories = categories | ||
breadcrumb | ||
add_breadcrumb t('edit') | ||
render :edit, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def duplicate | ||
redirect_to [:admin, @project.duplicate], | ||
notice: t('admin.successfully_duplicated_html', model: @project.to_s) | ||
end | ||
|
||
def destroy | ||
@project.destroy | ||
redirect_to admin_communication_website_portolio_projects_url, | ||
notice: t('admin.successfully_destroyed_html', model: @project.to_s) | ||
end | ||
protected | ||
|
||
def breadcrumb | ||
super | ||
breadcrumb_for @project | ||
end | ||
|
||
def categories | ||
@website.portfolio_categories | ||
.for_language(current_website_language) | ||
.ordered | ||
end | ||
|
||
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, | ||
category_ids: [] | ||
) | ||
.merge( | ||
university_id: current_university.id, | ||
language_id: current_website_language.id | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Communication::Website::FeatureAgenda | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_many :agenda_events, | ||
class_name: "Communication::Website::Agenda::Event", | ||
foreign_key: :communication_website_id | ||
alias :events :agenda_events | ||
|
||
has_many :agenda_categories, | ||
class_name: 'Communication::Website::Agenda::Category', | ||
foreign_key: :communication_website_id, | ||
dependent: :destroy | ||
end | ||
|
||
def has_agenda_events? | ||
agenda_events.published.any? | ||
end | ||
|
||
def has_agenda_categories? | ||
agenda_categories.any? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Communication::Website::FeatureBlog | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_many :posts, | ||
foreign_key: :communication_website_id, | ||
dependent: :destroy | ||
|
||
has_many :authors, -> { distinct }, through: :posts | ||
|
||
has_many :post_categories, | ||
class_name: 'Communication::Website::Post::Category', | ||
foreign_key: :communication_website_id, | ||
dependent: :destroy | ||
end | ||
|
||
def has_blog_posts? | ||
posts.published.any? | ||
end | ||
|
||
def has_blog_categories? | ||
post_categories.any? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Communication::Website::FeaturePortfolio | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_many :portfolio_projects, | ||
class_name: "Communication::Website::Portfolio::Project", | ||
foreign_key: :communication_website_id | ||
alias :projects :portfolio_projects | ||
|
||
has_many :portfolio_categories, | ||
class_name: 'Communication::Website::Portfolio::Category', | ||
foreign_key: :communication_website_id, | ||
dependent: :destroy | ||
alias :projects_categories :portfolio_categories | ||
end | ||
|
||
def has_portfolio_projects? | ||
projects.published.any? | ||
end | ||
|
||
def has_portfolio_categories? | ||
portfolio_categories.any? | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
app/models/communication/website/page/communication_portfolio.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Communication::Website::Page::CommunicationPortfolio < Communication::Website::Page | ||
|
||
def editable_width? | ||
false | ||
end | ||
|
||
def full_width_by_default? | ||
true | ||
end | ||
|
||
def is_necessary_for_website? | ||
website.feature_portfolio | ||
end | ||
|
||
def dependencies | ||
super + | ||
[website.config_default_languages] + | ||
website.projects | ||
end | ||
|
||
def git_path_relative | ||
'projects/_index.html' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/models/communication/website/permalink/portfolio/category.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Communication::Website::Permalink::Portfolio::Category < Communication::Website::Permalink | ||
def self.required_in_config?(website) | ||
website.feature_portfolio | ||
end | ||
|
||
def self.static_config_key | ||
:projects_categories | ||
end | ||
|
||
# /projets/:slug/ | ||
def self.pattern_in_website(website, language) | ||
"/#{website.special_page(Communication::Website::Page::CommunicationPortfolio, language: language).slug_with_ancestors}/:slug/" | ||
end | ||
|
||
protected | ||
|
||
def published? | ||
website.id == about.communication_website_id | ||
end | ||
|
||
def substitutions | ||
{ | ||
slug: about.slug | ||
} | ||
end | ||
|
||
end |
Oops, something went wrong.