From 1c12c010fa3258a734b0b8ef6c0e57cf3713e658 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Tue, 31 Mar 2020 11:39:11 -0400 Subject: [PATCH] mix format --- .../controllers/admin/advert/image_controller.ex | 7 ++++++- .../controllers/api/json/search/image_controller.ex | 6 +++++- .../controllers/api/json/search/reverse_controller.ex | 1 + lib/philomena_web/router.ex | 1 + lib/philomena_web/views/api/json/gallery_view.ex | 3 ++- lib/philomena_web/views/api/json/profile_view.ex | 8 +++++++- 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/philomena_web/controllers/admin/advert/image_controller.ex b/lib/philomena_web/controllers/admin/advert/image_controller.ex index 4807fb79..8fe46022 100644 --- a/lib/philomena_web/controllers/admin/advert/image_controller.ex +++ b/lib/philomena_web/controllers/admin/advert/image_controller.ex @@ -5,7 +5,12 @@ defmodule PhilomenaWeb.Admin.Advert.ImageController do alias Philomena.Adverts plug :verify_authorized - plug :load_and_authorize_resource, model: Advert, id_name: "advert_id", persisted: true, only: [:edit, :update, :delete] + + plug :load_and_authorize_resource, + model: Advert, + id_name: "advert_id", + persisted: true, + only: [:edit, :update, :delete] def edit(conn, _params) do changeset = Adverts.change_advert(conn.assigns.advert) diff --git a/lib/philomena_web/controllers/api/json/search/image_controller.ex b/lib/philomena_web/controllers/api/json/search/image_controller.ex index a136e022..2094097f 100644 --- a/lib/philomena_web/controllers/api/json/search/image_controller.ex +++ b/lib/philomena_web/controllers/api/json/search/image_controller.ex @@ -22,7 +22,11 @@ defmodule PhilomenaWeb.Api.Json.Search.ImageController do conn |> put_view(PhilomenaWeb.Api.Json.ImageView) - |> render("index.json", images: images, total: images.total_entries, interactions: interactions) + |> render("index.json", + images: images, + total: images.total_entries, + interactions: interactions + ) {:error, msg} -> conn diff --git a/lib/philomena_web/controllers/api/json/search/reverse_controller.ex b/lib/philomena_web/controllers/api/json/search/reverse_controller.ex index fff51950..d4630c96 100644 --- a/lib/philomena_web/controllers/api/json/search/reverse_controller.ex +++ b/lib/philomena_web/controllers/api/json/search/reverse_controller.ex @@ -9,6 +9,7 @@ defmodule PhilomenaWeb.Api.Json.Search.ReverseController do def create(conn, %{"image" => image_params}) do user = conn.assigns.current_user + images = image_params |> Map.put("distance", conn.params["distance"]) diff --git a/lib/philomena_web/router.ex b/lib/philomena_web/router.ex index 75be8cf4..d8589364 100644 --- a/lib/philomena_web/router.ex +++ b/lib/philomena_web/router.ex @@ -320,6 +320,7 @@ defmodule PhilomenaWeb.Router do only: [:index, :new, :create, :edit, :update, :delete] resources "/site_notices", SiteNoticeController, except: [:show] + resources "/adverts", AdvertController, except: [:show] do resources "/image", Advert.ImageController, only: [:edit, :update], singleton: true end diff --git a/lib/philomena_web/views/api/json/gallery_view.ex b/lib/philomena_web/views/api/json/gallery_view.ex index c8ae28ff..d49c1236 100644 --- a/lib/philomena_web/views/api/json/gallery_view.ex +++ b/lib/philomena_web/views/api/json/gallery_view.ex @@ -3,7 +3,8 @@ defmodule PhilomenaWeb.Api.Json.GalleryView do def render("index.json", %{galleries: galleries, total: total} = assigns) do %{ - galleries: render_many(galleries, PhilomenaWeb.Api.Json.GalleryView, "gallery.json", assigns), + galleries: + render_many(galleries, PhilomenaWeb.Api.Json.GalleryView, "gallery.json", assigns), total: total } end diff --git a/lib/philomena_web/views/api/json/profile_view.ex b/lib/philomena_web/views/api/json/profile_view.ex index 7803bcd8..92c9d0ec 100644 --- a/lib/philomena_web/views/api/json/profile_view.ex +++ b/lib/philomena_web/views/api/json/profile_view.ex @@ -18,7 +18,13 @@ defmodule PhilomenaWeb.Api.Json.ProfileView do uploads_count: user.uploads_count, posts_count: user.forum_posts_count, topics_count: user.topic_count, - links: render_many(user.public_links, PhilomenaWeb.Api.Json.UserLinkView, "user_link.json", assigns), + links: + render_many( + user.public_links, + PhilomenaWeb.Api.Json.UserLinkView, + "user_link.json", + assigns + ), awards: render_many(user.awards, PhilomenaWeb.Api.Json.AwardView, "award.json", assigns) } end