From ff31142be12ffc239c53193e80ab75795ceb2733 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Fri, 21 Jul 2023 13:34:17 +0300 Subject: [PATCH] add event to production stream on repo creation fix skipping streams if they are in stasis --- .../management/commands/advance_git_repos.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scipost_django/production/management/commands/advance_git_repos.py b/scipost_django/production/management/commands/advance_git_repos.py index 77bec1252..fff380e39 100644 --- a/scipost_django/production/management/commands/advance_git_repos.py +++ b/scipost_django/production/management/commands/advance_git_repos.py @@ -23,7 +23,7 @@ import tarfile from base64 import b64encode -from production.models import ProofsRepository +from production.models import ProofsRepository, ProductionUser, ProductionEvent class Command(BaseCommand): @@ -144,6 +144,15 @@ class Command(BaseCommand): } ) + # Add event to the production stream + if system_user := ProductionUser.objects.get(user__username="system"): + ProductionEvent.objects.create( + stream=repo.stream, + event="status", + comments=f"Created git repository for proofs.", + noted_by=system_user, + ) + self.stdout.write( self.style.SUCCESS(f"Created git repository at {repo.git_path}") ) @@ -498,9 +507,11 @@ class Command(BaseCommand): # Create the repos repos_to_be_created = repos.filter( status=ProofsRepository.PROOFS_REPO_UNINITIALIZED - stream__in_stasis=False ) for repo in repos_to_be_created: + # Skip repos whose streams that are in stasis + if repo.stream.in_stasis: + continue try: self._create_git_repo(repo) repo.status = ProofsRepository.PROOFS_REPO_CREATED -- GitLab