Skip to content
Snippets Groups Projects
Commit 1c80eb1e authored by Julian's avatar Julian
Browse files

work on dashboardfeeds

parent b80b839b
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,14 @@ ...@@ -24,6 +24,14 @@
</div> </div>
{% endfor %} {% endfor %}
<div class="row">
{% for widget in widgets %}
<div class="col s12 m12 l6 xl4">
{{ widget }}
</div>
{% endfor %}
</div>
<div class="row"> <div class="row">
<div class="col s12 m6"> <div class="col s12 m6">
<h5>{% blocktrans %}Last activities{% endblocktrans %}</h5> <h5>{% blocktrans %}Last activities{% endblocktrans %}</h5>
......
...@@ -5,8 +5,8 @@ from django.utils import timezone, formats ...@@ -5,8 +5,8 @@ from django.utils import timezone, formats
from ics import Calendar from ics import Calendar
from requests import RequestException from requests import RequestException
from dashboard import settings # from dashboard import settings
from dashboard.caches import LATEST_ARTICLE_CACHE, CURRENT_EVENTS_CACHE # from dashboard.caches import LATEST_ARTICLE_CACHE, CURRENT_EVENTS_CACHE
WP_DOMAIN: str = "https://katharineum-zu-luebeck.de" WP_DOMAIN: str = "https://katharineum-zu-luebeck.de"
...@@ -18,7 +18,8 @@ def get_newest_articles(domain: str = WP_DOMAIN, ...@@ -18,7 +18,8 @@ def get_newest_articles(domain: str = WP_DOMAIN,
author_whitelist: list = None, author_whitelist: list = None,
author_blacklist: list = None, author_blacklist: list = None,
category_whitelist: list = None, category_whitelist: list = None,
category_blacklist: list = None category_blacklist: list = None,
filter_vs_composer: bool = False,
): ):
""" """
This function returns the newest articles/posts of a WordPress site. This function returns the newest articles/posts of a WordPress site.
...@@ -29,6 +30,7 @@ def get_newest_articles(domain: str = WP_DOMAIN, ...@@ -29,6 +30,7 @@ def get_newest_articles(domain: str = WP_DOMAIN,
:param author_blacklist: If the author's id (an integer) is in this list, the article won't be shown :param author_blacklist: If the author's id (an integer) is in this list, the article won't be shown
:param category_whitelist: If this list is filled, only articles which are in one of this categories will be shown :param category_whitelist: If this list is filled, only articles which are in one of this categories will be shown
:param category_blacklist: If the category's id (an integer) is in this list, the article won't be shown :param category_blacklist: If the category's id (an integer) is in this list, the article won't be shown
:param filter_vs_composer: Remove unnecessary Visual Composer Tags
:return: a list of the newest posts/articles :return: a list of the newest posts/articles
""" """
# Make mutable default arguments unmutable # Make mutable default arguments unmutable
...@@ -68,7 +70,7 @@ def get_newest_articles(domain: str = WP_DOMAIN, ...@@ -68,7 +70,7 @@ def get_newest_articles(domain: str = WP_DOMAIN,
image_url: str = "" image_url: str = ""
# Replace VS composer tags if activated # Replace VS composer tags if activated
if settings.latest_article_settings.replace_vs_composer_stuff: if filter_vs_composer:
excerpt = VS_COMPOSER_REGEX.sub("", post["excerpt"]["rendered"]) excerpt = VS_COMPOSER_REGEX.sub("", post["excerpt"]["rendered"])
else: else:
excerpt = post["excerpt"]["rendered"] excerpt = post["excerpt"]["rendered"]
...@@ -81,13 +83,13 @@ def get_newest_articles(domain: str = WP_DOMAIN, ...@@ -81,13 +83,13 @@ def get_newest_articles(domain: str = WP_DOMAIN,
"image_url": image_url, "image_url": image_url,
} }
) )
if len(posts) >= limit and limit >= 0: if len(posts) >= limit >= 0:
break break
return posts return posts
@LATEST_ARTICLE_CACHE.decorator # @LATEST_ARTICLE_CACHE.decorator
def get_newest_article_from_news(domain=WP_DOMAIN): def get_newest_article_from_news(domain=WP_DOMAIN):
newest_articles: list = get_newest_articles(domain=domain, limit=1, category_whitelist=[1, 27]) newest_articles: list = get_newest_articles(domain=domain, limit=1, category_whitelist=[1, 27])
if len(newest_articles) > 0: if len(newest_articles) > 0:
...@@ -149,7 +151,7 @@ def get_current_events(calendar: Calendar, limit: int = 5) -> list: ...@@ -149,7 +151,7 @@ def get_current_events(calendar: Calendar, limit: int = 5) -> list:
return events return events
@CURRENT_EVENTS_CACHE.decorator # @CURRENT_EVENTS_CACHE.decorator
def get_current_events_with_cal(limit: int = 5) -> list: def get_current_events_with_cal(limit: int = 5) -> list:
# Get URL # Get URL
calendar_url: str = settings.current_events_settings.calendar_url calendar_url: str = settings.current_events_settings.calendar_url
......
...@@ -20,6 +20,8 @@ from .models import Activity, Group, Notification, Person, School ...@@ -20,6 +20,8 @@ from .models import Activity, Group, Notification, Person, School
from .tables import GroupsTable, PersonsTable from .tables import GroupsTable, PersonsTable
from .util import messages from .util import messages
from aleksis.apps.dashboardfeeds.views import get_widgets
@person_required @person_required
def index(request: HttpRequest) -> HttpResponse: def index(request: HttpRequest) -> HttpResponse:
...@@ -33,6 +35,8 @@ def index(request: HttpRequest) -> HttpResponse: ...@@ -33,6 +35,8 @@ def index(request: HttpRequest) -> HttpResponse:
context["notifications"] = notifications context["notifications"] = notifications
context["unread_notifications"] = unread_notifications context["unread_notifications"] = unread_notifications
context["widgets"] = get_widgets(request)
return render(request, "core/index.html", context) return render(request, "core/index.html", context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment