Skip to content
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

Merged
merged 6 commits into from
Mar 1, 2018
Merged

Multi facilities #189

merged 6 commits into from
Mar 1, 2018

Conversation

fcapovilla
Copy link
Collaborator

Fixes issues #163
This feature adds the "managed_facilities" field to Users, so an admin can manage multiple facilities.

@fcapovilla fcapovilla requested a review from bglusman February 24, 2018 18:40
@sourcelevel-bot
Copy link

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) }

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

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

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.

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

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

@sourcelevel-bot
Copy link

Ebert has finished reviewing this Pull Request and has found:

  • 5 fixed issues! 🎉

You can see more details about this review at https://ebertapp.io/github/openpantry/open_pantry/pulls/189.

Copy link
Collaborator

@bglusman bglusman left a 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! 💜💛💚♥️💙💖🖤

@bglusman
Copy link
Collaborator

bglusman commented Mar 1, 2018

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 !

@bglusman bglusman merged commit 87866f6 into openpantry:master Mar 1, 2018
@fcapovilla
Copy link
Collaborator Author

Don't worry, I also forgot to remind you like you asked me. :D
Thank you for merging this PR. If you see any problem that seem related to this, just tell me and I'll try to fix it as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants