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

Add DynamicHTML options and endpoints for Cyberstorm #1037

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Oksamies
Copy link
Contributor

No description provided.

Copy link
Contributor Author

Oksamies commented May 23, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Oksamies Oksamies force-pushed the 05-24-Add_DynamicHTML_options_and_endpoints_for_Cyberstorm branch from 3066f62 to c613e5a Compare May 23, 2024 21:38
Comment on lines +22 to +25
if (
self.kwargs["placement"].startswith("cyberstorm_")
and self.kwargs["placement"] in DynamicPlacement.options()
):
Copy link
Member

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]}
Copy link
Member

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):
Copy link
Member

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.

Comment on lines +22 to +26
path(
"dynamichtml/<str:placement>/",
DynamicHTMLAPIView.as_view(),
name="cyberstorm.dynamichtml",
),
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants