diff --git a/API/main.py b/API/main.py index 38e4b6e..9af6bd4 100644 --- a/API/main.py +++ b/API/main.py @@ -1,9 +1,11 @@ import datetime +import pprint import random +import feedparser import jwt -from data.connect import init_db, connect, User, Document, DocumentCategory, Comment +from data.connect import init_db, connect, User, Document, DocumentCategory, Comment, Event from flask import Flask, Response, request, jsonify from flask_cors import CORS @@ -288,6 +290,43 @@ def get_employee_list(): } ) + return resp + + +@app.route("/rss") +def get_rss_feed(): + feed = feedparser.parse('https://naukatv.ru/rss') + + news_items = [] + for entry in feed.entries: + news_items.append({ + "title": entry.title, + "link": entry.link, + "description": entry.get("description", "Без описания"), + "pubDate": entry.get("published", "Нет даты"), + "image": entry.links[1].href, + }) + + return news_items + + +@app.route('/events') +def get_events(): + resp = [] + + with connect() as session: + events = session.query(Event).all() + users = session.query(User).all() + + for event in events: + user = random.choice(users) + + resp.append({ + 'title': event.title, + 'date': str(event.datetime_event.date()), + 'author': f'{user.last_name} {user.first_name}', + 'description': event.title, + }) return resp diff --git a/WEB/app/src/app/app.css b/WEB/app/src/app/app.css index e3708d5..1c63fdd 100644 --- a/WEB/app/src/app/app.css +++ b/WEB/app/src/app/app.css @@ -67,4 +67,54 @@ display: flex; flex-direction: row; justify-content: space-between; +} + +.content { + display: flex; + flex-direction: row; + +} + +.calendar-and-events { + width: 30%; +} + +.news { + width: 70%; +} + +.news-block { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 10px; +} + +.news-item { + width: 450px; + height: 400px; + background-color: #2f9836; + + display: flex; + flex-direction: column; + padding: 1vw; + + color: white; +} + +.image-rss { + width: 107%; + margin-top: -1vw; + margin-left: -1vw; + margin-right: -1vw; +} + +.calendar { + margin: 2vw; + border: 1px solid black; + height: 25vw; +} + +.events { + margin: 2vw; + border: 1px solid black; } \ No newline at end of file diff --git a/WEB/app/src/app/components/news-card.js b/WEB/app/src/app/components/news-card.js new file mode 100644 index 0000000..740091f --- /dev/null +++ b/WEB/app/src/app/components/news-card.js @@ -0,0 +1,13 @@ +const RSSFeed = (article, index) => { + + return ( +
{article.article.description}
+{article.article.pubDate}
+