-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add throttling to contact api endpoint #1231
Conversation
Signed-off-by: David Wallace <[email protected]>
Signed-off-by: David Wallace <[email protected]>
@@ -334,6 +334,11 @@ def visibility(self, request, pk=None): | |||
throttle_classes=[EmailThrottle]) | |||
def contact(self, request, pk): | |||
if settings.PROJECT_CONTACT: | |||
try: | |||
project = self.get_object() |
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.
The self.get_object()
(permission handling) is needed by the try ... except
is not. Since I am not sold on the caching thing yet, I will fix this in the original branch.
@@ -151,7 +151,8 @@ def test_contact_get_set(db, client): | |||
|
|||
@pytest.mark.parametrize('username,password', users) | |||
@pytest.mark.parametrize('project_id', projects) | |||
def test_contact_post(db, client, username, password, project_id): | |||
def test_contact_post(db, client,settings, username, password, project_id): | |||
assert settings.PROJECT_CONTACT |
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 do we need to check this here?
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.
it's easier to know what this test is for like that and what the feature flag does..
caching, with database caching as default, is not a required feature and may be an option only after the dependency on the compressor is resolved (eg. with bs5). So, it might be an option after 2.4 when there are any issues that can be resolved by caching. |
This PR adds throttling to the contact api endpoint.