Skip to content
Snippets Groups Projects
Commit ff858992 authored by pabois's avatar pabois
Browse files

author connected to posts

parent ef318152
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,6 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web ...@@ -57,6 +57,6 @@ class Admin::Communication::Website::PostsController < Admin::Communication::Web
def post_params def post_params
params.require(:communication_website_post) params.require(:communication_website_post)
.permit(:university_id, :website_id, :title, :description, :text, :published, :published_at, :featured_image, :featured_image_delete, :featured_image_infos, :slug, category_ids: []) .permit(:university_id, :website_id, :title, :description, :text, :published, :published_at, :featured_image, :featured_image_delete, :featured_image_infos, :slug, :author_id, category_ids: [])
end end
end end
...@@ -13,16 +13,19 @@ ...@@ -13,16 +13,19 @@
# title :string # title :string
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
# author_id :uuid
# communication_website_id :uuid not null # communication_website_id :uuid not null
# university_id :uuid not null # university_id :uuid not null
# #
# Indexes # Indexes
# #
# index_communication_website_posts_on_author_id (author_id)
# index_communication_website_posts_on_communication_website_id (communication_website_id) # index_communication_website_posts_on_communication_website_id (communication_website_id)
# index_communication_website_posts_on_university_id (university_id) # index_communication_website_posts_on_university_id (university_id)
# #
# Foreign Keys # Foreign Keys
# #
# fk_rails_... (author_id => communication_website_authors.id)
# fk_rails_... (communication_website_id => communication_websites.id) # fk_rails_... (communication_website_id => communication_websites.id)
# fk_rails_... (university_id => universities.id) # fk_rails_... (university_id => universities.id)
# #
...@@ -36,6 +39,9 @@ class Communication::Website::Post < ApplicationRecord ...@@ -36,6 +39,9 @@ class Communication::Website::Post < ApplicationRecord
belongs_to :university belongs_to :university
belongs_to :website, belongs_to :website,
foreign_key: :communication_website_id foreign_key: :communication_website_id
belongs_to :author,
class_name: 'Communication::Website::Author',
optional: true
has_and_belongs_to_many :categories, has_and_belongs_to_many :categories,
class_name: 'Communication::Website::Category', class_name: 'Communication::Website::Category',
join_table: 'communication_website_categories_posts', join_table: 'communication_website_categories_posts',
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<p> <p>
<strong><%= Communication::Website::Author.human_attribute_name('biography') %></strong> <strong><%= Communication::Website::Author.human_attribute_name('biography') %></strong>
</p> </p>
<%= sanitize @author.biography %> <%= @author.biography %>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<%= f.input :slug, as: :string if post.persisted? %> <%= f.input :slug, as: :string if post.persisted? %>
<%= f.input :published %> <%= f.input :published %>
<%= f.input :published_at, html5: true %> <%= f.input :published_at, html5: true %>
<%= f.association :author, collection: @website.authors.ordered if @website.authors.any? %>
<%= f.association :categories, as: :check_boxes if @website.categories.any? %> <%= f.association :categories, as: :check_boxes if @website.categories.any? %>
</div> </div>
</div> </div>
......
...@@ -25,6 +25,12 @@ ...@@ -25,6 +25,12 @@
</div> </div>
<table class="<%= table_classes %>"> <table class="<%= table_classes %>">
<tbody> <tbody>
<% if @post.author %>
<tr>
<td width="150"><%= Communication::Website::Post.human_attribute_name('author') %></td>
<td><%= link_to_if can?(:read, @post.author), @post.author, admin_communication_website_author_path(@post.author) %></td>
</tr>
<% end %>
<tr> <tr>
<td width="150"><%= Communication::Website::Post.human_attribute_name('slug') %></td> <td width="150"><%= Communication::Website::Post.human_attribute_name('slug') %></td>
<td><%= @post.slug %></td> <td><%= @post.slug %></td>
......
...@@ -26,8 +26,8 @@ fr: ...@@ -26,8 +26,8 @@ fr:
one: Site Web one: Site Web
other: Sites Web other: Sites Web
communication/website/author: communication/website/author:
one: Auteur one: Auteur·rice
other: Auteurs other: Auteur·rice·s
communication/website/category: communication/website/category:
one: Catégorie one: Catégorie
other: Catégories other: Catégories
......
...@@ -34,8 +34,8 @@ fr: ...@@ -34,8 +34,8 @@ fr:
one: Université one: Université
other: Universités other: Universités
user: user:
one: Utilisateur one: Utilisateur·rice
other: Utilisateurs other: Utilisateur·rice·s
admin: admin:
attachment_not_available: Impossible d'accéder à l'élément attachment_not_available: Impossible d'accéder à l'élément
dashboard: Tableau de bord dashboard: Tableau de bord
......
class AddAuthorToCommunicationWebsitePost < ActiveRecord::Migration[6.1]
def change
add_reference :communication_website_posts, :author, foreign_key: { to_table: :communication_website_authors }, type: :uuid
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_10_28_090402) do ActiveRecord::Schema.define(version: 2021_10_28_100510) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto" enable_extension "pgcrypto"
...@@ -239,6 +239,8 @@ ActiveRecord::Schema.define(version: 2021_10_28_090402) do ...@@ -239,6 +239,8 @@ ActiveRecord::Schema.define(version: 2021_10_28_090402) do
t.text "slug" t.text "slug"
t.text "path" t.text "path"
t.text "github_path" t.text "github_path"
t.uuid "author_id"
t.index ["author_id"], name: "index_communication_website_posts_on_author_id"
t.index ["communication_website_id"], name: "index_communication_website_posts_on_communication_website_id" t.index ["communication_website_id"], name: "index_communication_website_posts_on_communication_website_id"
t.index ["university_id"], name: "index_communication_website_posts_on_university_id" t.index ["university_id"], name: "index_communication_website_posts_on_university_id"
end end
...@@ -464,6 +466,7 @@ ActiveRecord::Schema.define(version: 2021_10_28_090402) do ...@@ -464,6 +466,7 @@ ActiveRecord::Schema.define(version: 2021_10_28_090402) do
add_foreign_key "communication_website_pages", "communication_website_pages", column: "parent_id" add_foreign_key "communication_website_pages", "communication_website_pages", column: "parent_id"
add_foreign_key "communication_website_pages", "communication_websites" add_foreign_key "communication_website_pages", "communication_websites"
add_foreign_key "communication_website_pages", "universities" add_foreign_key "communication_website_pages", "universities"
add_foreign_key "communication_website_posts", "communication_website_authors", column: "author_id"
add_foreign_key "communication_website_posts", "communication_websites" add_foreign_key "communication_website_posts", "communication_websites"
add_foreign_key "communication_website_posts", "universities" add_foreign_key "communication_website_posts", "universities"
add_foreign_key "communication_websites", "universities" add_foreign_key "communication_websites", "universities"
......
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