mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 21:52:44 +01:00
[API/Edudziennik] Use new getTeacher methods. Add teamId to lessons.
This commit is contained in:
parent
a2fa133831
commit
30303f50ac
@ -14,7 +14,6 @@ import pl.szczodrzynski.edziennik.data.db.modules.announcements.Announcement
|
|||||||
import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS
|
import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
|
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
|
||||||
import pl.szczodrzynski.edziennik.get
|
import pl.szczodrzynski.edziennik.get
|
||||||
import pl.szczodrzynski.edziennik.splitName
|
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
|
||||||
class EdudziennikWebAnnouncements(override val data: DataEdudziennik,
|
class EdudziennikWebAnnouncements(override val data: DataEdudziennik,
|
||||||
@ -37,9 +36,7 @@ class EdudziennikWebAnnouncements(override val data: DataEdudziennik,
|
|||||||
val subject = titleElement.text()
|
val subject = titleElement.text()
|
||||||
|
|
||||||
val teacherName = announcementElement.child(1).text()
|
val teacherName = announcementElement.child(1).text()
|
||||||
val teacher = teacherName.splitName()?.let { (teacherFirstName, teacherLastName) ->
|
val teacher = data.getTeacherByFirstLast(teacherName)
|
||||||
data.getTeacher(teacherFirstName, teacherLastName)
|
|
||||||
} ?: return@forEach
|
|
||||||
|
|
||||||
val dateString = announcementElement.getElementsByClass("datetime").first().text()
|
val dateString = announcementElement.getElementsByClass("datetime").first().text()
|
||||||
val startDate = Date.fromY_m_d(dateString)
|
val startDate = Date.fromY_m_d(dateString)
|
||||||
|
@ -82,8 +82,8 @@ class EdudziennikWebGrades(override val data: DataEdudziennik,
|
|||||||
|
|
||||||
val description = columnName + if (comment.isNotBlank()) " - $comment" else ""
|
val description = columnName + if (comment.isNotBlank()) " - $comment" else ""
|
||||||
|
|
||||||
val (teacherLastName, teacherFirstName) = info.child(1).text().split(' ')
|
val teacherName = info.child(1).text()
|
||||||
val teacher = data.getTeacher(teacherFirstName, teacherLastName)
|
val teacher = data.getTeacherByLastFirst(teacherName)
|
||||||
|
|
||||||
val addedDate = info.child(2).text().split(' ').let {
|
val addedDate = info.child(2).text().split(' ').let {
|
||||||
val day = it[0].toInt()
|
val day = it[0].toInt()
|
||||||
|
@ -16,7 +16,6 @@ import pl.szczodrzynski.edziennik.data.db.modules.api.SYNC_ALWAYS
|
|||||||
import pl.szczodrzynski.edziennik.data.db.modules.events.Event
|
import pl.szczodrzynski.edziennik.data.db.modules.events.Event
|
||||||
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
|
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata
|
||||||
import pl.szczodrzynski.edziennik.get
|
import pl.szczodrzynski.edziennik.get
|
||||||
import pl.szczodrzynski.edziennik.splitName
|
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
|
|
||||||
class EdudziennikWebHomework(override val data: DataEdudziennik,
|
class EdudziennikWebHomework(override val data: DataEdudziennik,
|
||||||
@ -46,9 +45,7 @@ class EdudziennikWebHomework(override val data: DataEdudziennik,
|
|||||||
val startTime = lessons.firstOrNull { it.subjectId == subject.id }?.displayStartTime
|
val startTime = lessons.firstOrNull { it.subjectId == subject.id }?.displayStartTime
|
||||||
|
|
||||||
val teacherName = homeworkElement.child(2).text()
|
val teacherName = homeworkElement.child(2).text()
|
||||||
val teacher = teacherName.splitName()?.let { (teacherFirstName, teacherLastName) ->
|
val teacher = data.getTeacherByFirstLast(teacherName)
|
||||||
data.getTeacher(teacherFirstName, teacherLastName)
|
|
||||||
} ?: return@forEach
|
|
||||||
|
|
||||||
val topic = homeworkElement.child(4).text()
|
val topic = homeworkElement.child(4).text()
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import pl.szczodrzynski.edziennik.data.db.modules.timetable.Lesson
|
|||||||
import pl.szczodrzynski.edziennik.get
|
import pl.szczodrzynski.edziennik.get
|
||||||
import pl.szczodrzynski.edziennik.getString
|
import pl.szczodrzynski.edziennik.getString
|
||||||
import pl.szczodrzynski.edziennik.singleOrNull
|
import pl.szczodrzynski.edziennik.singleOrNull
|
||||||
import pl.szczodrzynski.edziennik.splitName
|
|
||||||
import pl.szczodrzynski.edziennik.utils.Utils.d
|
import pl.szczodrzynski.edziennik.utils.Utils.d
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
@ -108,10 +107,8 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik,
|
|||||||
val teacherElement = info[1].child(0)
|
val teacherElement = info[1].child(0)
|
||||||
val teacherLongId = EDUDZIENNIK_TEACHER_ID.find(teacherElement.attr("href"))?.get(1)
|
val teacherLongId = EDUDZIENNIK_TEACHER_ID.find(teacherElement.attr("href"))?.get(1)
|
||||||
val teacherName = teacherElement.text().trim()
|
val teacherName = teacherElement.text().trim()
|
||||||
teacherName.splitName()?.let { (teacherLastName, teacherFirstName) ->
|
data.getTeacherByLastFirst(teacherName, teacherLongId).id
|
||||||
data.getTeacher(teacherFirstName, teacherLastName, teacherLongId)
|
} else null
|
||||||
}?.id ?: -1
|
|
||||||
} else -1
|
|
||||||
|
|
||||||
val lessonObject = Lesson(profileId, -1).also {
|
val lessonObject = Lesson(profileId, -1).also {
|
||||||
it.type = type
|
it.type = type
|
||||||
@ -121,6 +118,7 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik,
|
|||||||
it.endTime = endTime
|
it.endTime = endTime
|
||||||
it.subjectId = subject.id
|
it.subjectId = subject.id
|
||||||
it.teacherId = teacherId
|
it.teacherId = teacherId
|
||||||
|
it.teamId = data.teamClass?.id
|
||||||
|
|
||||||
it.id = it.buildId()
|
it.id = it.buildId()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user