mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-15 01:23:25 -05:00
Rewrite cache decorator to reference args by name
`@cache.delete('user', 'user_id')` is easier to read and understand than
`@cache.delete('user', key_from_args=[1])`. This will become even more
apparent if we have to start doing stuff like `key_from_args=[1, 5]`,
which is a lot more opaque than just saying
`'service_id', 'template_id'`.
It does make the implementation a bit more complex, but I’m not too
worried about that because:
- the tests are solid
- it’s nicely encapsulated
This commit is contained in:
@@ -44,8 +44,8 @@ class InviteApiClient(NotifyAdminAPIClient):
|
||||
self.post(url='/service/{0}/invite/{1}'.format(service_id, invited_user_id),
|
||||
data=data)
|
||||
|
||||
@cache.delete('service')
|
||||
@cache.delete('user', key_from_args=[1])
|
||||
@cache.delete('service', 'service_id')
|
||||
@cache.delete('user', 'invited_user_id')
|
||||
def accept_invite(self, service_id, invited_user_id):
|
||||
data = {'status': 'accepted'}
|
||||
self.post(url='/service/{0}/invite/{1}'.format(service_id, invited_user_id),
|
||||
|
||||
Reference in New Issue
Block a user