diff --git a/react/src/dashboard.js b/react/src/dashboard.js index 0fbddfce98bd9bbe31e7ab63aa0297eff3ac5a41..c99f7ad84d92c6c77906ab1b02402740814dcca8 100644 --- a/react/src/dashboard.js +++ b/react/src/dashboard.js @@ -1,11 +1,11 @@ const REFRESH_TIME = 15; -function WithCheckCircleIcon(props) { - return <div className={"col s12"}> - <i className={"material-icons left green-text"}>check_circle</i> - {props.children} - </div> -} +// function WithCheckCircleIcon(props) { +// return <div className={"col s12"}> +// <i className={"material-icons left green-text"}>check_circle</i> +// {props.children} +// </div> +// } class Dashboard extends React.Component { constructor() { @@ -23,7 +23,6 @@ class Dashboard extends React.Component { } const timeout = window.setTimeout(this.updateRefreshTime, 1000); this.setState({refreshIn: this.state.refreshIn - 1, timeout: timeout}); - console.log("WOrk"); } else { this.updateData(); } @@ -55,7 +54,7 @@ class Dashboard extends React.Component { console.log(notification); $("#not-" + notification.id).addClass("scale-out"); window.setTimeout(() => { - $("#not-" + notification.id).remove(); + $("#not-" + notification.id).hide(); }, 200); $.getJSON(API_URL + "/notifications/read/" + notification.id); this.updateData(); @@ -64,7 +63,8 @@ class Dashboard extends React.Component { render() { if (this.state.isLoading) { - return <div className={"row center-via-flex container"} style={{"height": "10em"}}> + // Show loading screen until first data are loaded + return <div className={"row center-via-flex container"} style={{"height": "15em"}}> <div className={"center2-via-flex"}> <div className="preloader-wrapper big active"> <div className="spinner-layer spinner-primary"> @@ -79,7 +79,7 @@ class Dashboard extends React.Component { </div> </div> </div> - <p className={"text-center"}>Wird geladen …</p> + <p className={"text-center flow-text"}>Deine aktuellen Informationen werden geladen …</p> </div> </div>; } @@ -97,19 +97,32 @@ class Dashboard extends React.Component { Moin, {this.state.user.full_name !== "" ? this.state.user.full_name : this.state.user.username}. Hier findest du alle aktuellen Informationen:</p> + <div className={"alert success"}> + <p> + <i className={"material-icons left"}>report_problem</i> + Das neue Dashboard von SchoolApps befindet sich momentan in der <strong>Testphase</strong>. Falls + Fehler auftreten oder du einen Verbesserungsvorschlag für uns hast, schreibe uns bitte unter <a + href={"mailto:support@katharineum.de"}>support@katharineum.de</a>. + </p> + </div> + {/* UNREAD NOTIFICATIONS*/} {this.state.unread_notifications && this.state.unread_notifications.length > 0 ? this.state.unread_notifications.map(function (notification) { return <div className={"alert primary scale-transition"} id={"not-" + notification.id} key={notification.id}> <div> + {/* Info icon */} <i className={"material-icons left"}>info</i> + <div className={"right"}> + {/* Button for marking as read*/} <button className={"btn-flat"} onClick={() => that.closeNotification(notification)}> <i className={"material-icons center"}>close</i> - {/*Gelesen*/} </button> </div> + + {/* Notification title and desc */} <strong>{notification.title}</strong> <p>{notification.description}</p> </div> @@ -120,8 +133,6 @@ class Dashboard extends React.Component { {this.state.plan && this.state.plan.hints.length > 0 ? <div> {this.state.plan.hints.map(function (hint, idx) { - const from_date = moment(hint.from_date); - const to_date = moment(hint.to_date); return <div className="alert primary" key={idx}> <div> <em className="right hide-on-small-and-down"> @@ -143,78 +154,81 @@ class Dashboard extends React.Component { <div className={"row"}> <div className={"dashboard-cards"}> - {/* CURRENT SUBSTITUTIONS*/} - <div className="card"> - {this.state.has_plan ? <div className="card-content"> + {/* MY PLAN */} + {this.state.has_plan ? <div className="card"> + <div className="card-content"> + {/* Show individualized title */} <span className="card-title"> - Vertretungen {this.state.plan.type === 2 ? "der" : "für"} <em> + Plan {this.state.plan.type === 2 ? "der" : "für"} <em> {this.state.plan.name}</em> für {this.state.date_formatted} </span> - {this.state.lessons && this.state.lessons.length > 0 ? <div> - {this.state.lessons.map(function (lesson) { - return <div className="row"> - <div className="col s4"> - <div className="card timetable-title-card"> - <div className="card-content"> - - <span className="card-title left"> - {lesson.time.number_format} - </span> - - <div - className="right timetable-time grey-text text-darken-2"> - <span>{lesson.time.start}</span> - <br/> - <span>{lesson.time.end}</span> - </div> + + {/* Show plan */} + {this.state.lessons && this.state.lessons.length > 0 ? <div className={"timetable-plan"}> + {this.state.lessons.map(function (lesson) { + // Show one lesson row + return <div className="row"> + {/* Show time information*/} + <div className="col s4"> + <div className="card timetable-title-card"> + <div className="card-content"> + {/* Lesson number*/} + <span className="card-title left"> + {lesson.time.number_format} + </span> + + {/* Times */} + <div className="right timetable-time grey-text text-darken-2"> + <span>{lesson.time.start}</span> + <br/> + <span>{lesson.time.end}</span> </div> </div> - </div> - <div className={"col s8"} dangerouslySetInnerHTML={{__html: lesson.html}}/> - </div>; - })} - </div> - : - <p>Keine Vertretungen für morgen vorhanden.</p> - } - </div> : <p className={"flow-text"}>Keine Vertretungen vorhanden.</p>} - {this.state.has_plan ? <div className="card-action"> + </div> + + {/* Show lesson content (via generated HTML by Django) */} + <div className={"col s8"} dangerouslySetInnerHTML={{__html: lesson.html}}/> + </div>; + })} + </div> : ""} + </div> + <div className="card-action"> <a href={MY_PLAN_URL}> <span className="badge new primary-color card-action-badge">SMART PLAN</span> anzeigen </a> - </div> : ""} - </div> + </div> + </div> : ""} {/* MY STATUS */} - <div className="card"> - <div className="card-content"> - <span className="card-title">Mein Status</span> - <div className={"row"}> - <WithCheckCircleIcon> - {this.state.user_type_formatted} - </WithCheckCircleIcon> - - {this.state.user_type === 1 || this.state.user_type === 2 ? <WithCheckCircleIcon> - Meine Klassen: {this.state.classes.join(", ")} - </WithCheckCircleIcon> : ""} - - {this.state.user_type === 1 || this.state.user_type === 2 ? <WithCheckCircleIcon> - Meine Kurse: {this.state.courses.join(", ")} - </WithCheckCircleIcon> : ""} - - {this.state.user_type === 1 ? <WithCheckCircleIcon> - Meine Fächer: {this.state.subjects.join(", ")} - </WithCheckCircleIcon> : ""} - {this.state.user_type === 1 || this.state.has_wifi ? - <WithCheckCircleIcon>WLAN</WithCheckCircleIcon> : <div className={"col"}> - <i className={"material-icons left red-text"}>cancel</i> - Kein WLAN - </div>} - </div> - </div> - </div> + {/*<div className="card">*/} + {/* <div className="card-content">*/} + {/* <span className="card-title">Mein Status</span>*/} + {/* <div className={"row"}>*/} + {/* <WithCheckCircleIcon>*/} + {/* {this.state.user_type_formatted}*/} + {/* </WithCheckCircleIcon>*/} + + {/* {this.state.user_type === 1 || this.state.user_type === 2 ? <WithCheckCircleIcon>*/} + {/* Meine Klassen: {this.state.classes.join(", ")}*/} + {/* </WithCheckCircleIcon> : ""}*/} + + {/* {this.state.user_type === 1 || this.state.user_type === 2 ? <WithCheckCircleIcon>*/} + {/* Meine Kurse: {this.state.courses.join(", ")}*/} + {/* </WithCheckCircleIcon> : ""}*/} + + {/* {this.state.user_type === 1 ? <WithCheckCircleIcon>*/} + {/* Meine Fächer: {this.state.subjects.join(", ")}*/} + {/* </WithCheckCircleIcon> : ""}*/} + {/* {this.state.user_type === 1 || this.state.has_wifi ?*/} + {/* <WithCheckCircleIcon>WLAN</WithCheckCircleIcon> : <div className={"col"}>*/} + {/* <i className={"material-icons left red-text"}>cancel</i>*/} + {/* Kein WLAN*/} + {/* </div>}*/} + {/* </div>*/} + {/* </div>*/} + {/*</div>*/} {/* CURRENT EVENTS*/} {this.state.current_events && this.state.current_events.length > 0 ? @@ -230,37 +244,38 @@ class Dashboard extends React.Component { })} </div> <div className="card-action"> - <a href="https://katharineum-zu-luebeck.de/aktuelles/termine/" - target={"_blank"}>Weitere Termine + <a href="https://katharineum-zu-luebeck.de/aktuelles/termine/" target={"_blank"}> + Weitere Termine </a> </div> </div> : ""} {/* EXAMS */} - <div className="card"> - <div className="card-content"> - <span className="card-title">Klausuren der <em>Eb</em></span> - <div className="card-panel event-card"> - <span className={"title"}>Sextanereinschulung</span> - <br/> - 28.Aug. 2019 18:30 - 22:00 - </div> - <div className="card-panel event-card"> - <span className={"title"}>Sextanereinschulung</span> - <br/> - 28.Aug. 2019 18:30 - 22:00 - </div> - </div> - <div className="card-action"> - <a href="https://katharineum-zu-luebeck.de/aktuelles/termine/">Alle Klausuren</a> - </div> - </div> + {/*<div className="card">*/} + {/* <div className="card-content">*/} + {/* <span className="card-title">Klausuren der <em>Eb</em></span>*/} + {/* <div className="card-panel event-card">*/} + {/* <span className={"title"}>Sextanereinschulung</span>*/} + {/* <br/>*/} + {/* 28.Aug. 2019 18:30 - 22:00*/} + {/* </div>*/} + {/* <div className="card-panel event-card">*/} + {/* <span className={"title"}>Sextanereinschulung</span>*/} + {/* <br/>*/} + {/* 28.Aug. 2019 18:30 - 22:00*/} + {/* </div>*/} + {/* </div>*/} + {/* <div className="card-action">*/} + {/* <a href="https://katharineum-zu-luebeck.de/aktuelles/termine/">Alle Klausuren</a>*/} + {/* </div>*/} + {/*</div>*/} {/* NEWEST ARTICLE FROM HOMEPAGE*/} {this.state.newest_article ? <div> <div className="card"> + {/* Image with badge and title */} <div className="card-image"> <span className={"badge-image"}>Aktuelles von der Homepage</span> <img src={this.state.newest_article.image_url} @@ -268,13 +283,19 @@ class Dashboard extends React.Component { <span className="card-title" dangerouslySetInnerHTML={{__html: this.state.newest_article.title}}/> </div> + + {/* Short text */} <div className="card-content"> <p dangerouslySetInnerHTML={{__html: this.state.newest_article.short_text}}/> </div> + + {/* Link to article */} <div className="card-action"> <a href={this.state.newest_article.link} target={"_blank"}>Mehr lesen</a> </div> </div> + + {/* Link to homepage */} <a className={"btn hundred-percent primary-color"} href={"https://katharineum-zu-luebeck.de/"} target={"_blank"}> diff --git a/schoolapps/dashboard/settings.py b/schoolapps/dashboard/settings.py index 9252e8cfa142523941fb75901944217cfedd30cd..4dc09f18c3e8d8f2979aa5e8eb6dda8479f85735 100644 --- a/schoolapps/dashboard/settings.py +++ b/schoolapps/dashboard/settings.py @@ -14,7 +14,7 @@ class CurrentEventsSettings(dbsettings.Group): calendar_url = dbsettings.StringValue("URL des Kalenders", help_text="Pfad zu einer ICS-Datei", default="https://nimbus.katharineum.de/remote.php/dav/public-calendars" "/owit7yysLB2CYNTq?export") - events_count = dbsettings.IntegerValue("Anzahl der Termine, die angezeigt werden sollen", default=3) + events_count = dbsettings.IntegerValue("Anzahl der Termine, die angezeigt werden sollen", default=5) class MyStatusSettings(dbsettings.Group): diff --git a/schoolapps/dashboard/urls.py b/schoolapps/dashboard/urls.py index 5a237324b9a153c7897d3b7444f070c43c810e42..7aaefdf2f2cf116a6dea9e331745445521e76223 100755 --- a/schoolapps/dashboard/urls.py +++ b/schoolapps/dashboard/urls.py @@ -1,9 +1,23 @@ from django.urls import path -from . import views - -urlpatterns = [ - path('', views.index, name='dashboard'), - path('api', views.api_information, name="api_information"), - path('api/notifications/read/<int:id>', views.api_read_notification, name="api_read_notification"), - path('api/my-plan', views.api_my_plan_html, name="api_my_plan_html"), -] + +from untisconnect.models import Terms, Schoolyear + +try: + from . import views + + urlpatterns = [ + path('', views.index, name='dashboard'), + path('api', views.api_information, name="api_information"), + path('api/notifications/read/<int:id>', views.api_read_notification, name="api_read_notification"), + path('api/my-plan', views.api_my_plan_html, name="api_my_plan_html"), + ] + +except (Terms.DoesNotExist, Schoolyear.DoesNotExist): + from timetable import fallback_view + + urlpatterns = [ + path('', fallback_view.fallback, name='dashboard'), + path('api', fallback_view.fallback, name="api_information"), + path('api/notifications/read/<int:id>', fallback_view.fallback, name="api_read_notification"), + path('api/my-plan', fallback_view.fallback, name="api_my_plan_html"), + ] diff --git a/schoolapps/dashboard/views.py b/schoolapps/dashboard/views.py index 06353674f49085151dd5ebec0e8707548bf5d9e4..225e107ba98ca404ac69b306d36147f19092d4bd 100755 --- a/schoolapps/dashboard/views.py +++ b/schoolapps/dashboard/views.py @@ -1,7 +1,6 @@ from email.utils import formatdate from django.contrib.auth.decorators import login_required -from django.core.serializers import serialize from django.http import JsonResponse from django.shortcuts import render, get_object_or_404 from django.template.loader import render_to_string @@ -9,15 +8,14 @@ from django.utils import timezone, formats from martor.templatetags.martortags import safe_markdown from dashboard.settings import latest_article_settings, current_events_settings -from helper import get_newest_articles, get_current_events, get_newest_article_from_news -from schoolapps.settings import LONG_WEEK_DAYS +from helper import get_current_events, get_newest_article_from_news, get_current_events_with_cal from timetable.helper import get_name_for_next_week_day_from_today, get_type_and_object_of_user from timetable.hints import get_all_hints_by_class_and_time_period, get_all_hints_for_teachers_by_time_period from timetable.views import get_next_weekday_with_time, get_calendar_week from untisconnect.api import TYPE_TEACHER, TYPE_CLASS from untisconnect.plan import get_plan -from .models import Activity, Notification from userinformation import UserInformation +from .models import Activity, Notification @login_required @@ -37,35 +35,31 @@ def api_information(request): notifications = request.user.notifications.all().filter(user=request.user).order_by('-created_at')[:5] unread_notifications = request.user.notifications.all().filter(user=request.user, read=False).order_by( '-created_at') + + # Get latest article from homepage if latest_article_settings.latest_article_is_activated: newest_article = get_newest_article_from_news(domain=latest_article_settings.wp_domain) else: newest_article = None + # Get date information date_formatted = get_name_for_next_week_day_from_today() next_weekday = get_next_weekday_with_time(timezone.now(), timezone.now().time()) # Get user type (student, teacher, etc.) _type, el = get_type_and_object_of_user(request.user) - hints = None - if _type == TYPE_TEACHER: - # Teacher - plan_id = el.id - raw_type = "teacher" - # Get hints + # Get hints + if _type == TYPE_TEACHER: + # Get hints for teachers hints = list(get_all_hints_for_teachers_by_time_period(next_weekday, next_weekday)) - elif _type == TYPE_CLASS: - # Student - - plan_id = el.id - raw_type = "class" - - # Get hints + # Get hints for students hints = list(get_all_hints_by_class_and_time_period(el, next_weekday, next_weekday)) else: hints = [] + + # Serialize hints ser = [] for hint in hints: serialized = {} @@ -74,7 +68,7 @@ def api_information(request): serialized["html"] = safe_markdown(hint.text) ser.append(serialized) hints = ser - print(hints) + context = { 'activities': list(activities.values()), 'notifications': list(notifications.values()), @@ -86,8 +80,7 @@ def api_information(request): 'subjects': UserInformation.user_subjects(request.user), 'has_wifi': UserInformation.user_has_wifi(request.user), "newest_article": newest_article, - "current_events": get_current_events( - limit=current_events_settings.events_count) if current_events_settings.current_events_is_activated else None, + "current_events": get_current_events_with_cal() if current_events_settings.current_events_is_activated else None, "date_formatted": date_formatted, "user": { "username": request.user.username, @@ -95,6 +88,7 @@ def api_information(request): } } + # If plan is available for user give extra information if _type is not None: context["plan"] = { "type": _type, @@ -105,7 +99,6 @@ def api_information(request): else: context["has_plan"] = False - print(context) return JsonResponse(context) @@ -116,6 +109,7 @@ def api_read_notification(request, id): notification = get_object_or_404(Notification, id=id, user=request.user) notification.read = True notification.save() + return JsonResponse({"success": True}) @@ -125,23 +119,14 @@ def api_my_plan_html(request): # Get user type (student, teacher, etc.) _type, el = get_type_and_object_of_user(request.user) - hints = None if _type == TYPE_TEACHER: # Teacher plan_id = el.id raw_type = "teacher" - - # Get hints - # hints = list(get_all_hints_for_teachers_by_time_period(next_weekday, next_weekday)) - elif _type == TYPE_CLASS: # Student - plan_id = el.id raw_type = "class" - - # Get hints - # hints = list(get_all_hints_by_class_and_time_period(el, next_weekday, next_weekday)) else: return JsonResponse({"success": False}) @@ -150,24 +135,18 @@ def api_my_plan_html(request): calendar_week = next_weekday.isocalendar()[1] monday_of_week = get_calendar_week(calendar_week, next_weekday.year)["first_day"] week_day = next_weekday.isoweekday() - 1 - print(raw_type, plan_id, next_weekday, calendar_week, monday_of_week) # Get plan plan = get_plan(_type, plan_id, smart=True, monday_of_week=monday_of_week) lessons = [] for row, time in plan: lesson_container = row[week_day] - for element in lesson_container.elements: - if element.substitution is not None: - print(time) - html = render_to_string("timetable/lesson.html", {"col": lesson_container}, request=request) - time["start"] = formats.date_format(time["start"], "H:i") - time["end"] = formats.date_format(time["end"], "H:i") - - lessons.append({"time": time, "html": html}) - break - print(lessons) + html = render_to_string("timetable/lesson.html", {"col": lesson_container, "type": _type}, request=request) + time["start"] = formats.date_format(time["start"], "H:i") + time["end"] = formats.date_format(time["end"], "H:i") + lessons.append({"time": time, "html": html}) + print(lessons) return JsonResponse({"success": True, "lessons": lessons}) diff --git a/schoolapps/helper.py b/schoolapps/helper.py index 9ff631ab51bd47a468627bdbb800874c1f6dcaac..c0e2c15a2a23e2b1396561f3c92d6cc382d8a1f9 100644 --- a/schoolapps/helper.py +++ b/schoolapps/helper.py @@ -7,6 +7,7 @@ from django.template.loader_tags import register from django.utils import timezone, formats from ics import Calendar import requests +from requests import RequestException from dashboard import settings @@ -64,10 +65,12 @@ def get_newest_articles(domain: str = WP_DOMAIN, suffix: str = "/wp-json/wp/v2/posts" url: str = domain + suffix - - site: requests.request = requests.get(url) - data: dict = site.json() - + try: + site: requests.request = requests.get(url, timeout=10) + data: dict = site.json() + except RequestException as e: + print("E", str(e)) + return [] posts: list = [] for post in data: @@ -108,18 +111,13 @@ def get_newest_articles(domain: str = 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]) - if len(newest_articles) >= 0: + if len(newest_articles) > 0: return newest_articles[0] else: return None -# Set calendar here -CALENDAR_URL: str = settings.current_events_settings.calendar_url -CALENDAR: Calendar = Calendar(requests.get(CALENDAR_URL).text) - - -def get_current_events(calendar: Calendar = CALENDAR, limit: int = 5) -> list: +def get_current_events(calendar: Calendar, limit: int = 5) -> list: """ Get upcoming events from calendar :param calendar: The calendar object @@ -170,3 +168,20 @@ def get_current_events(calendar: Calendar = CALENDAR, limit: int = 5) -> list: }) return events + + +def get_current_events_with_cal(limit: int = 5) -> list: + # Get URL + calendar_url: str = settings.current_events_settings.calendar_url + if calendar_url is None or calendar_url == "": + return [] + + # Get ICS + try: + calendar: Calendar = Calendar(requests.get(calendar_url, timeout=3).text) + except RequestException as e: + print("E", str(e)) + return [] + + # Get events + return get_current_events(calendar, settings.current_events_settings.events_count) diff --git a/schoolapps/schoolapps/settings.py b/schoolapps/schoolapps/settings.py index 94ec985f92532d298e26ba8091f8278e058c1a40..3a8ae45210903a758ed24b1d6bb81ec660c8b105 100755 --- a/schoolapps/schoolapps/settings.py +++ b/schoolapps/schoolapps/settings.py @@ -124,7 +124,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # TIMETABLE TIMETABLE_WIDTH = 5 -TIMETABLE_HEIGHT = 10 +TIMETABLE_HEIGHT = 9 LESSONS = [('8:00', '1.'), ('8:45', '2.'), ('9:45', '3.'), ('10:35', '4.'), ('11:35', '5.'), ('12:25', '6.'), ('13:15', '7.'), ('14:05', '8.'), ('14:50', '9.')] SHORT_WEEK_DAYS = ["Mo", "Di", "Mi", "Do", "Fr"] diff --git a/schoolapps/static/js/dashboard.js b/schoolapps/static/js/dashboard.js index 3d721599c557a5128efe28cf7c483f98fc0a894b..b22214354991890c8a7780d9c327647c3499781d 100644 --- a/schoolapps/static/js/dashboard.js +++ b/schoolapps/static/js/dashboard.js @@ -46,18 +46,12 @@ function _inherits(subClass, superClass) { var REFRESH_TIME = 15; -function WithCheckCircleIcon(props) { - return React.createElement( - "div", - {className: "col s12"}, - React.createElement( - "i", - {className: "material-icons left green-text"}, - "check_circle" - ), - props.children - ); -} +// function WithCheckCircleIcon(props) { +// return <div className={"col s12"}> +// <i className={"material-icons left green-text"}>check_circle</i> +// {props.children} +// </div> +// } var Dashboard = function (_React$Component) { _inherits(Dashboard, _React$Component); @@ -74,7 +68,6 @@ var Dashboard = function (_React$Component) { } var timeout = window.setTimeout(_this.updateRefreshTime, 1000); _this.setState({refreshIn: _this.state.refreshIn - 1, timeout: timeout}); - console.log("WOrk"); } else { _this.updateData(); } @@ -116,7 +109,7 @@ var Dashboard = function (_React$Component) { console.log(notification); $("#not-" + notification.id).addClass("scale-out"); window.setTimeout(function () { - $("#not-" + notification.id).remove(); + $("#not-" + notification.id).hide(); }, 200); $.getJSON(API_URL + "/notifications/read/" + notification.id); this.updateData(); @@ -126,9 +119,10 @@ var Dashboard = function (_React$Component) { key: "render", value: function render() { if (this.state.isLoading) { + // Show loading screen until first data are loaded return React.createElement( "div", - {className: "row center-via-flex container", style: {"height": "10em"}}, + {className: "row center-via-flex container", style: {"height": "15em"}}, React.createElement( "div", {className: "center2-via-flex"}, @@ -157,8 +151,8 @@ var Dashboard = function (_React$Component) { ), React.createElement( "p", - {className: "text-center"}, - "Wird geladen \u2026" + {className: "text-center flow-text"}, + "Deine aktuellen Informationen werden geladen \u2026" ) ) ); @@ -187,6 +181,34 @@ var Dashboard = function (_React$Component) { this.state.user.full_name !== "" ? this.state.user.full_name : this.state.user.username, ". Hier findest du alle aktuellen Informationen:" ), + React.createElement( + "div", + {className: "alert success"}, + React.createElement( + "p", + null, + React.createElement( + "i", + {className: "material-icons left"}, + "report_problem" + ), + "Das neue Dashboard von SchoolApps befindet sich momentan in der ", + React.createElement( + "strong", + null, + "Testphase" + ), + ". Falls Fehler auftreten oder du einen Verbesserungsvorschlag f\xFCr uns hast, schreibe uns bitte unter ", + React.createElement( + "a", + { + href: "mailto:support@katharineum.de" + }, + "support@katharineum.de" + ), + "." + ) + ), this.state.unread_notifications && this.state.unread_notifications.length > 0 ? this.state.unread_notifications.map(function (notification) { return React.createElement( "div", @@ -236,8 +258,6 @@ var Dashboard = function (_React$Component) { "div", null, this.state.plan.hints.map(function (hint, idx) { - var from_date = moment(hint.from_date); - var to_date = moment(hint.to_date); return React.createElement( "div", {className: "alert primary", key: idx}, @@ -272,16 +292,16 @@ var Dashboard = function (_React$Component) { React.createElement( "div", {className: "dashboard-cards"}, - React.createElement( + this.state.has_plan ? React.createElement( "div", {className: "card"}, - this.state.has_plan ? React.createElement( + React.createElement( "div", {className: "card-content"}, React.createElement( "span", {className: "card-title"}, - "Vertretungen ", + "Plan ", this.state.plan.type === 2 ? "der" : "für", " ", React.createElement( @@ -294,8 +314,9 @@ var Dashboard = function (_React$Component) { ), this.state.lessons && this.state.lessons.length > 0 ? React.createElement( "div", - null, + {className: "timetable-plan"}, this.state.lessons.map(function (lesson) { + // Show one lesson row return React.createElement( "div", {className: "row"}, @@ -315,9 +336,7 @@ var Dashboard = function (_React$Component) { ), React.createElement( "div", - { - className: "right timetable-time grey-text text-darken-2" - }, + {className: "right timetable-time grey-text text-darken-2"}, React.createElement( "span", null, @@ -339,17 +358,9 @@ var Dashboard = function (_React$Component) { }) ); }) - ) : React.createElement( - "p", - null, - "Keine Vertretungen f\xFCr morgen vorhanden." - ) - ) : React.createElement( - "p", - {className: "flow-text"}, - "Keine Vertretungen vorhanden." + ) : "" ), - this.state.has_plan ? React.createElement( + React.createElement( "div", {className: "card-action"}, React.createElement( @@ -362,62 +373,8 @@ var Dashboard = function (_React$Component) { ), "anzeigen" ) - ) : "" - ), - React.createElement( - "div", - {className: "card"}, - React.createElement( - "div", - {className: "card-content"}, - React.createElement( - "span", - {className: "card-title"}, - "Mein Status" - ), - React.createElement( - "div", - {className: "row"}, - React.createElement( - WithCheckCircleIcon, - null, - this.state.user_type_formatted - ), - this.state.user_type === 1 || this.state.user_type === 2 ? React.createElement( - WithCheckCircleIcon, - null, - "Meine Klassen: ", - this.state.classes.join(", ") - ) : "", - this.state.user_type === 1 || this.state.user_type === 2 ? React.createElement( - WithCheckCircleIcon, - null, - "Meine Kurse: ", - this.state.courses.join(", ") - ) : "", - this.state.user_type === 1 ? React.createElement( - WithCheckCircleIcon, - null, - "Meine F\xE4cher: ", - this.state.subjects.join(", ") - ) : "", - this.state.user_type === 1 || this.state.has_wifi ? React.createElement( - WithCheckCircleIcon, - null, - "WLAN" - ) : React.createElement( - "div", - {className: "col"}, - React.createElement( - "i", - {className: "material-icons left red-text"}, - "cancel" - ), - "Kein WLAN" - ) - ) ) - ), + ) : "", this.state.current_events && this.state.current_events.length > 0 ? React.createElement( "div", {className: "card"}, @@ -448,63 +405,11 @@ var Dashboard = function (_React$Component) { {className: "card-action"}, React.createElement( "a", - { - href: "https://katharineum-zu-luebeck.de/aktuelles/termine/", - target: "_blank" - }, + {href: "https://katharineum-zu-luebeck.de/aktuelles/termine/", target: "_blank"}, "Weitere Termine" ) ) ) : "", - React.createElement( - "div", - {className: "card"}, - React.createElement( - "div", - {className: "card-content"}, - React.createElement( - "span", - {className: "card-title"}, - "Klausuren der ", - React.createElement( - "em", - null, - "Eb" - ) - ), - React.createElement( - "div", - {className: "card-panel event-card"}, - React.createElement( - "span", - {className: "title"}, - "Sextanereinschulung" - ), - React.createElement("br", null), - "28.Aug. 2019 18:30 - 22:00" - ), - React.createElement( - "div", - {className: "card-panel event-card"}, - React.createElement( - "span", - {className: "title"}, - "Sextanereinschulung" - ), - React.createElement("br", null), - "28.Aug. 2019 18:30 - 22:00" - ) - ), - React.createElement( - "div", - {className: "card-action"}, - React.createElement( - "a", - {href: "https://katharineum-zu-luebeck.de/aktuelles/termine/"}, - "Alle Klausuren" - ) - ) - ), this.state.newest_article ? React.createElement( "div", null, diff --git a/schoolapps/timetable/helper.py b/schoolapps/timetable/helper.py index 1187472575edf7ec5ce4a47b8937fa3c5c3b7dff..c2f9d451fc5d86bd7c1acc5ae7fe43f1c1145a1c 100644 --- a/schoolapps/timetable/helper.py +++ b/schoolapps/timetable/helper.py @@ -24,7 +24,7 @@ def get_name_for_next_week_day_from_today() -> str: date_formatted = "morgen" else: # Other weekday - date_formatted = LONG_WEEK_DAYS[next_weekday.isoweekday() - 2] + date_formatted = LONG_WEEK_DAYS[next_weekday.isoweekday() - 1][0] return date_formatted @@ -36,16 +36,11 @@ def get_type_and_object_of_user(user): _type = TYPE_TEACHER shortcode = user.username el = get_teacher_by_shortcode(shortcode) - plan_id = el.id - raw_type = "teacher" - elif _type == UserInformation.STUDENT: # Student _type = TYPE_CLASS _name = UserInformation.user_classes(user)[0] el = get_class_by_name(_name) - plan_id = el.id - raw_type = "class" else: return None, None