-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi facilities #189
Multi facilities #189
Conversation
Hello, @fcapovilla! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information. |
alias OpenPantry.Repo | ||
alias OpenPantry.User | ||
|
||
def for_token(user = %User{}), do: { :ok, "User:#{user.id}" } | ||
def for_token(_), do: { :error, "Unknown resource type" } | ||
|
||
def from_token("User:" <> id), do: { :ok, Repo.get(User, id) } | ||
def from_token("User:" <> id), do: { :ok, User |> Ecto.Query.preload(:managed_facilities) |> Repo.get(id) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no whitespace around parentheses/brackets most of the time, but here there is.
end | ||
|
||
@doc false | ||
def changeset(%UserManagedFacility{} = user_facility, attrs) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File has the variable name after the pattern while most of the files have the variable name before the pattern when naming parameter pattern matches
@@ -0,0 +1,19 @@ | |||
defmodule OpenPantry.UserManagedFacility do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modules should have a @moduledoc tag.
lib/open_pantry/user_from_auth.ex
Outdated
case Repo.get_by(User, email: auth.info.email) do | ||
user = | ||
from(u in User, where: u.email == ^auth.info.email, preload: [:managed_facilities]) | ||
|> Repo.one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a function call when a pipeline is only one function long
Ebert has finished reviewing this Pull Request and has found:
You can see more details about this review at https://ebertapp.io/github/openpantry/open_pantry/pulls/189. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great so far! I'm gonna try out locally and hopefully merge tomorrow, if you don't hear anything by Tuesday definitely remind me! Thanks so much! 💜💛💚
Ugh I failed myself! Forgot to do this Monday or Tuesday, just looked at the other open PR tonight... Prefer to test locally before merging since test suite is for shit, but also trust you if you say it works, so... I'm just gonna merge this and if anything is broken, we'll fix in a follow up PR! I'm slightly tipsy, but I feel this is still a responsible decision ;-) Thanks so much @fcapovilla ! |
Don't worry, I also forgot to remind you like you asked me. :D |
Fixes issues #163
This feature adds the "managed_facilities" field to Users, so an admin can manage multiple facilities.