Улучшено удоство использования при продвижении статьи #16
Добавлены валидации для модели статьи и шаблон при успешном продвижении статьи.
This commit is contained in:
parent
dec7fb9af8
commit
ca6d0eaa5e
18
cms/migrations/0003_alter_article_link.py
Normal file
18
cms/migrations/0003_alter_article_link.py
Normal file
@ -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),
|
||||
),
|
||||
]
|
@ -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/')
|
||||
|
11
cms/templates/articles/created.html
Normal file
11
cms/templates/articles/created.html
Normal file
@ -0,0 +1,11 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
<div class="alert alert-success" role="alert">
|
||||
Статья продвинута успешно!
|
||||
</div>
|
||||
<a
|
||||
href="{% url 'new-article' %}"
|
||||
class="btn btn-primary">
|
||||
Продвиньте новую статью
|
||||
</a>
|
||||
{% endblock content %}
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user