Created
November 15, 2021 21:02
-
-
Save sminnee/cfa46e8b3b8b5d1c909349eb5a9bd91d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/server/facilities/models/assets.py b/server/facilities/models/assets.py | |
index 4f05dfec..f982e579 100644 | |
--- a/server/facilities/models/assets.py | |
+++ b/server/facilities/models/assets.py | |
@@ -26,9 +26,9 @@ class AssetEstimatedAge(Enum): | |
GREATER_THAN_TWENTY = '20+ years' | |
class AssetDuplicateTaskMode(Enum): | |
- link = 'link' | |
- duplicate = 'duplicate' | |
- none = 'none' | |
+ LINK = 'link' | |
+ DUPLICATE = 'duplicate' | |
+ NONE = 'none' | |
def from_string(value: str): | |
try: | |
@@ -122,11 +122,11 @@ class PropertyAsset(models.Model): | |
for resource in self.resources.all().iterator(): | |
resource.clone(asset_id=cloned.pk) | |
- if taskMode == AssetDuplicateTaskMode.link: | |
+ if taskMode == AssetDuplicateTaskMode.LINK: | |
for content in self.work_order_content.all().iterator(): | |
content.assets.add(cloned) | |
- elif taskMode == AssetDuplicateTaskMode.duplicate: | |
+ elif taskMode == AssetDuplicateTaskMode.DUPLICATE: | |
for content in self.work_order_content.all().iterator(): | |
cloned_work_order = content.work_order.clone() | |
cloned_work_order.first_content.assets.add(cloned) | |
diff --git a/server/facilities/views/assets.py b/server/facilities/views/assets.py | |
index 018f6bd4..6d1deb41 100644 | |
--- a/server/facilities/views/assets.py | |
+++ b/server/facilities/views/assets.py | |
@@ -46,7 +46,7 @@ class AssetViewSet(viewsets.ModelViewSet): | |
def duplicate(self, request: Request, *args, **kwargs): | |
"""Duplicate an asset - the post var taskMode can be 'none','link',or 'duplicate'""" | |
- taskMode = AssetDuplicateTaskMode.from_string(request.POST["taskMode"] or "none") | |
+ taskMode = AssetDuplicateTaskMode.from_string(request.POST["taskMode"]) | |
if taskMode == None: | |
return Response({'error': 'Incorrect taskMode value'}, status=status.HTTP_400_BAD_REQUEST) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment