diff --git a/cms/forms.py b/cms/forms.py
new file mode 100644
index 0000000..fdefe50
--- /dev/null
+++ b/cms/forms.py
@@ -0,0 +1,5 @@
+from django.forms import ModelForm
+
+
+class ArticleForm(ModelForm):
+ pass
diff --git a/cms/templates/articles/new.html b/cms/templates/articles/new.html
new file mode 100644
index 0000000..d125fec
--- /dev/null
+++ b/cms/templates/articles/new.html
@@ -0,0 +1,13 @@
+
Заполните данные статьи для продвижения в соц. сетях
+
\ No newline at end of file
diff --git a/cms/urls.py b/cms/urls.py
index b1c5b39..0f5fd29 100644
--- a/cms/urls.py
+++ b/cms/urls.py
@@ -1,7 +1,8 @@
from django.urls import path
-from .views import ArticleView
+from .views import ArticleView, new_article
urlpatterns = [
- path('articles/', ArticleView.as_view())
+ path('articles/', ArticleView.as_view(), name='create-article'),
+ path('articles/new/', new_article, name='new-article'),
]
diff --git a/cms/views.py b/cms/views.py
index b71ab91..b59142c 100644
--- a/cms/views.py
+++ b/cms/views.py
@@ -2,9 +2,11 @@ import os
from json import JSONDecoder, JSONEncoder
import requests
-from django.http import JsonResponse
+from django.http import JsonResponse, HttpRequest
+from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views import View
+from django.urls import reverse
from django.views.decorators.csrf import csrf_exempt
from cms.models import Article
@@ -69,11 +71,20 @@ class ArticleView(View):
gid='70000001426867',
attachment=encoded_attachments)
- def post(self, request):
- article_data = JSONDecoder().decode(request.body.decode())
- article = Article.objects.create(**article_data)
+ def post(self, request: HttpRequest):
+ post_data = request.POST
+ article = Article.objects.create(body=post_data['body'],
+ link=post_data['link'])
self._promote_to_telegram(article)
self._promote_to_ok(article)
self._promote_to_vk(article)
response = {'ok': True}
return JsonResponse(response)
+
+
+def new_article(request):
+ return render(request,
+ template_name='articles/new.html',)
+
+
+