Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Oct 28, 2024
1 parent 2a043d9 commit 5f8bf23
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Create a challenge. Ready? Brainstorm. mindwendel helps you to easily brainstorm
- Easily create and upvote ideas, with live updates from your companions
- Cluster or filter your ideas with custom labels
- Preview of links to ease URL sharing
- Add file attachments, uploaded to an S3 compatible backend and automatically encrypted
- Add automatically encrypted file attachments which are uploaded to an S3 compatible storage backend
- Add lanes, use drag & drop to order ideas
- Export your generated ideas to html or csv (currently comma separated)
- German & English Translation files
Expand Down
2 changes: 1 addition & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ if config_env() == :prod || config_env() == :dev do
queues: [default: 1]
end

config :mindwendel, max_upload_length: System.get_env("MAX_UPLOAD_LENGTH", "2666666")
config :mindwendel, max_upload_length: System.get_env("MW_FILE_UPLOAD_MAX_FILE_SIZE", "2666666")

# configure cloak:
config :mindwendel, Mindwendel.Services.Vault,
Expand Down
16 changes: 2 additions & 14 deletions lib/mindwendel/attachments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,12 @@ defmodule Mindwendel.Attachments do
@doc """
Gets a single attached_file
Raises `Ecto.NoResultsError` if the Brainstorming does not exist.
## Examples
iex> get_attached_file!("0323906b-b496-4778-ae67-1dd779d3de3c")
%Brainstorming{ ... }
iex> get_attached_file!("0323906b-b496-4778-ae67-1dd779d3de3c")
** (Ecto.NoResultsError)
iex> get_attached_file!("not_a_valid_uuid_string")
** (Ecto.Query.CastError)
iex> get_attached_file("0323906b-b496-4778-ae67-1dd779d3de3c")
%File{ ... }
"""
def get_attached_file!(id) do
Repo.get!(File, id)
end

def get_attached_file(id) do
Repo.get(File, id)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mindwendel/brainstormings/idea.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Mindwendel.Brainstormings.Idea do
alias Mindwendel.Accounts.User

@label_values [:label_1, :label_2, :label_3, :label_4, :label_5]
@max_file_attachments 4
@max_file_attachments 2

schema "ideas" do
field :body, :string
Expand Down
2 changes: 1 addition & 1 deletion lib/mindwendel_web/live/idea_live/form_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule MindwendelWeb.IdeaLive.FormComponent do
%{current_user: current_user, brainstorming: brainstorming, idea: idea} = socket.assigns

if has_moderating_or_ownership_permission(brainstorming, idea, current_user) do
attachment = Attachments.get_attached_file!(id)
attachment = Attachments.get_attached_file(id)
Attachments.delete_attached_file(attachment)
end

Expand Down
4 changes: 2 additions & 2 deletions test/mindwendel/attachments_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ defmodule Mindwendel.AttachmentsTest do
alias Mindwendel.Factory
alias Mindwendel.Attachments

describe "get_attached_file!" do
describe "get_attached_file" do
test "returns the file" do
attachment = Factory.insert!(:file)
assert Attachments.get_attached_file!(attachment.id) == attachment
assert Attachments.get_attached_file(attachment.id) == attachment
end
end

Expand Down

0 comments on commit 5f8bf23

Please sign in to comment.