fix(signals.py): fix repo creation even if create_gitea_repo False
This commit is contained in:
@@ -152,6 +152,12 @@ def create_gitea_repo_on_lesson_creation(
|
||||
course = instance.module.course
|
||||
repo_name = f"course-{course.id}-lesson-{instance.id}"
|
||||
|
||||
if not instance.create_gitea_repo:
|
||||
logger.debug(
|
||||
f"Lesson {instance.title} is not marked for Gitea repository creation, skipping"
|
||||
)
|
||||
return
|
||||
|
||||
if not course.live:
|
||||
logger.debug(
|
||||
f"Course {course.title} is not live, skipping Gitea repository creation for lesson {instance.title}"
|
||||
@@ -203,11 +209,13 @@ def create_gitea_repo_on_lesson_creation(
|
||||
headers={"Authorization": f"token {os.getenv('GITEA_API_TOKEN')}"},
|
||||
)
|
||||
response.raise_for_status()
|
||||
repo_url = response.json().get("url", None)
|
||||
repo_url = response.json().get("html_url")
|
||||
|
||||
instance.gitea_repo_url = repo_url
|
||||
instance.save()
|
||||
instance.save(update_fields=["gitea_repo_url"])
|
||||
|
||||
logger.info(
|
||||
f"Successfully created Gitea repository for lesson {instance.title}"
|
||||
f"Successfully created Gitea repository for lesson {instance.title}: {repo_url}"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception(
|
||||
|
||||
Reference in New Issue
Block a user