Skip to content
Snippets Groups Projects
Commit ab1fe480 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Done

parent 20edc2d3
No related branches found
No related tags found
No related merge requests found
Showing with 58 additions and 4 deletions
......@@ -57,6 +57,7 @@ class Admin::Communication::Extranets::Posts::CategoriesController < Admin::Comm
params.require(:communication_extranet_post_category)
.permit(
:name,
:slug,
)
.merge(
university_id: current_university.id
......
class Extranet::Posts::CategoriesController < Extranet::Posts::ApplicationController
def index
@categories = current_extranet.post_categories.ordered
breadcrumb
add_breadcrumb Communication::Extranet::Post::Category.model_name.human(count: 2)
end
def show
@category = current_extranet.post_categories.find_by slug: params[:slug]
@posts = @category.posts.ordered.page params[:page]
breadcrumb
add_breadcrumb @category
end
end
......@@ -21,14 +21,26 @@
# fk_rails_e53c2a25fc (extranet_id => communication_extranets.id)
#
class Communication::Extranet::Post::Category < ApplicationRecord
include WithSlug
include WithUniversity
belongs_to :extranet, class_name: 'Communication::Extranet'
has_many :posts
validates :name, presence: true
scope :ordered, -> { order(:name) }
def to_s
"#{name}"
end
protected
def slug_unavailable?(slug)
self.class.unscoped
.where(extranet_id: self.extranet_id, slug: slug)
.where.not(id: self.id)
.exists?
end
end
......@@ -9,6 +9,14 @@
<% end %>
</div>
<div class="col-md-4">
<%= osuny_panel t('metadata') do %>
<%= f.input :slug,
as: :string,
input_html: category.persisted? ? {} : {
class: 'js-slug-input',
data: { source: '#communication_extranet_post_category_name' }
} %>
<% end %>
</div>
</div>
<% content_for :action_bar_right do %>
......
......@@ -15,4 +15,5 @@
</div>
</div>
<% end %>
</div>
\ No newline at end of file
</div>
<%= paginate @documents, theme: 'bootstrap-5' %>
\ No newline at end of file
<% content_for :title, Communication::Extranet::Post::Category.model_name.human(count: 2) %>
<ul>
<% @categories.each do |category| %>
<li><%= link_to category, posts_category_path(slug: category.slug) %></li>
<% end %>
</ul>
\ No newline at end of file
<% content_for :title, @category %>
<%= render 'extranet/posts/posts/list', posts: @posts %>
<%= paginate @posts, theme: 'bootstrap-5' %>
\ No newline at end of file
......@@ -9,7 +9,7 @@
<b><%= post %></b><br>
<span class="text-muted"><%= l post.published_at.to_date %><span>
</p>
<%= link_to t('extranet.posts.read_post'), posts_communication_extranet_post_path(post.slug), class: ' btn btn-outline-primary stretched-link' %>
<%= link_to t('extranet.posts.read_post'), posts_post_path(post.slug), class: ' btn btn-outline-primary stretched-link' %>
</div>
</div>
<% end %>
......
<% content_for :title, Communication::Extranet::Post.model_name.human(count: 2) %>
<%= render 'extranet/posts/posts/list', posts: @posts %>
\ No newline at end of file
<%= render 'extranet/posts/posts/list', posts: @posts %>
<%= paginate @posts, theme: 'bootstrap-5' %>
\ No newline at end of file
......@@ -6,6 +6,8 @@
<% end %>
<% end %>
<%= link_to @post.category, posts_category_path(slug: @post.category.slug) if @post.category %>
</main>
<%= render 'admin/communication/blocks/preview', about: @post %>
<main>
......@@ -20,7 +20,10 @@ namespace :alumni do
root to: 'persons#index'
end
namespace :posts do
get ':slug' => 'posts#show', as: :communication_extranet_post
get 'categories' => 'categories#index', as: :categories
get 'categories/:slug' => 'categories#show', as: :category
# Categories before slug !
get ':slug' => 'posts#show', as: :post
root to: 'posts#index'
end
namespace :library do
......
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