-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform the get sustaining members tag to a scheduled job
- Loading branch information
Showing
5 changed files
with
48 additions
and
17 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from plugins.tasks.generate_plugins_xml import * # noqa | ||
from plugins.tasks.update_qgis_versions import * # noqa | ||
from plugins.tasks.rebuild_search_index import * # noqa | ||
from plugins.tasks.get_sustaining_members import * # noqa |
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,32 @@ | ||
from celery import shared_task | ||
from celery.utils.log import get_task_logger | ||
import requests | ||
from bs4 import BeautifulSoup | ||
from django.conf import settings | ||
import os | ||
|
||
logger = get_task_logger(__name__) | ||
|
||
@shared_task | ||
def get_sustaining_members(): | ||
""" | ||
Get the Sustaining members HTML section from the new website | ||
""" | ||
try: | ||
url = 'https://qgis.org' | ||
response = requests.get(url) | ||
response.raise_for_status() | ||
soup = BeautifulSoup(response.text, 'html.parser') | ||
|
||
# Extract the section by the specified class name | ||
section = soup.select_one('section.section') | ||
|
||
if section: | ||
template_path = os.path.join(settings.SITE_ROOT, 'templates/flatpages/sustaining_members.html') | ||
with open(template_path, 'w') as f: | ||
f.write(section.prettify()) | ||
logger.info(f"get_sustaining_members: Section saved to {template_path}") | ||
else: | ||
logger.info("get_sustaining_members: Section not found") | ||
except requests.RequestException as e: | ||
logger.info(f"get_sustaining_members: {e}") |
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