Skip to content

Commit

Permalink
Merge pull request #709 from Gary-Community-Ventures/bug/pull_validat…
Browse files Browse the repository at this point in the history
…ions_update

Ignore frozen when pulling validations
  • Loading branch information
CalebPena authored Jan 24, 2025
2 parents 0bcc472 + 7d19096 commit e5a969a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions screener/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ class Meta:
)
create_only_fields = ("external_id", "is_test", "referrer_code", "white_label")

def __init__(self, *args, **kwargs):
self.force = kwargs.pop("force", False)
super().__init__(*args, **kwargs)

def validate(self, attrs):
white_label_code = attrs.pop("white_label")["code"]
white_label = WhiteLabel.objects.get(code=white_label_code)
Expand Down
6 changes: 4 additions & 2 deletions validations/management/commands/pull_validations.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.core.management.base import BaseCommand
from getpass import getpass
import requests

from django.db import transaction
from screener.models import Screen
from screener.serializers import ScreenSerializer
from validations.models import Validation
from validations.serializers import ValidationSerializer
import requests


class Command(BaseCommand):
Expand All @@ -18,6 +19,7 @@ def add_arguments(self, parser):
help="Domain of the environment to pull from",
)

@transaction.atomic
def handle(self, *args, **options):
domain = options["domain"]
api_key = getpass("API key: ")
Expand All @@ -42,7 +44,7 @@ def _upsert_screen(self, uuid: str, domain: str, api_key: str):
try:
# update
screen = Screen.objects.get(uuid=uuid)
serializer = ScreenSerializer(screen, data=remote_screen)
serializer = ScreenSerializer(screen, data=remote_screen, force=True)
except Screen.DoesNotExist:
# create
serializer = ScreenSerializer(data=remote_screen)
Expand Down

0 comments on commit e5a969a

Please sign in to comment.