Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hansegucker/AlekSIS-Core
  • pinguin/AlekSIS-Core
  • AlekSIS/official/AlekSIS-Core
  • sunweaver/AlekSIS-Core
  • sggua/AlekSIS-Core
  • edward/AlekSIS-Core
  • magicfelix/AlekSIS-Core
7 results
Show changes
Commits on Source (9)
from django.utils.translation import gettext_lazy as _
def myplan_dashboard(request):
context = {
"title": _("My plan for today"),
}
return context
def calendar_dashboard(request):
context = {
"title": _("Current events"),
}
return context
def wordpress_dashboard(request):
context = {
"title": _("News "),
}
return context
WIDGETS = [
(_("Your plan"),)
]
......@@ -64,6 +64,7 @@ header, main, footer {
.brand-logo {
margin-left: 10px;
z-index: 5;
}
@media only screen and (max-width: 993px) {
......
......@@ -45,7 +45,7 @@
{% block extra_head %}{% endblock %}
</head>
<body>
<body id="body">
<header>
<!-- Menu button (sidenav) -->
......
......@@ -4,26 +4,61 @@
{% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %}
{% block content %}
<p class="flow-text">{% blocktrans %}AlekSIS (School Information System){% endblocktrans %}</p>
{% if user.is_authenticated %}
{% for notification in unread_notifications %}
<div class="alert primary scale-transition">
<div>
<i class="material-icons left">info</i>
<div class="right">
<a class="btn-flat waves-effect" href="{% url "notification_mark_read" notification.id %}">
<i class="material-icons center">close</i>
</a>
<div id="dashboard">
<p class="flow-text">{% blocktrans %}AlekSIS (School Information System){% endblocktrans %}</p>
{% if user.is_authenticated %}
{% for notification in unread_notifications %}
<div class="alert primary scale-transition">
<div>
<i class="material-icons left">info</i>
<div class="right">
<a class="btn-flat waves-effect" href="{% url "notification_mark_read" notification.id %}">
<i class="material-icons center">close</i>
</a>
</div>
<strong>{{ notification.title }}</strong>
<p>{{ notification.description }}</p>
</div>
</div>
{% endfor %}
<div class="row">
<div class="col s12 m6">
<h5>{% blocktrans %}Last activities{% endblocktrans %}</h5>
<strong>{{ notification.title }}</strong>
<p>{{ notification.description }}</p>
{% if activities %}
<ul class="collection">
{% for activity in activities %}
<li class="collection-item">
<span class="badge new primary-color">{{ activity.app }}</span>
<span class="title">{{ activity.title }}</span>
<p>
<i class="material-icons left">access_time</i> {{ activity.created_at }}
</p>
<p>
{{ activity.description }}
</p>
</li>
{% endfor %}
</ul>
{% else %}
<p>{% blocktrans %}No activities available yet.{% endblocktrans %}</p>
{% endif %}
</div>
</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>
......@@ -48,33 +83,85 @@
{% endif %}
</div>
<div class="col s12 m6">
<h5>{% blocktrans %}Recent notifications{% endblocktrans %}</h5>
<div class="col s12 m6">
<h5>{% blocktrans %}Recent notifications{% endblocktrans %}</h5>
{% if notifications %}
<ul class="collection">
{% for notification in notifications %}
<li class="collection-item">
<span class="badge new primary-color">{{ notification.app }}</span>
<span class="title">{{ notification.title }}</span>
<p>
<i class="material-icons left">access_time</i> {{ notification.created_at }}
</p>
<p>
{{ notification.description }}
</p>
{% if notification.link %}
{% if notifications %}
<ul class="collection">
{% for notification in notifications %}
<li class="collection-item">
<span class="badge new primary-color">{{ notification.app }}</span>
<span class="title">{{ notification.title }}</span>
<p>
<a href="{{ notification.link }}">{% blocktrans %}More information →{% endblocktrans %}</a>
<i class="material-icons left">access_time</i> {{ notification.created_at }}
</p>
{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<p>{% blocktrans %}No notifications available yet.{% endblocktrans %}</p>
{% endif %}
<p>
{{ notification.description }}
</p>
{% if notification.link %}
<p>
<a href="{{ notification.link }}">{% blocktrans %}More information →{% endblocktrans %}</a>
</p>
{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<p>{% blocktrans %}No notifications available yet.{% endblocktrans %}</p>
{% endif %}
</div>
</div>
</div>
{% endif %}
{% endif %}
</div>
<script type="text/javascript">
const asyncIntervals = [];
const runAsyncInterval = async (cb, interval, intervalIndex) => {
await cb();
if (asyncIntervals[intervalIndex]) {
setTimeout(() => runAsyncInterval(cb, interval, intervalIndex), interval);
}
};
const setAsyncInterval = (cb, interval) => {
if (cb && typeof cb === "function") {
const intervalIndex = asyncIntervals.length;
asyncIntervals.push(true);
runAsyncInterval(cb, interval, intervalIndex);
return intervalIndex;
} else {
throw new Error('Callback must be a function');
}
};
const clearAsyncInterval = (intervalIndex) => {
if (asyncIntervals[intervalIndex]) {
asyncIntervals[intervalIndex] = false;
}
};
/* SOURCE: https://dev.to/jsmccrumb/asynchronous-setinterval-4j69 */
{# ------------------------------------------ #}
{#$(document).ready(function () {#}
{# setInterval(function () {#}
{# $('#body').load("/");#}
{# }, 3000);#}
{# });#}
{# ------------------------------------------ #}
let dashboard_interval = setAsyncInterval(async () => {
console.log('fetching new data');
const promise = new Promise((resolve) => {
$('#dashboard').load("/ #dashboard");
resolve(1);
});
await promise;
console.log('data fetched successfully');
}, 15000);
</script>
{% endblock %}
......@@ -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
......
......@@ -18,21 +18,25 @@ from .forms import (
)
from .models import Activity, Group, Notification, Person, School
from .tables import GroupsTable, PersonsTable
from .util import messages
from .util import messages, network
from aleksis.apps.dashboardfeeds.views import get_widgets
@person_required
def index(request: HttpRequest) -> HttpResponse:
context = {}
activities = request.user.person.activities.all()[:5]
notifications = request.user.person.notifications.all()[:5]
unread_notifications = request.user.person.notifications.all().filter(read=False)
activities = request.user.person.activities.all().order_by('-created_at')[:5]
notifications = request.user.person.notifications.all().order_by('-created_at')[:5]
unread_notifications = request.user.person.notifications.all().filter(read=False).order_by('-created_at')
context["activities"] = activities
context["notifications"] = notifications
context["unread_notifications"] = unread_notifications
context["widgets"] = get_widgets(request)
return render(request, "core/index.html", context)
......@@ -255,7 +259,7 @@ def notification_mark_read(request: HttpRequest, id_: int) -> HttpResponse:
notification = get_object_or_404(Notification, pk=id_)
if notification.recipient.user == request.user:
if notification.user == request.user.person:
notification.read = True
notification.save()
else:
......
Subproject commit de78f40b39b970570ffbd2d059a0329376141e75
Subproject commit 99c4cd0b940497f2bca5e10904c482ac8807bd0f
Subproject commit 1415a4851bd53ffe4e14c0961422e5b66060d0f8
Subproject commit 0ea718b743e9c2235adceb8b09db84e8c2abd59c
......@@ -25,6 +25,17 @@ optional = false
python-versions = "*"
version = "1.4.3"
[[package]]
category = "main"
description = "Better dates & times for Python"
name = "arrow"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
version = "0.14.7"
[package.dependencies]
python-dateutil = "*"
[[package]]
category = "main"
description = "ASGI specs, helper code, and adapters"
......@@ -395,11 +406,6 @@ optional = false
python-versions = "*"
version = "2.5.0"
[package.dependencies]
[package.dependencies.django-picklefield]
optional = true
version = "*"
[package.extras]
database = ["django-picklefield"]
redis = ["redis"]
......@@ -408,6 +414,7 @@ redis = ["redis"]
reference = "590fa02eb30e377da0eda5cc3a84254b839176a7"
type = "git"
url = "https://github.com/jazzband/django-constance"
[[package]]
category = "main"
description = "A configurable set of panels that display various debug information about the current request/response."
......@@ -604,10 +611,6 @@ version = "3.0.1"
Django = ">=1.11.3"
babel = "*"
[package.dependencies.phonenumbers]
optional = true
version = ">=7.0.2"
[package.extras]
phonenumbers = ["phonenumbers (>=7.0.2)"]
phonenumberslite = ["phonenumberslite (>=7.0.2)"]
......@@ -1040,6 +1043,20 @@ version = "3.0.5"
[package.dependencies]
gitdb2 = ">=2.0.0"
[[package]]
category = "main"
description = "Python icalendar (rfc5545) parser"
name = "ics"
optional = false
python-versions = "*"
version = "0.6"
[package.dependencies]
arrow = ">=0.11,<0.15"
python-dateutil = "*"
six = ">1.5"
tatsu = ">4.2"
[[package]]
category = "main"
description = "Turn HTML into equivalent Markdown-structured text."
......@@ -1808,6 +1825,17 @@ version = "1.31.0"
pbr = ">=2.0.0,<2.1.0 || >2.1.0"
six = ">=1.10.0"
[[package]]
category = "main"
description = "TatSu takes a grammar in a variation of EBNF as input, and outputs a memoizing PEG/Packrat parser in Python."
name = "tatsu"
optional = false
python-versions = "*"
version = "4.4.0"
[package.extras]
future-regex = ["regex"]
[[package]]
category = "dev"
description = "ANSII Color formatting for output in terminal."
......@@ -1993,6 +2021,10 @@ appdirs = [
{file = "appdirs-1.4.3-py2.py3-none-any.whl", hash = "sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e"},
{file = "appdirs-1.4.3.tar.gz", hash = "sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92"},
]
arrow = [
{file = "arrow-0.14.7-py2.py3-none-any.whl", hash = "sha256:4bfacea734ead51495dc47df00421ecfd4ca1f2c0fbe58b9a26eaeddedc31caf"},
{file = "arrow-0.14.7.tar.gz", hash = "sha256:67f8be7c0cf420424bc62d8d7dc40b44e4bb2f7b515f9cc2954fb36e35797656"},
]
asgiref = [
{file = "asgiref-3.2.3-py2.py3-none-any.whl", hash = "sha256:ea448f92fc35a0ef4b1508f53a04c4670255a3f33d22a81c8fc9c872036adbe5"},
{file = "asgiref-3.2.3.tar.gz", hash = "sha256:7e06d934a7718bf3975acbf87780ba678957b87c7adc056f13b6215d610695a0"},
......@@ -2318,6 +2350,9 @@ gitpython = [
{file = "GitPython-3.0.5-py3-none-any.whl", hash = "sha256:c155c6a2653593ccb300462f6ef533583a913e17857cfef8fc617c246b6dc245"},
{file = "GitPython-3.0.5.tar.gz", hash = "sha256:9c2398ffc3dcb3c40b27324b316f08a4f93ad646d5a6328cafbb871aa79f5e42"},
]
ics = [
{file = "ics-0.6-py2.py3-none-any.whl", hash = "sha256:12cf34aed0dafa1bf99d79ca58e99949d6721511b856386e118015fe5f5d6e3a"},
{file = "ics-0.6-py3.7.egg", hash = "sha256:daa457478dbaba3ce7ab5f7b3a411e72d7a2771c0781c21013cc6c9f27b2a050"},
html2text = [
{file = "html2text-2020.1.16-py3-none-any.whl", hash = "sha256:c7c629882da0cf377d66f073329ccf34a12ed2adf0169b9285ae4e63ef54c82b"},
{file = "html2text-2020.1.16.tar.gz", hash = "sha256:e296318e16b059ddb97f7a8a1d6a5c1d7af4544049a01e261731d2d5cc277bbb"},
......@@ -2746,6 +2781,10 @@ stevedore = [
{file = "stevedore-1.31.0-py2.py3-none-any.whl", hash = "sha256:01d9f4beecf0fbd070ddb18e5efb10567801ba7ef3ddab0074f54e3cd4e91730"},
{file = "stevedore-1.31.0.tar.gz", hash = "sha256:e0739f9739a681c7a1fda76a102b65295e96a144ccdb552f2ae03c5f0abe8a14"},
]
tatsu = [
{file = "TatSu-4.4.0-py2.py3-none-any.whl", hash = "sha256:c9211eeee9a2d4c90f69879ec0b518b1aa0d9450249cb0dd181f5f5b18be0a92"},
{file = "TatSu-4.4.0.zip", hash = "sha256:80713413473a009f2081148d0f494884cabaf9d6866b71f2a68a92b6442f343d"},
]
termcolor = [
{file = "termcolor-1.1.0.tar.gz", hash = "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b"},
]
......