fix credo warning for is_owner?
This commit is contained in:
parent
2a87037f06
commit
362c406471
@ -234,7 +234,7 @@ defmodule Memex.Contexts do
|
|||||||
def owner_or_admin?(_context, %{role: :admin}), do: true
|
def owner_or_admin?(_context, %{role: :admin}), do: true
|
||||||
def owner_or_admin?(_context, _other_user), do: false
|
def owner_or_admin?(_context, _other_user), do: false
|
||||||
|
|
||||||
@spec is_owner?(Context.t(), User.t()) :: boolean()
|
@spec owner?(Context.t(), User.t()) :: boolean()
|
||||||
def is_owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||||
def is_owner?(_context, _other_user), do: false
|
def owner?(_context, _other_user), do: false
|
||||||
end
|
end
|
||||||
|
@ -234,7 +234,7 @@ defmodule Memex.Notes do
|
|||||||
def owner_or_admin?(_context, %{role: :admin}), do: true
|
def owner_or_admin?(_context, %{role: :admin}), do: true
|
||||||
def owner_or_admin?(_context, _other_user), do: false
|
def owner_or_admin?(_context, _other_user), do: false
|
||||||
|
|
||||||
@spec is_owner?(Note.t(), User.t()) :: boolean()
|
@spec owner?(Note.t(), User.t()) :: boolean()
|
||||||
def is_owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||||
def is_owner?(_context, _other_user), do: false
|
def owner?(_context, _other_user), do: false
|
||||||
end
|
end
|
||||||
|
@ -236,7 +236,7 @@ defmodule Memex.Pipelines do
|
|||||||
def owner_or_admin?(_context, %{role: :admin}), do: true
|
def owner_or_admin?(_context, %{role: :admin}), do: true
|
||||||
def owner_or_admin?(_context, _other_user), do: false
|
def owner_or_admin?(_context, _other_user), do: false
|
||||||
|
|
||||||
@spec is_owner?(Pipeline.t(), User.t()) :: boolean()
|
@spec owner?(Pipeline.t(), User.t()) :: boolean()
|
||||||
def is_owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
def owner?(%{user_id: user_id}, %{id: user_id}), do: true
|
||||||
def is_owner?(_context, _other_user), do: false
|
def owner?(_context, _other_user), do: false
|
||||||
end
|
end
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
>
|
>
|
||||||
<:actions :let={context}>
|
<:actions :let={context}>
|
||||||
<.link
|
<.link
|
||||||
:if={Contexts.is_owner?(context, @current_user)}
|
:if={Contexts.owner?(context, @current_user)}
|
||||||
patch={~p"/contexts/#{context}/edit"}
|
patch={~p"/contexts/#{context}/edit"}
|
||||||
aria-label={dgettext("actions", "edit %{context_slug}", context_slug: context.slug)}
|
aria-label={dgettext("actions", "edit %{context_slug}", context_slug: context.slug)}
|
||||||
>
|
>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<div class="self-end flex space-x-4">
|
<div class="self-end flex space-x-4">
|
||||||
<.link
|
<.link
|
||||||
:if={Contexts.is_owner?(@context, @current_user)}
|
:if={Contexts.owner?(@context, @current_user)}
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
patch={~p"/context/#{@context}/edit"}
|
patch={~p"/context/#{@context}/edit"}
|
||||||
>
|
>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
>
|
>
|
||||||
<:actions :let={note}>
|
<:actions :let={note}>
|
||||||
<.link
|
<.link
|
||||||
:if={Notes.is_owner?(note, @current_user)}
|
:if={Notes.owner?(note, @current_user)}
|
||||||
patch={~p"/notes/#{note}/edit"}
|
patch={~p"/notes/#{note}/edit"}
|
||||||
aria-label={dgettext("actions", "edit %{note_slug}", note_slug: note.slug)}
|
aria-label={dgettext("actions", "edit %{note_slug}", note_slug: note.slug)}
|
||||||
>
|
>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<div class="self-end flex space-x-4">
|
<div class="self-end flex space-x-4">
|
||||||
<.link
|
<.link
|
||||||
:if={Notes.is_owner?(@note, @current_user)}
|
:if={Notes.owner?(@note, @current_user)}
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
patch={~p"/note/#{@note}/edit"}
|
patch={~p"/note/#{@note}/edit"}
|
||||||
>
|
>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
>
|
>
|
||||||
<:actions :let={pipeline}>
|
<:actions :let={pipeline}>
|
||||||
<.link
|
<.link
|
||||||
:if={Pipelines.is_owner?(pipeline, @current_user)}
|
:if={Pipelines.owner?(pipeline, @current_user)}
|
||||||
patch={~p"/pipelines/#{pipeline}/edit"}
|
patch={~p"/pipelines/#{pipeline}/edit"}
|
||||||
aria-label={dgettext("actions", "edit %{pipeline_slug}", pipeline_slug: pipeline.slug)}
|
aria-label={dgettext("actions", "edit %{pipeline_slug}", pipeline_slug: pipeline.slug)}
|
||||||
>
|
>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<div class="pb-4 self-end flex space-x-4">
|
<div class="pb-4 self-end flex space-x-4">
|
||||||
<.link
|
<.link
|
||||||
:if={Pipelines.is_owner?(@pipeline, @current_user)}
|
:if={Pipelines.owner?(@pipeline, @current_user)}
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
patch={~p"/pipeline/#{@pipeline}/edit"}
|
patch={~p"/pipeline/#{@pipeline}/edit"}
|
||||||
>
|
>
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<%= gettext("%{position}. %{title}", position: position + 1, title: title) %>
|
<%= gettext("%{position}. %{title}", position: position + 1, title: title) %>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<%= if Pipelines.is_owner?(@pipeline, @current_user) do %>
|
<%= if Pipelines.owner?(@pipeline, @current_user) do %>
|
||||||
<div class="flex justify-between items-center space-x-4">
|
<div class="flex justify-between items-center space-x-4">
|
||||||
<%= if position <= 0 do %>
|
<%= if position <= 0 do %>
|
||||||
<i class="fas text-xl fa-chevron-up cursor-not-allowed opacity-25"></i>
|
<i class="fas text-xl fa-chevron-up cursor-not-allowed opacity-25"></i>
|
||||||
@ -113,7 +113,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<.link
|
<.link
|
||||||
:if={Pipelines.is_owner?(@pipeline, @current_user)}
|
:if={Pipelines.owner?(@pipeline, @current_user)}
|
||||||
class="self-end btn btn-primary"
|
class="self-end btn btn-primary"
|
||||||
patch={~p"/pipeline/#{@pipeline}/add_step"}
|
patch={~p"/pipeline/#{@pipeline}/add_step"}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user