From 912efc8dcd50989f0e22ff5c27252ddcef0efefa Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Tue, 26 Nov 2019 23:52:49 -0500 Subject: [PATCH] various fixes --- assets/css/views/filters.scss | 4 ++++ lib/philomena/filters/filter.ex | 2 +- lib/philomena/images/image.ex | 1 + lib/philomena_web/views/post_view.ex | 9 ++++++--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/assets/css/views/filters.scss b/assets/css/views/filters.scss index d6539c17..94508e48 100644 --- a/assets/css/views/filters.scss +++ b/assets/css/views/filters.scss @@ -25,3 +25,7 @@ } } } + +.spoiler-filter-code { + white-space: pre-wrap; +} \ No newline at end of file diff --git a/lib/philomena/filters/filter.ex b/lib/philomena/filters/filter.ex index ab5118ff..2414c22c 100644 --- a/lib/philomena/filters/filter.ex +++ b/lib/philomena/filters/filter.ex @@ -32,7 +32,7 @@ defmodule Philomena.Filters.Filter do filter |> cast(attrs, [:spoilered_tag_list, :hidden_tag_list, :description, :name, :spoilered_complex_str, :hidden_complex_str]) |> propagate_tag_lists() - |> validate_required([:name]) + |> validate_required([:name, :description]) |> unsafe_validate_unique([:user_id, :name], Repo) |> validate_my_downvotes(:spoilered_complex_str) |> validate_my_downvotes(:hidden_complex_str) diff --git a/lib/philomena/images/image.ex b/lib/philomena/images/image.ex index 16d8ef90..eecc694f 100644 --- a/lib/philomena/images/image.ex +++ b/lib/philomena/images/image.ex @@ -138,6 +138,7 @@ defmodule Philomena.Images.Image do |> validate_number(:image_height, greater_than: 0, less_than_or_equal_to: 32767) |> validate_length(:image_name, max: 255, count: :bytes) |> validate_inclusion(:image_mime_type, ~W(image/gif image/jpeg image/png image/svg+xml video/webm)) + |> unsafe_validate_unique([:image_sha512_hash], Philomena.Repo) end def source_changeset(image, attrs) do diff --git a/lib/philomena_web/views/post_view.ex b/lib/philomena_web/views/post_view.ex index 683c209b..cc83324d 100644 --- a/lib/philomena_web/views/post_view.ex +++ b/lib/philomena_web/views/post_view.ex @@ -23,9 +23,12 @@ defmodule PhilomenaWeb.PostView do end defp author_name(object) do - case Attribution.anonymous?(object) do - true -> PhilomenaWeb.UserAttributionView.anonymous_name(object) - false -> object.user.name + cond do + Attribution.anonymous?(object) || !object.user -> + PhilomenaWeb.UserAttributionView.anonymous_name(object) + + true -> + object.user.name end end end