Compare commits
4 Commits
delayed_pu
...
master
Author | SHA1 | Date |
---|---|---|
Alexei | f3345f6da5 | 1 year ago |
Alexei | 7c7053f47e | 1 year ago |
Alexei | 867f999174 | 1 year ago |
Артур Галямов | 75af7b0b79 | 2 years ago |
16 changed files with 451 additions and 464 deletions
@ -0,0 +1,3 @@ |
|||||||
|
Этот продукт является ОБЩЕСТВЕННЫМ ДОСТОЯНИЕМ и может быть использован КАК ЕСТЬ, со всеми достоинствами и недостатками, полностью или частично, кем угодно и в каких угодно целях БЕЗ КАКИХ-ЛИБО ОГРАНИЧЕНИЙ. |
||||||
|
|
||||||
|
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. |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 24 KiB |
@ -1,3 +0,0 @@ |
|||||||
from .celery import app as celery_app |
|
||||||
|
|
||||||
__all__ = ('celery_app') |
|
@ -1,15 +0,0 @@ |
|||||||
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}') |
|
@ -1,19 +0,0 @@ |
|||||||
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 |
|
@ -1,20 +0,0 @@ |
|||||||
{% 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