From ca6d0eaa5e6ecc0c6bccba3b780f7cb38a50767b Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Mon, 19 Dec 2022 18:45:20 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=83=D0=B4=D0=BE=D1=81=D1=82=D0=B2=D0=BE=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B4?= =?UTF-8?q?=D0=B2=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=D0=B8=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлены валидации для модели статьи и шаблон при успешном продвижении статьи. --- cms/migrations/0003_alter_article_link.py | 18 ++++++++++++++++++ cms/models.py | 4 ++-- cms/templates/articles/created.html | 11 +++++++++++ cms/views.py | 5 ++--- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 cms/migrations/0003_alter_article_link.py create mode 100644 cms/templates/articles/created.html diff --git a/cms/migrations/0003_alter_article_link.py b/cms/migrations/0003_alter_article_link.py new file mode 100644 index 0000000..b6549c3 --- /dev/null +++ b/cms/migrations/0003_alter_article_link.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.4 on 2022-12-19 13:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0002_remove_article_title_article_link'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='link', + field=models.CharField(default='https://zakonvremeni.ru/news/', max_length=200), + ), + ] diff --git a/cms/models.py b/cms/models.py index 18197c5..e7f00a5 100644 --- a/cms/models.py +++ b/cms/models.py @@ -2,5 +2,5 @@ from django.db import models class Article(models.Model): - body = models.TextField() - link = models.CharField(max_length=300, default='https://zakonvremeni.ru/news/') + body = models.TextField(null=False) + link = models.CharField(max_length=200, default='https://zakonvremeni.ru/news/') diff --git a/cms/templates/articles/created.html b/cms/templates/articles/created.html new file mode 100644 index 0000000..8d53679 --- /dev/null +++ b/cms/templates/articles/created.html @@ -0,0 +1,11 @@ +{% extends 'base.html' %} +{% block content %} + + + Продвиньте новую статью + +{% endblock content %} \ No newline at end of file diff --git a/cms/views.py b/cms/views.py index 7cd6a56..9ae4f7d 100644 --- a/cms/views.py +++ b/cms/views.py @@ -2,7 +2,7 @@ import os from json import JSONEncoder import requests -from django.http import JsonResponse, HttpRequest +from django.http import HttpRequest from django.shortcuts import render from django.utils.decorators import method_decorator from django.views import View @@ -78,8 +78,7 @@ class ArticleView(View): self._promote_to_telegram(article) self._promote_to_ok(article) self._promote_to_vk(article) - response = {'ok': True} - return JsonResponse(response) + return render(request, template_name='articles/created.html') def new_article(request):