-
Notifications
You must be signed in to change notification settings - Fork 27
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 DynamicHTML options and endpoints for Cyberstorm #1037
base: master
Are you sure you want to change the base?
Add DynamicHTML options and endpoints for Cyberstorm #1037
Conversation
3066f62
to
c613e5a
Compare
if ( | ||
self.kwargs["placement"].startswith("cyberstorm_") | ||
and self.kwargs["placement"] in DynamicPlacement.options() | ||
): |
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.
no need to check for the cyberstorm prefix, just check if the kwarg is a valid option. also invert the if clause.
is_active=True, | ||
).order_by("ordering") | ||
if len(dynamic_htmls) != 0: | ||
return {"dynamic_htmls": [escapejs(dh.content) for dh in dynamic_htmls]} |
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 are we escaping? shouldn't be necessary here, in fact it's probably the opposite of what we want
dynamic_htmls = serializers.ListField(child=serializers.CharField()) | ||
|
||
|
||
class DynamicHTMLAPIView(CyberstormAutoSchemaMixin, RetrieveAPIView): |
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.
There's no reason to use the RetrieveAPIView
base class when you're not returning a db model instance. Use the GenericAPIView
instead and just implement the get
method on it.
path( | ||
"dynamichtml/<str:placement>/", | ||
DynamicHTMLAPIView.as_view(), | ||
name="cyberstorm.dynamichtml", | ||
), |
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.
Perhaps we should have an API view which returns all active placements, rather than one view per placement ID? Would make it only require 1 request on the clients
No description provided.