Новости
This commit is contained in:
1 parent
99145b3b9c
commit
95a2ce6bf9
5 files changed
+79
-64
No files matched your search
+20
-35
@@ -5,6 +5,7 @@ from rest_framework.views import APIView
|
||||
from .renderers import UserJSONRenderer
|
||||
from userauth.models import *
|
||||
from navigation.models import *
|
||||
from navigation.serializers import *
|
||||
from userauth.serializers import *
|
||||
from .models import *
|
||||
from .serializers import *
|
||||
@@ -14,43 +15,27 @@ import pandas as pd
|
||||
class testView(APIView):
|
||||
|
||||
def get(self, request):
|
||||
from datetime import date
|
||||
|
||||
|
||||
manbrd = DictEmployee.objects.using('user_directory').filter(birthdate__month=date.today().month)
|
||||
if len(manbrd) > 0 :
|
||||
nowday= manbrd.filter(birthdate__day=date.today().day)
|
||||
|
||||
brdimage = BirthdayImage.objects.order_by("?")[:len(nowday)+1]
|
||||
|
||||
newsqueryset = News.objects.all().order_by('cdate')
|
||||
|
||||
|
||||
|
||||
for x in newsqueryset:
|
||||
a=model_to_dict(x)
|
||||
# a['link']= str(x.link.url)
|
||||
# a['show'] = False
|
||||
# a['showComment'] = False
|
||||
# a['author'] = model_to_dict(DictEmployee.objects.using('user_directory').get(login=x.author.username))
|
||||
a['scores'] = [{"score":y.score, "user":y.author.username} for y in x.get_news.all()]
|
||||
a['comment'] = [{"author":model_to_dict(DictEmployee.objects.using('user_directory').get(login=k.author.username)),
|
||||
"cdate":k.cdate,
|
||||
"text":k.text,
|
||||
"id": k.pk
|
||||
} for k in x.get_comment_news.all()
|
||||
]
|
||||
|
||||
allbirthday = {
|
||||
"title":'Дни рождения в это месяце ',
|
||||
"text": "\n".join([f"{x.birthdate} - {x.fio}" for x in manbrd]),
|
||||
"link": "/media/"+str(brdimage[0].img),
|
||||
"published": 'true',
|
||||
|
||||
"sender": "/media/default/dr.png",
|
||||
}
|
||||
|
||||
|
||||
if len(nowday) > 0 :
|
||||
|
||||
|
||||
brdtext = BirthdayText.objects.order_by("?")[:len(nowday)]
|
||||
# print( brdtext[].text, '=====================================')
|
||||
birthday = []
|
||||
for k in nowday:
|
||||
|
||||
birthday.append({
|
||||
"title":'Поздравляем!',
|
||||
"text": f"{k.fio} {brdtext[0].text}",
|
||||
"link": "/media/"+str(brdimage[0].img),
|
||||
"published": 'true',
|
||||
"sender": "/media/default/dr.png",
|
||||
})
|
||||
|
||||
|
||||
return Response(birthday)
|
||||
return Response(NewsSerializer(newsqueryset, many=True).data)
|
||||
# from .serializers import RegistrationSerializer
|
||||
|
||||
# class RegistrationAPIView(APIView):
|
||||
|
||||
Reference in new issue
Block a user