Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Untis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Untis
Commits
dfcada11
Commit
dfcada11
authored
6 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Current status
parent
b8b3b2dd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/apps/untis/parse.py
+98
-69
98 additions, 69 deletions
biscuit/apps/untis/parse.py
biscuit/apps/untis/sub.py
+18
-7
18 additions, 7 deletions
biscuit/apps/untis/sub.py
with
116 additions
and
76 deletions
biscuit/apps/untis/parse.py
+
98
−
69
View file @
dfcada11
...
...
@@ -18,9 +18,75 @@ class Lesson(object):
el
.
create
(
day
,
hour
,
rooms
)
self
.
times
.
append
(
el
)
def
create
(
self
,
db_obj
):
def
create
(
self
,
raw_lesson
,
drive
):
self
.
filled
=
True
# Split data (,)
lesson_id
=
raw_lesson
.
lesson_id
raw_lesson_data
=
raw_lesson
.
lessonelement1
.
split
(
"
,
"
)
raw_time_data
=
raw_lesson
.
lesson_tt
.
split
(
"
,
"
)
rtd2
=
[]
for
el
in
raw_time_data
:
rtd2
.
append
(
el
.
split
(
"
~
"
))
# print(rtd2)
for
el
in
rtd2
:
day
=
int
(
el
[
1
])
hour
=
int
(
el
[
2
])
room_ids
=
untis_split_third
(
el
[
3
],
conv
=
int
)
rooms
=
[]
for
room_id
in
room_ids
:
r
=
drive
[
"
rooms
"
][
room_id
]
rooms
.
append
(
r
)
self
.
add_time
(
day
,
hour
,
rooms
)
# print(raw_lesson_data)
# print(raw_time_data)
# Split data more (~)
rld2
=
[]
for
el
in
raw_lesson_data
:
rld2
.
append
(
el
.
split
(
"
~
"
))
# print(rld2)
for
el
in
rld2
:
teacher_id
=
int
(
el
[
0
])
subject_id
=
int
(
el
[
2
])
room_ids
=
untis_split_third
(
el
[
4
],
int
)
class_ids
=
untis_split_third
(
el
[
17
],
conv
=
int
)
# print("TEACHER – ", teacher_id, "; SUBJECT – ", subject_id, "; ROOMS – ", room_ids, "; CLASSES – ",
# class_ids)
if
teacher_id
!=
0
:
teacher
=
drive
[
"
teachers
"
][
teacher_id
]
else
:
teacher
=
None
if
subject_id
!=
0
:
subject
=
drive
[
"
subjects
"
][
subject_id
]
else
:
subject
=
None
rooms
=
[]
for
room_id
in
room_ids
:
r
=
drive
[
"
rooms
"
][
room_id
]
rooms
.
append
(
r
)
classes
=
[]
for
class_id
in
class_ids
:
c
=
drive
[
"
classes
"
][
class_id
]
classes
.
append
(
c
)
# print("TEACHER – ", teacher, "; SUBJECT – ", subject, "; ROOMS – ", rooms,
# "; CLASSES – ", classes)
self
.
add_element
(
teacher
,
subject
,
rooms
,
classes
)
class
LessonElement
(
object
):
def
__init__
(
self
):
...
...
@@ -52,7 +118,7 @@ from .api import *
from
.api_helper
import
untis_split_third
def
pars
e
():
def
build_driv
e
():
odrive
=
{
"
teachers
"
:
get_all_teachers
(),
"
rooms
"
:
get_all_rooms
(),
...
...
@@ -72,7 +138,14 @@ def parse():
drive
[
key
][
id
]
=
el
print
(
drive
)
return
drive
drive
=
build_drive
()
def
parse
():
global
drive
lessons
=
[]
raw_lessons
=
get_raw_lessons
()
...
...
@@ -85,74 +158,9 @@ def parse():
if
raw_lesson
.
lesson_tt
and
raw_lesson
.
lessonelement1
:
# Create object
lesson_obj
=
Lesson
()
lesson_obj
.
create
(
raw_lesson
,
drive
)
# Split data (,)
lesson_id
=
raw_lesson
.
lesson_id
raw_lesson_data
=
raw_lesson
.
lessonelement1
.
split
(
"
,
"
)
raw_time_data
=
raw_lesson
.
lesson_tt
.
split
(
"
,
"
)
rtd2
=
[]
for
el
in
raw_time_data
:
rtd2
.
append
(
el
.
split
(
"
~
"
))
# print(rtd2)
for
el
in
rtd2
:
day
=
int
(
el
[
1
])
hour
=
int
(
el
[
2
])
room_ids
=
untis_split_third
(
el
[
3
],
conv
=
int
)
rooms
=
[]
for
room_id
in
room_ids
:
r
=
drive
[
"
rooms
"
][
room_id
]
rooms
.
append
(
r
)
lesson_obj
.
add_time
(
day
,
hour
,
rooms
)
# print(raw_lesson_data)
# print(raw_time_data)
# Split data more (~)
rld2
=
[]
for
el
in
raw_lesson_data
:
rld2
.
append
(
el
.
split
(
"
~
"
))
# print(rld2)
for
el
in
rld2
:
teacher_id
=
int
(
el
[
0
])
subject_id
=
int
(
el
[
2
])
room_ids
=
untis_split_third
(
el
[
4
],
int
)
class_ids
=
untis_split_third
(
el
[
17
],
conv
=
int
)
# print("TEACHER – ", teacher_id, "; SUBJECT – ", subject_id, "; ROOMS – ", room_ids, "; CLASSES – ",
# class_ids)
if
teacher_id
!=
0
:
teacher
=
drive
[
"
teachers
"
][
teacher_id
]
else
:
teacher
=
None
if
subject_id
!=
0
:
subject
=
drive
[
"
subjects
"
][
subject_id
]
else
:
subject
=
None
rooms
=
[]
for
room_id
in
room_ids
:
r
=
drive
[
"
rooms
"
][
room_id
]
rooms
.
append
(
r
)
classes
=
[]
for
class_id
in
class_ids
:
c
=
drive
[
"
classes
"
][
class_id
]
classes
.
append
(
c
)
# print("TEACHER – ", teacher, "; SUBJECT – ", subject, "; ROOMS – ", rooms,
# "; CLASSES – ", classes)
lesson_obj
.
add_element
(
teacher
,
subject
,
rooms
,
classes
)
# print("DAY – ", day, "; HOUR – ", hour, "; ROOMS – ", room_ids)
# print("DAY – ", day, "; HOUR – ", hour, "; ROOMS – ", room_ids)
lessons
.
append
(
lesson_obj
)
...
...
@@ -192,6 +200,27 @@ class LessonElementContainer(object):
self
.
room
=
room
def
get_lesson_by_id
(
id
):
global
drive
lesson
=
Lesson
()
raw_lesson
=
run_one
(
models
.
Lesson
.
objects
,
filter_term
=
True
).
get
(
lesson_id
=
id
)
lesson
.
create
(
raw_lesson
,
drive
)
return
lesson
def
get_lesson_element_by_id_and_teacher
(
lesson_id
,
teacher
):
print
(
lesson_id
)
try
:
lesson
=
get_lesson_by_id
(
lesson_id
)
except
Exception
:
return
None
for
element
in
lesson
.
elements
:
print
(
element
.
teacher
.
shortcode
)
if
element
.
teacher
.
id
==
teacher
.
id
:
return
element
return
None
def
get_plan
(
type
,
id
):
"""
Generates a plan for type (TYPE_TEACHE, TYPE_CLASS, TYPE_ROOM) and a id of the teacher (class, room)
"""
...
...
This diff is collapsed.
Click to expand it.
biscuit/apps/untis/sub.py
+
18
−
7
View file @
dfcada11
...
...
@@ -4,6 +4,7 @@ from untisconnect import models
from
untisconnect.api
import
run_default_filter
,
row_by_row_helper
,
get_teacher_by_id
,
get_subject_by_id
,
\
get_room_by_id
,
get_class_by_id
from
untisconnect.api_helper
import
run_using
,
untis_split_first
from
untisconnect.parse
import
get_lesson_by_id
,
get_lesson_element_by_id_and_teacher
DATE_FORMAT
=
"
%Y%m%d
"
...
...
@@ -33,6 +34,7 @@ class Substitution(object):
self
.
room_new
=
None
self
.
corridor
=
None
self
.
classes
=
None
self
.
lesson_element
=
None
def
__str__
(
self
):
if
self
.
filled
:
...
...
@@ -49,37 +51,46 @@ class Substitution(object):
self
.
type
=
list
(
db_obj
.
flags
)
self
.
text
=
db_obj
.
text
# Lesson
# Teacher
if
db_obj
.
teacher_idlessn
!=
0
:
self
.
teacher_old
=
get_teacher_by_id
(
db_obj
.
teacher_idlessn
)
self
.
teacher_old
=
get_teacher_by_id
(
db_obj
.
teacher_idlessn
)
if
db_obj
.
teacher_idsubst
!=
0
:
self
.
teacher_new
=
get_teacher_by_id
(
db_obj
.
teacher_idsubst
)
self
.
lesson_element
=
get_lesson_element_by_id_and_teacher
(
self
.
lesson_id
,
self
.
teacher_old
)
print
(
self
.
lesson
)
# Subject
self
.
subject_old
=
None
self
.
subject_old
=
self
.
lesson_element
.
subject
if
self
.
lesson_element
is
not
None
else
None
if
db_obj
.
subject_idsubst
!=
0
:
self
.
subject_new
=
get_subject_by_id
(
db_obj
.
subject_idsubst
)
# Room
self
.
room_old
=
None
self
.
room
s
_old
=
self
.
lesson_element
.
rooms
if
self
.
lesson_element
is
not
None
else
[]
if
db_obj
.
room_idsubst
!=
0
:
self
.
room_new
=
get_room_by_id
(
db_obj
.
room_idsubst
)
self
.
corridor
=
db_obj
.
corridor_id
# Classes
self
.
classes
=
[]
class_ids
=
untis_split_first
(
db_obj
.
classids
,
conv
=
int
)
print
(
class_ids
)
for
id
in
class_ids
:
self
.
classes
.
append
(
get_class_by_id
(
id
))
def
get_substitutions_by_date
():
subs_raw
=
run_default_filter
(
run_using
(
models
.
Substitution
.
objects
.
filter
(
date
=
"
20180821
"
)),
filter_term
=
False
)
print
(
subs_raw
)
subs_raw
=
run_default_filter
(
run_using
(
models
.
Substitution
.
objects
.
filter
(
date
=
"
20180821
"
).
order_by
(
"
classids
"
,
"
lesson
"
)),
filter_term
=
False
)
# print(subs_raw)
subs
=
row_by_row_helper
(
subs_raw
,
Substitution
)
print
(
subs
)
for
row
in
subs
:
print
(
row
.
classes
)
for
class_
in
row
.
classes
:
print
(
class_
.
name
)
return
subs
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment