Skip to content

Commit

Permalink
Organisation datagouv : logo peut ne pas exister (#3644)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti authored Dec 5, 2023
1 parent b8bbc44 commit 251b156
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/transport/lib/db/organization.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ defmodule DB.Organization do
def changeset(struct, attrs \\ %{}) do
struct
|> cast(attrs, [:id, :slug, :name, :acronym, :logo, :logo_thumbnail, :badges, :metrics, :created_at])
|> validate_required([:id, :slug, :name, :logo, :logo_thumbnail, :badges])
|> validate_required([:id, :slug, :name, :badges])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<% avatar_src =
cond do
user_avatar = comment["posted_by"]["avatar_thumbnail"] -> user_avatar
is_producer and @org_logo_thumbnail -> @org_logo_thumbnail
is_producer and not is_nil(@org_logo_thumbnail) -> @org_logo_thumbnail
true -> "https://www.data.gouv.fr/api/1/avatars/#{comment["posted_by"]["id"]}/52"
end %>
<% commenter_full_name = comment["posted_by"]["first_name"] <> " " <> comment["posted_by"]["last_name"] %>
Expand Down
5 changes: 3 additions & 2 deletions apps/transport/test/db/contact_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ defmodule DB.ContactTest do
"acronym" => nil,
"badges" => [],
"id" => Ecto.UUID.generate(),
"logo" => "https://static.data.gouv.fr/avatars/85/53e0a3845e43eb87fb905032aaa389-original.png",
"logo_thumbnail" => "https://static.data.gouv.fr/avatars/85/53e0a3845e43eb87fb905032aaa389-100.png",
# Can save an org without logos
"logo" => nil,
"logo_thumbnail" => nil,
"name" => "Big Corp",
"slug" => "foo"
}
Expand Down

0 comments on commit 251b156

Please sign in to comment.