-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: generate 1wg-charters files via celery (#7428)
* refactor: move helpers to utils.py * feat: task to generate 1wg-charters files * refactor: use 1wg-charter files in views * chore: create periodic task + slight renaming * chore: remove wgets from bin/hourly * test: refactor tests for new task/views * fix: fix bug uncovered by tests * chore: remove unused imports * fix: clean whitespace in draft titles * fix: return verbatim bytes for charter views * chore: remove now-empty /bin/hourly 🎉
- Loading branch information
1 parent
ffb9eb1
commit a5f44df
Showing
9 changed files
with
186 additions
and
127 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright The IETF Trust 2024, All Rights Reserved | ||
# | ||
# Celery task definitions | ||
# | ||
from celery import shared_task | ||
from pathlib import Path | ||
|
||
from django.conf import settings | ||
from django.template.loader import render_to_string | ||
|
||
from .models import Group | ||
from .utils import fill_in_charter_info, fill_in_wg_drafts, fill_in_wg_roles | ||
|
||
|
||
@shared_task | ||
def generate_wg_charters_files_task(): | ||
areas = Group.objects.filter(type="area", state="active").order_by("name") | ||
groups = Group.objects.filter(type="wg", state="active").exclude(parent=None).order_by("acronym") | ||
for group in groups: | ||
fill_in_charter_info(group) | ||
fill_in_wg_roles(group) | ||
fill_in_wg_drafts(group) | ||
for area in areas: | ||
area.groups = [g for g in groups if g.parent_id == area.pk] | ||
charter_path = Path(settings.CHARTER_PATH) | ||
(charter_path / "1wg-charters.txt").write_text( | ||
render_to_string("group/1wg-charters.txt", {"areas": areas}), | ||
encoding="utf8", | ||
) | ||
(charter_path / "1wg-charters-by-acronym.txt").write_text( | ||
render_to_string("group/1wg-charters-by-acronym.txt", {"groups": groups}), | ||
encoding="utf8", | ||
) |
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
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
Oops, something went wrong.