mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-20 04:14:23 +01:00
fixes #109: add ability to delete channels
This commit is contained in:
parent
7cfb390e05
commit
a97006fd9c
3 changed files with 13 additions and 2 deletions
|
@ -6,7 +6,7 @@ defmodule PhilomenaWeb.ChannelController do
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
plug :load_and_authorize_resource, model: Channel, only: [:show, :new, :create, :edit, :update]
|
plug :load_and_authorize_resource, model: Channel, only: [:show, :new, :create, :edit, :update, :delete]
|
||||||
|
|
||||||
def index(conn, params) do
|
def index(conn, params) do
|
||||||
show_nsfw? = conn.cookies["chan_nsfw"] == "true"
|
show_nsfw? = conn.cookies["chan_nsfw"] == "true"
|
||||||
|
@ -74,6 +74,14 @@ defmodule PhilomenaWeb.ChannelController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete(conn, _params) do
|
||||||
|
{:ok, _channel} = Channels.delete_channel(conn.assigns.channel)
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_flash(:info, "Channel destroyed successfully.")
|
||||||
|
|> redirect(to: Routes.channel_path(conn, :index))
|
||||||
|
end
|
||||||
|
|
||||||
defp maybe_search(query, %{"cq" => cq}) when is_binary(cq) and cq != "" do
|
defp maybe_search(query, %{"cq" => cq}) when is_binary(cq) and cq != "" do
|
||||||
title_query = "#{cq}%"
|
title_query = "#{cq}%"
|
||||||
tag_query = "%#{cq}%"
|
tag_query = "%#{cq}%"
|
||||||
|
|
|
@ -393,7 +393,7 @@ defmodule PhilomenaWeb.Router do
|
||||||
singleton: true
|
singleton: true
|
||||||
|
|
||||||
resources "/pages", PageController, only: [:index, :new, :create, :edit, :update]
|
resources "/pages", PageController, only: [:index, :new, :create, :edit, :update]
|
||||||
resources "/channels", ChannelController, only: [:new, :create, :edit, :update]
|
resources "/channels", ChannelController, only: [:new, :create, :edit, :update, :delete]
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", PhilomenaWeb do
|
scope "/", PhilomenaWeb do
|
||||||
|
|
|
@ -32,5 +32,8 @@
|
||||||
a href=Routes.channel_path(@conn, :edit, @channel) class=link_class
|
a href=Routes.channel_path(@conn, :edit, @channel) class=link_class
|
||||||
i.fas.fa-fw.fa-edit>
|
i.fas.fa-fw.fa-edit>
|
||||||
' Edit
|
' Edit
|
||||||
|
a href=Routes.channel_path(@conn, :delete, @channel) class=link_class data-method="delete" data-confirm="Are you really, really sure?"
|
||||||
|
i.fas.fa-fw.fa-trash>
|
||||||
|
' Delete
|
||||||
|
|
||||||
= render PhilomenaWeb.Channel.SubscriptionView, "_subscription.html", conn: @conn, watching: @subscriptions[@channel.id], channel: @channel
|
= render PhilomenaWeb.Channel.SubscriptionView, "_subscription.html", conn: @conn, watching: @subscriptions[@channel.id], channel: @channel
|
||||||
|
|
Loading…
Reference in a new issue