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

Removing partner addresses #2218

Merged
merged 14 commits into from
Jan 31, 2024
Merged

Conversation

ivan-kocienski-gfsc
Copy link
Contributor

@ivan-kocienski-gfsc ivan-kocienski-gfsc commented Jan 29, 2024

Closes #2128

There is now a button to clear a partners address on the edit partner form:
Screenshot_2024-01-29_12-03-12

  • Admins can remove a partners address IF
    • partner has address
    • AND partner has at least one service area
    • AND
      • user is root
      • OR user owns partner
      • OR user is a partnership admin
      • OR user is a neighbourhood admin
        • AND user has partner address neighbourhood in their neighbourhood pool
  • Admins will be warned if removing a partner will de-list it from their partner list IF
    • admin is a neighbourhood OR partnership admin
    • AND user has no other neighbourhoods within the partners' service areas

@ivan-kocienski-gfsc ivan-kocienski-gfsc requested a review from a team January 29, 2024 12:10
@ivan-kocienski-gfsc ivan-kocienski-gfsc removed the request for review from a team January 29, 2024 12:25
@ivan-kocienski-gfsc ivan-kocienski-gfsc changed the title Removing partner addresses (WIP) Removing partner addresses Jan 29, 2024
If the admin is not root or does not own a partner then check to see if
the admin can "see" the partner via service areas. If they cannot then
warn the user that clearing the address will stop the admin from being
able to access this partner at all.
@ivan-kocienski-gfsc ivan-kocienski-gfsc requested a review from a team January 29, 2024 15:05
@ivan-kocienski-gfsc ivan-kocienski-gfsc changed the title (WIP) Removing partner addresses Removing partner addresses Jan 29, 2024
Copy link
Contributor

@r-ferrier r-ferrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this is a bit broken. Two things:

  • A partnership or neighbourhood admin should not be allowed to remove an address unless it's in their neighbourhood - this was to stop them taking over control of partners that other users also admin for.

  • once an address has been removed from a partner, it can never be put back! It's also now not possible to create a partner with an address.

See screenshot below:

Screenshot 2024-01-29 at 16 27 48

There's a few other smaller comments about the code I've left, let me know if you have any qs. I think it's possible it might be better for us to leave this now until the next sprint, especially as the permissions surrounding who can do what will become much simpler then, but the foundation work for this is really helpful and we can definitely extend upon this when we get to it!

app/javascript/controllers/partner_address_controller.js Outdated Show resolved Hide resolved
app/javascript/controllers/partner_address_controller.js Outdated Show resolved Hide resolved
.rubocop.yml Show resolved Hide resolved
app/models/partner.rb Show resolved Hide resolved
app/models/partner.rb Show resolved Hide resolved
app/models/partner.rb Show resolved Hide resolved
app/policies/partner_policy.rb Outdated Show resolved Hide resolved
app/views/admin/partners/_address_fields.html.erb Outdated Show resolved Hide resolved
- admins can see address form even if partner has no address
- update to policy governing who can trigger the clear address action
- allow only neighbourhood admins to clear an address if that address is
  in their neighbourhood pool
- removed redundant warning text
- removed console logging from JS controller
Copy link
Contributor

@r-ferrier r-ferrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like the address disappearing problem is fixed which is great but partnership/neighbourhood admins can still remove addresses that don't belong to them, which shouldn't be possible - have left some notes in the code as to why this might be.

app/models/partner.rb Show resolved Hide resolved
.rubocop.yml Show resolved Hide resolved
Copy link
Contributor

@r-ferrier r-ferrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wahey, this works! Looks great, so nice to be able to implement this in this sprint ✨

@ivan-kocienski-gfsc ivan-kocienski-gfsc merged commit 6bfea42 into main Jan 31, 2024
2 checks passed
@ivan-kocienski-gfsc ivan-kocienski-gfsc deleted the ik-2128-removing-partner-addresses branch January 31, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants