mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
more appropriate comment fix
This commit is contained in:
parent
29dd045202
commit
d5337eb75a
3 changed files with 9 additions and 4 deletions
|
@ -29,7 +29,12 @@ function commentPosted(response) {
|
||||||
commentEditForm.reset();
|
commentEditForm.reset();
|
||||||
|
|
||||||
if (requestOk) {
|
if (requestOk) {
|
||||||
response.text().then(text => displayComments(container, text));
|
response.text().then(text => {
|
||||||
|
if (text.includes('<div class="flash flash--warning">'))
|
||||||
|
window.location.reload();
|
||||||
|
else
|
||||||
|
displayComments(container, text);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
|
|
@ -43,7 +43,7 @@ defmodule Philomena.Comments do
|
||||||
{:error, %Ecto.Changeset{}}
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def create_comment(%Image{commenting_allowed: true} = image, attribution, params \\ %{}) do
|
def create_comment(image, attribution, params \\ %{}) do
|
||||||
comment =
|
comment =
|
||||||
Ecto.build_assoc(image, :comments)
|
Ecto.build_assoc(image, :comments)
|
||||||
|> Comment.creation_changeset(params, attribution)
|
|> Comment.creation_changeset(params, attribution)
|
||||||
|
|
|
@ -15,13 +15,13 @@ defmodule PhilomenaWeb.Image.CommentController do
|
||||||
edit: :create_comment,
|
edit: :create_comment,
|
||||||
update: :create_comment
|
update: :create_comment
|
||||||
|
|
||||||
plug :load_resource, model: Image, id_name: "image_id", persisted: true
|
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
|
||||||
plug :verify_authorized when action in [:show]
|
plug :verify_authorized when action in [:show]
|
||||||
|
|
||||||
# Undo the previous private parameter screwery
|
# Undo the previous private parameter screwery
|
||||||
plug PhilomenaWeb.LoadCommentPlug, [param: "id", show_hidden: true] when action in [:show]
|
plug PhilomenaWeb.LoadCommentPlug, [param: "id", show_hidden: true] when action in [:show]
|
||||||
plug PhilomenaWeb.LoadCommentPlug, [param: "id"] when action in [:edit, :update]
|
plug PhilomenaWeb.LoadCommentPlug, [param: "id"] when action in [:edit, :update]
|
||||||
plug PhilomenaWeb.CanaryMapPlug, create: :create, edit: :edit, update: :edit
|
plug PhilomenaWeb.CanaryMapPlug, create: :create_comment, edit: :edit, update: :edit
|
||||||
|
|
||||||
plug :authorize_resource,
|
plug :authorize_resource,
|
||||||
model: Comment,
|
model: Comment,
|
||||||
|
|
Loading…
Reference in a new issue