mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
load awards
This commit is contained in:
parent
95ace30af5
commit
5b35b75b1d
9 changed files with 18 additions and 9 deletions
|
@ -6,14 +6,14 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
import Ecto.Query
|
||||
|
||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
|
||||
plug :load_and_authorize_resource, model: Comment, only: [:show], preload: [:image, :user]
|
||||
plug :load_and_authorize_resource, model: Comment, only: [:show], preload: [:image, user: [awards: :badge]]
|
||||
|
||||
def index(conn, _params) do
|
||||
comments =
|
||||
Comment
|
||||
|> where(image_id: ^conn.assigns.image.id)
|
||||
|> order_by(desc: :created_at)
|
||||
|> preload([:image, :user])
|
||||
|> preload([:image, user: [awards: :badge]])
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
rendered =
|
||||
|
|
|
@ -5,7 +5,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
||||
plug :load_and_authorize_resource, model: Image, only: :show, preload: [:user, :tags]
|
||||
plug :load_and_authorize_resource, model: Image, only: :show, preload: [:tags, user: [awards: :badge]]
|
||||
|
||||
def index(conn, _params) do
|
||||
query = conn.assigns.compiled_filter
|
||||
|
@ -27,7 +27,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
comments =
|
||||
Comment
|
||||
|> where(image_id: ^conn.assigns.image.id)
|
||||
|> preload([:user, :image])
|
||||
|> preload([:image, user: [awards: :badge]])
|
||||
|> order_by(desc: :created_at)
|
||||
|> limit(25)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
|
|
@ -33,7 +33,7 @@ defmodule PhilomenaWeb.TopicController do
|
|||
|> where(topic_id: ^conn.assigns.topic.id)
|
||||
|> where([p], p.topic_position >= ^(25 * (page - 1)) and p.topic_position < ^(25 * page))
|
||||
|> order_by(asc: :created_at)
|
||||
|> preload([:user, topic: :forum])
|
||||
|> preload([topic: :forum, user: [awards: :badge]])
|
||||
|> Repo.all()
|
||||
|
||||
rendered =
|
||||
|
|
|
@ -3,7 +3,7 @@ article.block.communication id="comment_#{@comment.id}"
|
|||
.flex__fixed.spacing-right
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @comment, conn: @conn
|
||||
.flex__grow.communication__body
|
||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment, conn: @conn
|
||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment, awards: true, conn: @conn
|
||||
.communication__body__text
|
||||
/- if comment.hidden_from_users
|
||||
/ strong.comment_deleted
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
' Uploaded
|
||||
=> pretty_time(@image.created_at)
|
||||
' by
|
||||
=> render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @image, conn: @conn
|
||||
=> render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @image, awards: true, conn: @conn
|
||||
span.image-size
|
||||
|
|
||||
= @image.image_width
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
article.block.communication id="post_#{@post.id}"
|
||||
.block__content.flex.flex--no-wrap
|
||||
.flex__fixed.spacing-right
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @post, conn: @conn
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @post, awards: true, conn: @conn
|
||||
.flex__grow.communication__body
|
||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @post, conn: @conn
|
||||
.communication__body__text
|
||||
|
|
5
lib/philomena_web/templates/profile/_awards.html.slime
Normal file
5
lib/philomena_web/templates/profile/_awards.html.slime
Normal file
|
@ -0,0 +1,5 @@
|
|||
.badges
|
||||
= for award <- award_order(@awards) do
|
||||
- title = [award_title(award), award.label] |> Enum.join(" - ")
|
||||
.badge
|
||||
= badge_image(award.badge, alt: title, title: title, width: "18", height: "18")
|
|
@ -1,6 +1,8 @@
|
|||
= if !!@object.user and !@object.anonymous do
|
||||
strong<>
|
||||
= link(@object.user.name, to: Routes.profile_path(@conn, :show, @object.user))
|
||||
= if assigns[:awards] do
|
||||
= render PhilomenaWeb.ProfileView, "_awards.html", awards: @object.user.awards
|
||||
- else
|
||||
strong<>
|
||||
| Background Pony #
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
= if !!@object.user do
|
||||
strong<>
|
||||
= link(@object.user.name, to: Routes.profile_path(@conn, :show, @object.user))
|
||||
= if assigns[:awards] do
|
||||
= render PhilomenaWeb.ProfileView, "_awards.html", awards: @object.user.awards
|
Loading…
Reference in a new issue