-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add session_image and fix associations
- Loading branch information
1 parent
5600472
commit f944f90
Showing
14 changed files
with
149 additions
and
109 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
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
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
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
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
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,28 @@ | ||
defmodule Atomic.Uploaders.Post do | ||
@moduledoc false | ||
use Waffle.Definition | ||
use Waffle.Ecto.Definition | ||
alias Atomic.Activities.Session | ||
|
||
@versions [:original] | ||
@extension_whitelist ~w(.svg .jpg .jpeg .gif .png) | ||
|
||
def validate({file, _}) do | ||
file.file_name | ||
|> Path.extname() | ||
|> String.downcase() | ||
|> then(&Enum.member?(@extension_whitelist, &1)) | ||
|> case do | ||
true -> :ok | ||
false -> {:error, "invalid file type"} | ||
end | ||
end | ||
|
||
def filename(version, _) do | ||
version | ||
end | ||
|
||
def storage_dir(_version, {_file, %Session{} = scope}) do | ||
"uploads/atomic/sessions/#{scope.id}" | ||
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
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
Oops, something went wrong.