-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
[api] /receive/{id}/ > /topology/{id}/receive/ #62 #79
Conversation
@@ -75,7 +75,15 @@ def post(self, request, pk, format=None): | |||
'with message "%s"' | |||
) % (topology.get_parser_display(), e.__class__.__name__, e) | |||
return Response({'detail': error}, status=400) | |||
return Response({'detail': _('data received successfully')}) | |||
success_message = 'data received successfully' |
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.
should be success_message = _('data received successfully')
.
The marking for translation must be done this way, I think otherwise the i18n system would not recognize which string to be made translatable.
warning = ( | ||
". But this url is deprecated and will soon be removed." | ||
" We now use /topology/{id}/receive/" | ||
) |
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.
please also log the warning:
logger = logging.getLogger(__name__)
logger.warning( ....... )
" We now use /topology/{id}/receive/" | ||
) | ||
return Response({'detail': (success_message + warning)}) | ||
return Response({'detail': _(success_message)}) |
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.
again... do not repeat yourself.
if request.path == deprecated_url:
success_message = success_message + warning
return Response({'detail': success_message})
if request.path == deprecated_url: | ||
warning = ( | ||
". But this url is deprecated and will soon be removed." | ||
" We now use /topology/{id}/receive/" |
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.
Simplify: "This URL is depercated and will be removed in future versions, use /topology/{id}/receive/".
Make translatable at the moment of defining it here as well.
warning = _('This URL is depercated and will be removed in future versions, use /topology/{id}/receive/')
success_message = '{success_message}. {warning}'
3359292
to
1940f9c
Compare
) | ||
logger.warning(warning) | ||
success_message = f'{success_message}. {warning}' | ||
return Response({'detail': _(success_message)}) |
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.
should be success_message
instead of _(success_message)
because it was already marked as translatable before
if request.path == deprecated_url: | ||
warning = _( | ||
"This URL is depercated and will be removed in " | ||
"future versions, use /topology/{id}/receive/" |
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 single quotes for consistency
6a8a2a3
to
8cc436c
Compare
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.
if request.path == deprecated_url: | ||
warning = _( | ||
'This URL is depercated and will be removed in ' | ||
'future versions, use /topology/{id}/receive/' |
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.
this here should be /api/v1/topology/{id}/receive/
self.node_model.objects.all().delete() | ||
data = self._load('static/netjson-1-link.json') | ||
t = self.topology_model.objects.first() | ||
path = f'/api/v1/receive/{t.pk}/?key=test' |
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.
please use reverse()
, do not hardcode URLs
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.
@nemesisdesign since we have two urls mapping to same view (because we are supporting backward compatibility), reverse
will get confused which url to use since both of them have the same view name.
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.
@NoumbissiValere the solution is to change the old URL to have receive_topology_deprecated
and use reverse
here.
5d26e53
to
1e34993
Compare
@@ -269,6 +269,7 @@ def test_monitoring_integration(self, *args): | |||
'openwisp_monitoring.device', | |||
'openwisp_monitoring.check', | |||
'openwisp_controller.connection', | |||
'openwisp_notifications', |
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.
this test was failing without this line
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.
please remove this and the other thing related to markdown, if there's an issue with this part it must be resolved in another patch, not in this one
requirements-test.txt
Outdated
@@ -2,3 +2,4 @@ coveralls | |||
responses | |||
freezegun | |||
openwisp-utils[qa]~=0.5.1 | |||
markdown |
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.
needed by openwisp-notifications
during testing
@@ -269,6 +269,7 @@ def test_monitoring_integration(self, *args): | |||
'openwisp_monitoring.device', | |||
'openwisp_monitoring.check', | |||
'openwisp_controller.connection', | |||
'openwisp_notifications', |
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.
please remove this and the other thing related to markdown, if there's an issue with this part it must be resolved in another patch, not in this one
self.node_model.objects.all().delete() | ||
data = self._load('static/netjson-1-link.json') | ||
t = self.topology_model.objects.first() | ||
path = f'/api/v1/receive/{t.pk}/?key=test' |
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.
@NoumbissiValere the solution is to change the old URL to have receive_topology_deprecated
and use reverse
here.
1e34993
to
aee4d01
Compare
e531b25
to
fa23c13
Compare
@@ -75,7 +77,16 @@ def post(self, request, pk, format=None): | |||
'with message "%s"' | |||
) % (topology.get_parser_display(), e.__class__.__name__, e) | |||
return Response({'detail': error}, status=400) | |||
return Response({'detail': _('data received successfully')}) | |||
success_message = _('data received successfully') | |||
deprecated_url = f'/api/v1/receive/{pk}/' |
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.
do not hardcode URLs, use reverse()
if request.path == deprecated_url: | ||
warning = _( | ||
'This URL is depercated and will be removed in ' | ||
'future versions, use /api/v1/topology/{id}/receive/' |
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.
do not hardcode URLs, use reverse()
Closed issue by renaming /receive/{id}/ to /topology/{id}/receive/ while ensuring backward compatibility with warnings. Closes #62
fa23c13
to
c874632
Compare
Closed issue by renaming /receive/{id}/ to /topology/{id}/receive/
while ensuring backward compatibility with warnings.
Closes #62