Skip to content

Commit

Permalink
get or create environment
Browse files Browse the repository at this point in the history
  • Loading branch information
hblankenship committed Oct 11, 2024
1 parent c494b0b commit 7dd3f9a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions dojo/api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2175,9 +2175,12 @@ def set_context(
context = dict(data)
# update some vars
context["scan"] = data.pop("file", None)
context["environment"] = Development_Environment.objects.get(
# The assumption below is that a Development environment will be gotten or created, whether of the one provided or the Development environment
# because the Development environment always exists...
# If this fails, there are bigger problems.
context["environment"] = Development_Environment.objects.get_or_create(
name=data.get("environment", "Development"),
)
)[0]
# Set the active/verified status based upon the overrides
if "active" in self.initial_data:
context["active"] = data.get("active")
Expand Down Expand Up @@ -2454,9 +2457,12 @@ def set_context(
context = dict(data)
# update some vars
context["scan"] = data.get("file", None)
context["environment"] = Development_Environment.objects.get(
# The assumption below is that a Development environment will be gotten or created, whether of the one provided or the Development environment
# because the Development environment always exists...
# If this fails, there are bigger problems.
context["environment"] = Development_Environment.objects.get_or_create(
name=data.get("environment", "Development"),
)
)[0]
# Set the active/verified status based upon the overrides
if "active" in self.initial_data:
context["active"] = data.get("active")
Expand Down

0 comments on commit 7dd3f9a

Please sign in to comment.