Compare commits
3 Commits
master
...
delayed_pu
Author | SHA1 | Date |
---|---|---|
Fynjy | 33ede3992a | 8 months ago |
Fynjy | b4452019ef | 8 months ago |
Fynjy | 8ba795a2d3 | 8 months ago |
16 changed files with 464 additions and 451 deletions
@ -1,3 +0,0 @@ |
|||||||
Этот продукт является ОБЩЕСТВЕННЫМ ДОСТОЯНИЕМ и может быть использован КАК ЕСТЬ, со всеми достоинствами и недостатками, полностью или частично, кем угодно и в каких угодно целях БЕЗ КАКИХ-ЛИБО ОГРАНИЧЕНИЙ. |
|
||||||
|
|
||||||
This product is PUBLIC DOMAIN and may be used AS IS, with all advantages and faults, in whole or in part, by anyone for any purpose, WITHOUT ANY CONDITIONS. |
|
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 24 KiB |
@ -0,0 +1,3 @@ |
|||||||
|
from .celery import app as celery_app |
||||||
|
|
||||||
|
__all__ = ('celery_app') |
@ -0,0 +1,15 @@ |
|||||||
|
from __future__ import absolute_import, unicode_literals |
||||||
|
import os |
||||||
|
from celery import Celery |
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crossposting_backend.settings') |
||||||
|
|
||||||
|
CELERY_TIMEZONE = 'Europe/Moscow' |
||||||
|
|
||||||
|
app = Celery('cms') |
||||||
|
app.config_from_object('django.conf:settings', namespace='CELERY') |
||||||
|
app.autodiscover_tasks() |
||||||
|
|
||||||
|
@app.task(bind=True) |
||||||
|
def debug_task(self): |
||||||
|
print(f'Requestgit {self.request!r}') |
@ -0,0 +1,19 @@ |
|||||||
|
from cms import promoters |
||||||
|
from cms.models import Article |
||||||
|
from celery import shared_task |
||||||
|
|
||||||
|
|
||||||
|
@shared_task |
||||||
|
def promote_post(article_id): |
||||||
|
article = Article.objects.get(id=article_id) |
||||||
|
article.is_published = True |
||||||
|
article.save() |
||||||
|
marketer = promoters.Marketer(article) |
||||||
|
marketer.promote() |
||||||
|
|
||||||
|
|
||||||
|
@shared_task |
||||||
|
def delayed_post(article_id, publication_time): |
||||||
|
article = Article.objects.get(id=article_id) |
||||||
|
celery_task = promote_post.apply_async(args=[article.id], eta=publication_time) |
||||||
|
return celery_task.id |
@ -0,0 +1,20 @@ |
|||||||
|
{% extends 'base.html' %} |
||||||
|
{% load bootstrap5 %} |
||||||
|
{% block content %} |
||||||
|
<div class="container"> |
||||||
|
<a href="{% url 'new-article' %}" class="btn btn-primary">Вернуться</a> |
||||||
|
|
||||||
|
{% for article in post %} |
||||||
|
<div class="card mb-3"> |
||||||
|
<div class="card-body"> |
||||||
|
<p class="card-text">{{ article.body }}</p> |
||||||
|
<a href="{{ article.link }}">{{ article.link }}</a> |
||||||
|
<p class="card-text"><small class="text-muted">Дата публикации: {{ article.publication_time }}</small></p> |
||||||
|
{% if user.is_authenticated %} |
||||||
|
<a href="{% url 'article_delete' article.id %}" class="btn btn-danger">Удалить</a> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endfor %} |
||||||
|
</div> |
||||||
|
{% endblock content %} |
Loading…
Reference in new issue