mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
add profile source changes
This commit is contained in:
parent
015abf068b
commit
022b1008ab
8 changed files with 81 additions and 38 deletions
|
@ -0,0 +1,26 @@
|
||||||
|
defmodule PhilomenaWeb.Profile.SourceChangeController do
|
||||||
|
use PhilomenaWeb, :controller
|
||||||
|
|
||||||
|
alias Philomena.Users.User
|
||||||
|
alias Philomena.Images.Image
|
||||||
|
alias Philomena.SourceChanges.SourceChange
|
||||||
|
alias Philomena.Repo
|
||||||
|
import Ecto.Query
|
||||||
|
|
||||||
|
plug PhilomenaWeb.CanaryMapPlug, index: :show
|
||||||
|
plug :load_and_authorize_resource, model: User, id_name: "profile_id", id_field: "slug", persisted: true
|
||||||
|
|
||||||
|
def index(conn, _params) do
|
||||||
|
user = conn.assigns.user
|
||||||
|
|
||||||
|
source_changes =
|
||||||
|
SourceChange
|
||||||
|
|> join(:inner, [sc], i in Image, on: sc.image_id == i.id)
|
||||||
|
|> where([sc, i], sc.user_id == ^user.id and not (i.user_id == ^user.id and i.anonymous == true))
|
||||||
|
|> preload([:user, image: [:user, :tags]])
|
||||||
|
|> order_by(desc: :created_at)
|
||||||
|
|> Repo.paginate(conn.assigns.scrivener)
|
||||||
|
|
||||||
|
render(conn, "index.html", user: user, source_changes: source_changes)
|
||||||
|
end
|
||||||
|
end
|
|
@ -179,6 +179,7 @@ defmodule PhilomenaWeb.Router do
|
||||||
resources "/reports", Profile.ReportController, only: [:new, :create]
|
resources "/reports", Profile.ReportController, only: [:new, :create]
|
||||||
resources "/commission", Profile.CommissionController, only: [:show], singleton: true
|
resources "/commission", Profile.CommissionController, only: [:show], singleton: true
|
||||||
resources "/tag_changes", Profile.TagChangeController, only: [:index]
|
resources "/tag_changes", Profile.TagChangeController, only: [:index]
|
||||||
|
resources "/source_changes", Profile.SourceChangeController, only: [:index]
|
||||||
end
|
end
|
||||||
resources "/captchas", CaptchaController, only: [:create]
|
resources "/captchas", CaptchaController, only: [:create]
|
||||||
scope "/posts", Post, as: :post do
|
scope "/posts", Post, as: :post do
|
||||||
|
|
|
@ -7,40 +7,4 @@ h1
|
||||||
- route = fn p -> Routes.image_source_change_path(@conn, :index, @image, p) end
|
- route = fn p -> Routes.image_source_change_path(@conn, :index, @image, p) end
|
||||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @source_changes, route: route, conn: @conn
|
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @source_changes, route: route, conn: @conn
|
||||||
|
|
||||||
.block
|
= render PhilomenaWeb.SourceChangeView, "index.html", conn: @conn, source_changes: @source_changes, pagination: pagination
|
||||||
.block__header
|
|
||||||
= pagination
|
|
||||||
|
|
||||||
.block__content
|
|
||||||
table.table
|
|
||||||
thead
|
|
||||||
tr
|
|
||||||
th colspan=2 Image
|
|
||||||
th New Source
|
|
||||||
th Timestamp
|
|
||||||
th User
|
|
||||||
th Initial?
|
|
||||||
|
|
||||||
tbody
|
|
||||||
= for source_change <- @source_changes do
|
|
||||||
tr
|
|
||||||
td.center
|
|
||||||
= link source_change.image_id, to: Routes.image_path(@conn, :show, source_change.image)
|
|
||||||
td.center
|
|
||||||
= render PhilomenaWeb.ImageView, "_image_container.html", image: source_change.image, size: :thumb_tiny, conn: @conn
|
|
||||||
|
|
||||||
td
|
|
||||||
= source_change.new_value
|
|
||||||
|
|
||||||
td
|
|
||||||
= pretty_time(source_change.created_at)
|
|
||||||
|
|
||||||
td
|
|
||||||
= render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: source_change, conn: @conn
|
|
||||||
|
|
||||||
td
|
|
||||||
= if source_change.initial do
|
|
||||||
' ✓
|
|
||||||
|
|
||||||
.block__header
|
|
||||||
= pagination
|
|
|
@ -24,7 +24,7 @@
|
||||||
ul.profile-top__options__column
|
ul.profile-top__options__column
|
||||||
li = link("Favorites", to: Routes.search_path(@conn, :index, q: "faved_by_id:#{@user.id}"))
|
li = link("Favorites", to: Routes.search_path(@conn, :index, q: "faved_by_id:#{@user.id}"))
|
||||||
li = link("Tag changes", to: Routes.profile_tag_change_path(@conn, :index, @user))
|
li = link("Tag changes", to: Routes.profile_tag_change_path(@conn, :index, @user))
|
||||||
li = link("Source changes", to: "#")
|
li = link("Source changes", to: Routes.profile_source_change_path(@conn, :index, @user))
|
||||||
|
|
||||||
.column-layout
|
.column-layout
|
||||||
.column-layout__left
|
.column-layout__left
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
h1
|
||||||
|
' Source changes by
|
||||||
|
a href=Routes.profile_path(@conn, :show, @user)
|
||||||
|
= @user.name
|
||||||
|
|
||||||
|
- route = fn p -> Routes.profile_source_change_path(@conn, :index, @image, p) end
|
||||||
|
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @source_changes, route: route, conn: @conn
|
||||||
|
|
||||||
|
= render PhilomenaWeb.SourceChangeView, "index.html", conn: @conn, source_changes: @source_changes, pagination: pagination
|
37
lib/philomena_web/templates/source_change/index.html.slime
Normal file
37
lib/philomena_web/templates/source_change/index.html.slime
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
.block
|
||||||
|
.block__header
|
||||||
|
= @pagination
|
||||||
|
|
||||||
|
.block__content
|
||||||
|
table.table
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th colspan=2 Image
|
||||||
|
th New Source
|
||||||
|
th Timestamp
|
||||||
|
th User
|
||||||
|
th Initial?
|
||||||
|
|
||||||
|
tbody
|
||||||
|
= for source_change <- @source_changes do
|
||||||
|
tr
|
||||||
|
td.center
|
||||||
|
= link source_change.image_id, to: Routes.image_path(@conn, :show, source_change.image)
|
||||||
|
td.center
|
||||||
|
= render PhilomenaWeb.ImageView, "_image_container.html", image: source_change.image, size: :thumb_tiny, conn: @conn
|
||||||
|
|
||||||
|
td
|
||||||
|
= source_change.new_value
|
||||||
|
|
||||||
|
td
|
||||||
|
= pretty_time(source_change.created_at)
|
||||||
|
|
||||||
|
td
|
||||||
|
= render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: source_change, conn: @conn
|
||||||
|
|
||||||
|
td
|
||||||
|
= if source_change.initial do
|
||||||
|
' ✓
|
||||||
|
|
||||||
|
.block__header
|
||||||
|
= @pagination
|
3
lib/philomena_web/views/profile/source_change_view.ex
Normal file
3
lib/philomena_web/views/profile/source_change_view.ex
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
defmodule PhilomenaWeb.Profile.SourceChangeView do
|
||||||
|
use PhilomenaWeb, :view
|
||||||
|
end
|
3
lib/philomena_web/views/source_change_view.ex
Normal file
3
lib/philomena_web/views/source_change_view.ex
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
defmodule PhilomenaWeb.SourceChangeView do
|
||||||
|
use PhilomenaWeb, :view
|
||||||
|
end
|
Loading…
Reference in a new issue