Skip to content
Snippets Groups Projects
Commit fbbf63db authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

[UNTIS] All teachers can be got from [new] untisconnect api | Basic timetable...

[UNTIS] All teachers can be got from [new] untisconnect api | Basic timetable app with all teachers in a list | Untisconnector app for models/api from [UNTIS]
parent c6fa54d7
No related branches found
No related tags found
1 merge request!86Merge school-apps
Showing
with 11199 additions and 393 deletions
......@@ -10,5 +10,23 @@
<user-name>www-data</user-name>
<introspection-schemas>*:schoolapps</introspection-schemas>
</data-source>
<data-source name="Django default2" uuid="ea4cff78-5949-410f-aa64-d6daa5fb293d">
<database-info product="MySQL" version="5.7.21-0ubuntu0.16.04.1" jdbc-version="4.0" driver-name="MySQL Connector Java" driver-version="mysql-connector-java-5.1.44 ( Revision: b3cda4f864902ffdde495b9df93937c3e20009be )">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="exact" quoted-identifiers="exact" />
<user-name>www-data</user-name>
<introspection-schemas>*:schoolapps</introspection-schemas>
</data-source>
<data-source name="Django untis" uuid="ae145b31-953d-4d55-ad07-b49b3287f618">
<database-info product="MySQL" version="5.7.21-0ubuntu0.16.04.1" jdbc-version="4.0" driver-name="MySQL Connector Java" driver-version="mysql-connector-java-5.1.44 ( Revision: b3cda4f864902ffdde495b9df93937c3e20009be )">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="exact" quoted-identifiers="exact" />
<user-name>www-data</user-name>
<introspection-schemas>*:untis</introspection-schemas>
</data-source>
</component>
</project>
\ No newline at end of file
......@@ -17,5 +17,37 @@
<property name="yearIsDateType" value="false" />
</driver-properties>
</data-source>
<data-source source="LOCAL" name="Django default2" uuid="ea4cff78-5949-410f-aa64-d6daa5fb293d">
<driver-ref>mysql</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/schoolapps/schoolapps/settings.py</remarks>
<jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql:///schoolapps</jdbc-url>
<driver-properties>
<property name="autoReconnect" value="true" />
<property name="zeroDateTimeBehavior" value="convertToNull" />
<property name="tinyInt1isBit" value="false" />
<property name="characterEncoding" value="utf8" />
<property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" />
</driver-properties>
</data-source>
<data-source source="LOCAL" name="Django untis" uuid="ae145b31-953d-4d55-ad07-b49b3287f618">
<driver-ref>mysql</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/schoolapps/schoolapps/settings.py</remarks>
<jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql:///untis</jdbc-url>
<driver-properties>
<property name="autoReconnect" value="true" />
<property name="zeroDateTimeBehavior" value="convertToNull" />
<property name="tinyInt1isBit" value="false" />
<property name="characterEncoding" value="utf8" />
<property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" />
</driver-properties>
</data-source>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -31,6 +31,8 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'dashboard.apps.DashboardConfig',
'aub.apps.AubConfig',
'untisconnect.apps.UntisconnectConfig',
'timetable.apps.TimetableConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
......@@ -83,7 +85,7 @@ DATABASES = {
},
'untis': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'untis',
'NAME': 'untiskath',
'USER': 'www-data',
'PASSWORD': 'grummelPASS1531',
'HOST': '',
......
......@@ -35,6 +35,16 @@ urlpatterns = [
#######
path('aub/', include('aub.urls')),
#################
# UNTIS CONNECT #
#################
path('untis/', include('untisconnect.urls')),
#############
# TIMETABLE #
#############
path('timetable/', include('timetable.urls')),
#########
# Admin #
#########
......
......@@ -94,6 +94,7 @@
{% if user.is_authenticated %}
<li><a href="{% url 'dashboard' %}">Dashboard</a></li>
<li><a href="{% url 'aub_index' %}">Antrag auf Unterrichtsbefreiung</a></li>
<li><a href="{% url 'timetable_admin_teachers' %}">Alle Lehrer</a></li>
<li><a href="{% url 'logout' %}">Abmelden</a></li>
{% endif %}
</ul>
......
{% include 'partials/header.html' %}
<main>
<ul class="collection">
{% for teacher in teachers %}
<li class="collection-item avatar">
<i class="circle">{{ teacher.shortcode }}</i>
{{ teacher.first_name }} <strong>{{ teacher.name }}</strong>
</li>
{% endfor %}
</ul>
</main>
{% include 'partials/footer.html' %}
from django.urls import path
from . import views
urlpatterns = [
path('teachers/', views.admin_teachers, name='timetable_admin_teachers')
]
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from untisconnect.api import get_all_teachers
# Create your views here.
@login_required
def admin_teachers(request):
teachers = get_all_teachers()
context = {
"teachers": teachers
}
return render(request, "timetable/admin/teachers.html", context)
from . import models
DB_NAME = 'untis'
SCHOOL_ID = 705103
SCHOOLYEAR_ID = 20172018
VERSION_ID = 1
TERM_ID = 8
class Teacher(object):
def __init__(self):
self.filled = False
self.id = None
self.shortcode = None
self.first_name = None
self.name = None
self.full_name = None
def __str__(self):
if self.filled:
return (self.first_name or "") + " " + (self.name or "")
else:
return "Unbekannt"
def create(self, db_obj):
self.filled = True
self.id = db_obj.teacher_id
self.shortcode = db_obj.name
self.name = db_obj.longname
self.first_name = db_obj.firstname
def run_all(obj):
return run_default_filter(obj.using(DB_NAME).all())
def run_default_filter(obj):
return obj.filter(school_id=SCHOOL_ID, schoolyear_id=SCHOOLYEAR_ID, version_id=VERSION_ID, term_id=TERM_ID)
def get_all_teachers():
teachers = []
db_teachers = run_all(models.Teacher.objects)
for db_teacher in db_teachers:
t = Teacher()
t.create(db_teacher)
teachers.append(t)
return teachers
This diff is collapsed.
<h1>UNTIS CONNECTING SYSTEM</h1>
{{ teachers }}
{% for teacher in teachers %}
<p>{{ teacher.first_name }} {{ teacher.name }}</p>
{% endfor %}
\ No newline at end of file
from django.urls import path
from . import views
urlpatterns = [
path('', views.test, name='untisconnect_test')
]
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
# Create your views here.
from .api import get_all_teachers
@login_required
def test(request):
teachers = get_all_teachers()
context = {
'teachers': teachers
}
return render(request, "untisconnect/test.html", context=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