-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
authored and
root
committed
Nov 18, 2024
1 parent
58582ed
commit ddf3adc
Showing
4 changed files
with
50 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule Safira.Spotlights do | ||
use Ecto.Schema | ||
import Ecto.Changeset | ||
|
||
schema "spotlights" do | ||
field :duration, :integer | ||
end | ||
|
||
def change_spotlight(spotlight, attrs \\ %{}) do | ||
spotlight | ||
|> cast(attrs, [:duration]) | ||
|> validate_required([:duration]) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defmodule Safira.Uploaders.Spotlight do | ||
@moduledoc """ | ||
Spotlight image uploader. | ||
""" | ||
use Safira.Uploader | ||
|
||
alias Safira.Contest.Spotlight | ||
|
||
@versions [:original] | ||
@extension_whitelist ~w(.svg .png) | ||
|
||
def validate({file, _}) do | ||
file_extension = file.file_name |> Path.extname() |> String.downcase() | ||
Enum.member?(extension_whitelist(), file_extension) | ||
end | ||
|
||
def storage_dir(_, {_file, %Spotlight{} = spotlight}) do | ||
"uploads/contest/spotlights/#{spotlight.id}" | ||
end | ||
|
||
def filename(version, _) do | ||
version | ||
end | ||
|
||
def extension_whitelist do | ||
@extension_whitelist | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters