mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
galleries fixes
This commit is contained in:
parent
878b923a20
commit
a3b3a38fef
3 changed files with 21 additions and 2 deletions
|
@ -90,7 +90,22 @@ defmodule Philomena.Galleries do
|
|||
|
||||
"""
|
||||
def delete_gallery(%Gallery{} = gallery) do
|
||||
images =
|
||||
Interaction
|
||||
|> where(gallery_id: ^gallery.id)
|
||||
|> select([i], i.image_id)
|
||||
|> Repo.all()
|
||||
|
||||
Repo.delete(gallery)
|
||||
|> case do
|
||||
{:ok, gallery} ->
|
||||
Images.reindex_images(images)
|
||||
|
||||
{:ok, gallery}
|
||||
|
||||
error ->
|
||||
error
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -34,8 +34,8 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
gallery = conn.assigns.gallery
|
||||
user = conn.assigns.current_user
|
||||
query = "gallery_id:#{gallery.id}"
|
||||
params = Map.put(conn.params, "q", query)
|
||||
sort = ImageSorter.parse_sort(%{"sf" => "gallery_id:#{gallery.id}", "sd" => position_order(gallery)})
|
||||
params = Map.merge(conn.params, %{"q" => query, "sf" => "gallery_id:#{gallery.id}", "sd" => position_order(gallery)})
|
||||
sort = ImageSorter.parse_sort(params)
|
||||
|
||||
{:ok, {images, _tags}} = ImageLoader.search_string(conn, query, queries: sort.queries, sorts: sort.sorts)
|
||||
interactions = Interactions.user_interactions(images, user)
|
||||
|
|
|
@ -34,6 +34,10 @@ elixir:
|
|||
i.fa.fa-check>
|
||||
' Save
|
||||
|
||||
a href=Routes.gallery_path(@conn, :delete, @gallery) data-method="delete" data-confirm="Are you really, really sure?"
|
||||
i.fa.fa-trash>
|
||||
span.hide-mobile Delete
|
||||
|
||||
= if show_subscription_link?(@gallery.creator, @conn.assigns.current_user) do
|
||||
= render PhilomenaWeb.Gallery.SubscriptionView, "_subscription.html", watching: @watching, gallery: @gallery, conn: @conn
|
||||
|
||||
|
|
Loading…
Reference in a new issue