diff --git a/aleksis/core/templates/core/index.html b/aleksis/core/templates/core/index.html index 05875979203262f7f8818db06400da609679c891..bbb6b7df4ff1038755cb42a0eb9db000843366ac 100644 --- a/aleksis/core/templates/core/index.html +++ b/aleksis/core/templates/core/index.html @@ -24,6 +24,14 @@ </div> {% endfor %} + <div class="row"> + {% for widget in widgets %} + <div class="col s12 m12 l6 xl4"> + {{ widget }} + </div> + {% endfor %} + </div> + <div class="row"> <div class="col s12 m6"> <h5>{% blocktrans %}Last activities{% endblocktrans %}</h5> diff --git a/aleksis/core/util/network.py b/aleksis/core/util/network.py index 6c81df3330006f4ba8f591615d1c3aa06d939bcd..aa305ba160aa5034f05e53c24cd867c40ca65056 100644 --- a/aleksis/core/util/network.py +++ b/aleksis/core/util/network.py @@ -5,8 +5,8 @@ from django.utils import timezone, formats from ics import Calendar from requests import RequestException -from dashboard import settings -from dashboard.caches import LATEST_ARTICLE_CACHE, CURRENT_EVENTS_CACHE +# from dashboard import settings +# from dashboard.caches import LATEST_ARTICLE_CACHE, CURRENT_EVENTS_CACHE WP_DOMAIN: str = "https://katharineum-zu-luebeck.de" @@ -18,7 +18,8 @@ def get_newest_articles(domain: str = WP_DOMAIN, author_whitelist: list = None, author_blacklist: 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. @@ -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 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 filter_vs_composer: Remove unnecessary Visual Composer Tags :return: a list of the newest posts/articles """ # Make mutable default arguments unmutable @@ -68,7 +70,7 @@ def get_newest_articles(domain: str = WP_DOMAIN, image_url: str = "" # 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"]) else: excerpt = post["excerpt"]["rendered"] @@ -81,13 +83,13 @@ def get_newest_articles(domain: str = WP_DOMAIN, "image_url": image_url, } ) - if len(posts) >= limit and limit >= 0: + if len(posts) >= limit >= 0: break return posts -@LATEST_ARTICLE_CACHE.decorator +# @LATEST_ARTICLE_CACHE.decorator def get_newest_article_from_news(domain=WP_DOMAIN): newest_articles: list = get_newest_articles(domain=domain, limit=1, category_whitelist=[1, 27]) if len(newest_articles) > 0: @@ -149,7 +151,7 @@ def get_current_events(calendar: Calendar, limit: int = 5) -> list: return events -@CURRENT_EVENTS_CACHE.decorator +# @CURRENT_EVENTS_CACHE.decorator def get_current_events_with_cal(limit: int = 5) -> list: # Get URL calendar_url: str = settings.current_events_settings.calendar_url diff --git a/aleksis/core/views.py b/aleksis/core/views.py index ff11482f68268d5f5d090502039d1c4be12e99a2..b75811bf39d0dd5e861aca2084bf28003b6daa0f 100644 --- a/aleksis/core/views.py +++ b/aleksis/core/views.py @@ -20,6 +20,8 @@ from .models import Activity, Group, Notification, Person, School from .tables import GroupsTable, PersonsTable from .util import messages +from aleksis.apps.dashboardfeeds.views import get_widgets + @person_required def index(request: HttpRequest) -> HttpResponse: @@ -33,6 +35,8 @@ def index(request: HttpRequest) -> HttpResponse: context["notifications"] = notifications context["unread_notifications"] = unread_notifications + context["widgets"] = get_widgets(request) + return render(request, "core/index.html", context)