fix credo warning for is_owner_or_admin?
This commit is contained in:
parent
53d0dcfb15
commit
2a87037f06
@ -229,10 +229,10 @@ defmodule Memex.Contexts do
|
||||
context |> Context.update_changeset(attrs, user)
|
||||
end
|
||||
|
||||
@spec is_owner_or_admin?(Context.t(), User.t()) :: boolean()
|
||||
def is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
def is_owner_or_admin?(_context, %{role: :admin}), do: true
|
||||
def is_owner_or_admin?(_context, _other_user), do: false
|
||||
@spec owner_or_admin?(Context.t(), User.t()) :: boolean()
|
||||
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
def owner_or_admin?(_context, %{role: :admin}), do: true
|
||||
def owner_or_admin?(_context, _other_user), do: false
|
||||
|
||||
@spec is_owner?(Context.t(), User.t()) :: boolean()
|
||||
def is_owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
|
@ -229,10 +229,10 @@ defmodule Memex.Notes do
|
||||
note |> Note.update_changeset(attrs, user)
|
||||
end
|
||||
|
||||
@spec is_owner_or_admin?(Note.t(), User.t()) :: boolean()
|
||||
def is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
def is_owner_or_admin?(_context, %{role: :admin}), do: true
|
||||
def is_owner_or_admin?(_context, _other_user), do: false
|
||||
@spec owner_or_admin?(Note.t(), User.t()) :: boolean()
|
||||
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
def owner_or_admin?(_context, %{role: :admin}), do: true
|
||||
def owner_or_admin?(_context, _other_user), do: false
|
||||
|
||||
@spec is_owner?(Note.t(), User.t()) :: boolean()
|
||||
def is_owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
|
@ -231,10 +231,10 @@ defmodule Memex.Pipelines do
|
||||
pipeline |> Pipeline.update_changeset(attrs, user)
|
||||
end
|
||||
|
||||
@spec is_owner_or_admin?(Pipeline.t(), User.t()) :: boolean()
|
||||
def is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
def is_owner_or_admin?(_context, %{role: :admin}), do: true
|
||||
def is_owner_or_admin?(_context, _other_user), do: false
|
||||
@spec owner_or_admin?(Pipeline.t(), User.t()) :: boolean()
|
||||
def owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
def owner_or_admin?(_context, %{role: :admin}), do: true
|
||||
def owner_or_admin?(_context, _other_user), do: false
|
||||
|
||||
@spec is_owner?(Pipeline.t(), User.t()) :: boolean()
|
||||
def is_owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||
|
@ -40,7 +40,7 @@
|
||||
<%= dgettext("actions", "edit") %>
|
||||
</.link>
|
||||
<.link
|
||||
:if={Contexts.is_owner_or_admin?(context, @current_user)}
|
||||
:if={Contexts.owner_or_admin?(context, @current_user)}
|
||||
href="#"
|
||||
phx-click="delete"
|
||||
phx-value-id={context.id}
|
||||
|
@ -24,7 +24,7 @@
|
||||
<%= dgettext("actions", "edit") %>
|
||||
</.link>
|
||||
<button
|
||||
:if={Contexts.is_owner_or_admin?(@context, @current_user)}
|
||||
:if={Contexts.owner_or_admin?(@context, @current_user)}
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
phx-click="delete"
|
||||
|
@ -40,7 +40,7 @@
|
||||
<%= dgettext("actions", "edit") %>
|
||||
</.link>
|
||||
<.link
|
||||
:if={Notes.is_owner_or_admin?(note, @current_user)}
|
||||
:if={Notes.owner_or_admin?(note, @current_user)}
|
||||
href="#"
|
||||
phx-click="delete"
|
||||
phx-value-id={note.id}
|
||||
|
@ -24,7 +24,7 @@
|
||||
<%= dgettext("actions", "edit") %>
|
||||
</.link>
|
||||
<button
|
||||
:if={Notes.is_owner_or_admin?(@note, @current_user)}
|
||||
:if={Notes.owner_or_admin?(@note, @current_user)}
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
phx-click="delete"
|
||||
|
@ -40,7 +40,7 @@
|
||||
<%= dgettext("actions", "edit") %>
|
||||
</.link>
|
||||
<.link
|
||||
:if={Pipelines.is_owner_or_admin?(pipeline, @current_user)}
|
||||
:if={Pipelines.owner_or_admin?(pipeline, @current_user)}
|
||||
href="#"
|
||||
phx-click="delete"
|
||||
phx-value-id={pipeline.id}
|
||||
|
@ -24,7 +24,7 @@
|
||||
<%= dgettext("actions", "edit") %>
|
||||
</.link>
|
||||
<button
|
||||
:if={Pipelines.is_owner_or_admin?(@pipeline, @current_user)}
|
||||
:if={Pipelines.owner_or_admin?(@pipeline, @current_user)}
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
phx-click="delete"
|
||||
|
Loading…
Reference in New Issue
Block a user