Skip to content
Snippets Groups Projects
Commit aa41c377 authored by OndraRehounek's avatar OndraRehounek Committed by jan.bednarik
Browse files

Celery from env, working management command again

parent 1ec14937
Branches
No related tags found
2 merge requests!442Release,!432Feature/majak imports
......@@ -99,6 +99,16 @@ Kalendář se stáhne při uložení modelu obsahujícího `CalendarMixin`.
Appka přidává management command `update_callendars`, který stahuje a updatuje
kalendáře. Je třeba ho pravidelně volat na pozadí (přes CRON).
### Celery (Import z Jekyllu)
Import z Jekyll GitHub repozitářů pirátských webů je řešen asynchroně přes Celery.
Celery využívá Redis, který může běžet např. lokálně, typicky 6379:
V envu pak je pak potřeba mít nastavený Celery broker:
```
CELERY_BROKER_URL=redis://localhost:6379/6
CELERY_RESULT_BACKEND=redis://localhost:6379/6
```
### Stránka 404
Pokud je třeba vlastní 404 pro web, stačí do kořenové `xxxHomePage` webu
......
......@@ -13,13 +13,14 @@ from urllib.error import HTTPError
import markdown.serializers
import yaml
from django.contrib.messages import ERROR, INFO, SUCCESS, WARNING
from django.contrib.messages import INFO, SUCCESS, WARNING
from django.core.files.images import ImageFile
from django.utils import timezone
from markdown import Markdown
from markdown.extensions import Extension
from markdown.inlinepatterns import InlineProcessor
from wagtail.contrib.redirects.models import Redirect
from wagtail.core.models.collections import Collection
from wagtail.core.rich_text import RichText
from wagtail.images.models import Image
from yaml.scanner import ScannerError
......
from django.core.management.base import BaseCommand
from wagtail.core.models.collections import Collection
from ...jekyll_import import perform_import
from ...jekyll_import import JekyllArticleImporter
class Command(BaseCommand):
......@@ -34,7 +33,18 @@ class Command(BaseCommand):
type=bool,
help="Zda je o testovací běh.",
)
parser.add_argument(
"--use-git",
default=True,
type=bool,
help="Zda je o testovací běh.",
)
def handle(self, *args, **options):
pass
# perform_import() # TODO
return JekyllArticleImporter(
article_parent_page_id=options["clanky_id"],
collection_id=options["kolekce_id"],
url=options["path"],
dry_run=options["dry_run"],
use_git=options["use_git"],
).perform_import()
......@@ -192,8 +192,8 @@ CACHES["renditions"]["TIMEOUT"] = 60 * 60 * 24
# CELERY
# ------------------------------------------------------------------------------
CELERY_BROKER_URL = "redis://localhost:6379/6" # TODO set from env
CELERY_RESULT_BACKEND = "redis://localhost:6379/6"
CELERY_BROKER_URL = env.str("CELERY_BROKER_URL")
CELERY_RESULT_BACKEND = env.str("CELERY_RESULT_BACKEND")
CELERY_ACCEPT_CONTENT = ["application/json"]
CELERY_RESULT_SERIALIZER = "json"
CELERY_TASK_SERIALIZER = "json"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment