-
Notifications
You must be signed in to change notification settings - Fork 0
feat: admin teacher/staff CRUD ops #129
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
base: master
Are you sure you want to change the base?
Conversation
fny
left a comment
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.
Added some changes. I'll look at the front end shortly.
|
|
||
| ensure_or_forbidden! { current_user.admin_at?(location) } | ||
|
|
||
| location_account.destroy |
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 destroy! so that this doesn't silently fail
| is_mobile_taken = User.mobile_taken?(request_json[:mobile_number]) | ||
| is_email_taken = User.email_taken?(request_json[:email]) | ||
|
|
||
| puts request_json[:mobile_number] |
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.
Why is this here!?
| user = User.find(params[:user_id]) | ||
|
|
||
| ensure_or_forbidden! { current_user.admin_at? location } | ||
| ensure_or_forbidden! { user.location_accounts.exists?(location_id: location.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.
- You shouldn't use a forbidden for this. This should be a not found error.
- You don't need this given the check above
|
|
||
| patch '/v1/locations/:location_id/users/:user_id' do | ||
| location = Location.find_by_id_or_permalink!(params[:location_id]) | ||
| user = User.find(params[:user_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.
location.users.find(params[:user_id])
| puts is_mobile_taken | ||
| puts is_email_taken | ||
|
|
||
| if is_mobile_taken || is_email_taken |
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.
Instead of this check, create the user with the location account embedded. You should add a checkbox in the view to allow people to decide whether to send an invite.
user = User.new(...., location_accounts: LocationAccount.new(...))
if user.save
....
else
error_response(user)
end
|
|
||
| delete '/v1/locations/:location_id/users/:user_id' do | ||
| location = Location.find_by_id_or_permalink!(params[:location_id]) | ||
| user = User.find(params[:user_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.
same thing as before location.users.find(...)
| locationAccount?: LocationAccount | null | ||
| } | ||
|
|
||
| export default function AdminUserEditPage(props: F7Props) { |
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.
Add return types to exports: here it's JSX.Element
No description provided.