Skip to content
Snippets Groups Projects
Commit 227d1a6b authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

:tada::dolphin::sparkler: Merge the 100th Merge Request :sparkler::dolphin::tada:

Merge branch '30-dashboard' into 'master'

Resolve "Dashboard"

See merge request AlekSIS/AlekSIS!100
parents cdd4323f ad3a5f45
No related branches found
No related tags found
1 merge request!100Resolve "Dashboard"
Pipeline #564 canceled
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Selbst programmierte Anwendungen für den Schullaltag am Katharineum zu Lübeck"> <meta name="description" content="{% blocktrans %}AlekSIS is a web-based school information system (SIS) which can be used to manage and/or publish organisational data of educational in titutions.{% endblocktrans %}">
<title>School Information System</title> <title>{% blocktrans %}AlekSIS - School Information System{% endblocktrans %}</title>
{# Favicons #} {# Favicons #}
<link href="{% static "icons/favicon_16.png" %}" rel="icon" type="image/png" sizes="16x16"> <link href="{% static "icons/favicon_16.png" %}" rel="icon" type="image/png" sizes="16x16">
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<!-- Nav bar (logged in as, logout) --> <!-- Nav bar (logged in as, logout) -->
<nav> <nav>
<a class="brand-logo" href="/">SIS</a> <a class="brand-logo" href="/">AlekSIS</a>
<div class="nav-wrapper"> <div class="nav-wrapper">
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
......
{# -*- engine:django -*- #} {% extends 'core/base.html' %}
{% load i18n %}
{% extends "core/base.html" %} {% block content %}
<p class="flow-text">{% blocktrans %}AlekSIS (School Information System){% endblocktrans %}</p>
{% load i18n %} {% if user.is_authenticated %}
{% for notification in unread_notifications %}
<div class="alert primary scale-transition">
<div>
<i class="material-icons left">info</i>
{% block page_title %} <div class="right">
{% blocktrans %} <a class="btn-flat waves-effect" href="{% url "notification_mark_read" notification.id %}">
AlekSIS (School Information System) <i class="material-icons center">close</i>
{% endblocktrans %} </a>
{% endblock %} </div>
{% block content %} <strong>{{ notification.title }}</strong>
<div class="flow-text"> <p>{{ notification.description }}</p>
<p> </div>
{% blocktrans %} </div>
AlekSIS is a web-based school information system (SIS) which can be used to {% endfor %}
manage and/or publish organisational data of educational institutions.
{% endblocktrans %} <div class="row">
</p> <div class="col s12 m6">
</div> <h5>{% blocktrans %}Last activities{% endblocktrans %}</h5>
{% 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 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 %}
<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>
{% endif %}
{% endblock %} {% endblock %}
...@@ -31,6 +31,7 @@ urlpatterns = [ ...@@ -31,6 +31,7 @@ urlpatterns = [
path("group/<int:id_>", views.group, name="group_by_id"), path("group/<int:id_>", views.group, name="group_by_id"),
path("group/<int:id_>/edit", views.edit_group, name="edit_group_by_id"), path("group/<int:id_>/edit", views.edit_group, name="edit_group_by_id"),
path("", views.index, name="index"), path("", views.index, name="index"),
path("notifications/mark-read/<int:id_>", views.notification_mark_read, name="notification_mark_read"),
path("maintenance-mode/", include("maintenance_mode.urls")), path("maintenance-mode/", include("maintenance_mode.urls")),
path("impersonate/", include("impersonate.urls")), path("impersonate/", include("impersonate.urls")),
path("__i18n__/", include("django.conf.urls.i18n")), path("__i18n__/", include("django.conf.urls.i18n")),
......
from typing import Optional from typing import Optional
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.http import Http404, HttpRequest, HttpResponse from django.http import Http404, HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
...@@ -15,13 +16,29 @@ from .forms import ( ...@@ -15,13 +16,29 @@ from .forms import (
EditTermForm, EditTermForm,
PersonsAccountsFormSet, PersonsAccountsFormSet,
) )
from .models import Group, Person, School 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
@login_required
def index(request: HttpRequest) -> HttpResponse: def index(request: HttpRequest) -> HttpResponse:
context = {} context = {}
if request.user.is_authenticated:
activities = request.user.person.activities.all()[:5]
notifications = (
request.user.person.notifications.all()[:5]
)
unread_notifications = (
request.user.person.notifications.all().filter(read=False)
)
context["activities"] = activities
context["notifications"] = notifications
context["unread_notifications"] = unread_notifications
return render(request, "core/index.html", context) return render(request, "core/index.html", context)
...@@ -237,3 +254,17 @@ def edit_schoolterm(request: HttpRequest) -> HttpResponse: ...@@ -237,3 +254,17 @@ def edit_schoolterm(request: HttpRequest) -> HttpResponse:
context["edit_term_form"] = edit_term_form context["edit_term_form"] = edit_term_form
return render(request, "core/edit_schoolterm.html", context) return render(request, "core/edit_schoolterm.html", context)
def notification_mark_read(request: HttpRequest, id_: int) -> HttpResponse:
context = {}
notification = get_object_or_404(Notification, pk=id_)
if notification.user == request.user:
notification.read = True
notification.save()
else:
raise PermissionDenied(_("You are not allowed to mark notifications from other users as read!"))
return redirect("index")
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