Skip to content

Commit

Permalink
Merge pull request #24 from filips123/support-for-other-substitutions
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 authored Mar 31, 2021
2 parents 628560c + d428798 commit 2607619
Show file tree
Hide file tree
Showing 7 changed files with 1,209 additions and 1,002 deletions.
405 changes: 233 additions & 172 deletions API/poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions API/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ documentation = "https://github.com/filips123/GimVicUrnik/blob/main/README.md"

authors = [
"filips123 <[email protected]>",
"quAntum"
"ChristofferNorgaard"
]

keywords = [
Expand Down Expand Up @@ -43,7 +43,7 @@ Flask = "^1.1.2"
click = "^7.1.2"
schema = "^0.7.4"
requests = "^2.25.1"
SQLAlchemy = "^1.3.23"
SQLAlchemy = "^1.4.4"
pdf2docx = "^0.4.6"
openpyxl = "^3.0.7"
beautifulsoup4 = { extras = ["lxml"], version = "^4.9.3" }
Expand All @@ -53,7 +53,7 @@ sentry-sdk = { extras = ["flask", "sqlalchemy"], version = "^1.0.0", optional =
flakehell = "^0.9.0"
black = "^20.8b1"
flake8-black = "^0.2.1"
flake8-bugbear = "^20.11.1"
flake8-bugbear = "^21.3.2"

[tool.poetry.extras]
sentry = ["sentry-sdk"]
Expand Down
36 changes: 18 additions & 18 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@
},
"dependencies": {
"@mdi/js": "^5.9.55",
"@sentry/tracing": "^6.1.0",
"@sentry/vue": "^6.1.0",
"pulltorefreshjs": "^0.1.21",
"@sentry/tracing": "^6.2.4",
"@sentry/vue": "^6.2.4",
"pulltorefreshjs": "^0.1.22",
"register-service-worker": "^1.7.2",
"vue": "^2.6.12",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.1",
"vuetify": "^2.4.4",
"vuetify": "^2.4.8",
"vuex": "https://github.com/filips123/vuex#preservestate-options-dist",
"vuex-module-decorators": "https://github.com/filips123/vuex-module-decorators#combined-dist",
"vuex-persist": "^3.1.3"
},
"devDependencies": {
"@types/pulltorefreshjs": "^0.1.4",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"@vue/cli-plugin-babel": "^4.5.11",
"@vue/cli-plugin-eslint": "^4.5.11",
"@vue/cli-plugin-pwa": "^4.5.11",
"@vue/cli-plugin-router": "^4.5.11",
"@vue/cli-plugin-typescript": "^4.5.11",
"@vue/cli-plugin-vuex": "^4.5.11",
"@vue/cli-service": "^4.5.11",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"@vue/cli-plugin-babel": "^4.5.12",
"@vue/cli-plugin-eslint": "^4.5.12",
"@vue/cli-plugin-pwa": "^4.5.12",
"@vue/cli-plugin-router": "^4.5.12",
"@vue/cli-plugin-typescript": "^4.5.12",
"@vue/cli-plugin-vuex": "^4.5.12",
"@vue/cli-service": "^4.5.12",
"@vue/eslint-config-standard": "^6.0.0",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^7.19.0",
"eslint": "^7.23.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-vue": "^7.5.0",
"sass": "^1.32.7",
"eslint-plugin-vue": "^7.8.0",
"sass": "^1.32.8",
"sass-loader": "^10.1.1",
"typescript": " ^4.1.5",
"vue-cli-plugin-vuetify": "^2.1.0",
"typescript": " ^4.2.3",
"vue-cli-plugin-vuetify": "^2.3.1",
"vue-template-compiler": "^2.6.12",
"vuetify-loader": "^1.7.2"
}
Expand Down
16 changes: 8 additions & 8 deletions website/src/components/timetable/TimetableDay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class TimetableDay extends Vue {
details: [
{
type: 'subject',
contents: displayedLesson.subjects
contents: displayedLesson.subjects.filter(x => x)
},
{
type: 'teacher',
Expand All @@ -111,7 +111,7 @@ export default class TimetableDay extends Vue {
type: 'classroom',
contents: displayedLesson.classrooms.filter(x => x)
}
]
].filter(x => x.contents.length)
})
}
}
Expand All @@ -129,13 +129,13 @@ export default class TimetableDay extends Vue {
},
{
type: 'subject',
contents: displayedLesson.subjects
contents: displayedLesson.subjects.filter(x => x)
},
{
type: 'classroom',
contents: displayedLesson.classrooms.filter(x => x)
}
]
].filter(x => x.contents.length)
})
}
}
Expand All @@ -159,7 +159,7 @@ export default class TimetableDay extends Vue {
type: 'teacher',
contents: displayedLesson.teachers
}
]
].filter(x => x.contents.length)
})
}
}
Expand All @@ -169,13 +169,13 @@ export default class TimetableDay extends Vue {
for (const displayedLesson of displayedLessons.values()) {
data.push({
time: displayedLesson.time,
substitution: false,
substitution: displayedLesson.substitution,
details: [
{
type: 'classroom',
contents: displayedLesson.classrooms
contents: displayedLesson.classrooms.filter(x => x)
}
]
].filter(x => x.contents.length)
})
}
}
Expand Down
14 changes: 7 additions & 7 deletions website/src/components/timetable/TimetableWeek.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default class TimetableWeek extends Vue {
details: [
{
type: 'subject',
contents: lesson.subjects
contents: lesson.subjects.filter(x => x)
},
{
type: 'teacher',
Expand All @@ -205,7 +205,7 @@ export default class TimetableWeek extends Vue {
},
{
type: 'subject',
contents: lesson.subjects
contents: lesson.subjects.filter(x => x)
},
{
type: 'classroom',
Expand All @@ -226,26 +226,26 @@ export default class TimetableWeek extends Vue {
},
{
type: 'subject',
contents: lesson.subjects
contents: lesson.subjects.filter(x => x)
},
{
type: 'teacher',
contents: lesson.teachers
}
]
].filter(x => x.contents.length)
})
}

// Convert lessons of empty classroom into displayed format
if (this.currentEntity?.type === EntityType.EmptyClassrooms) {
timeData.days.push({
substitution: false,
substitution: lesson.substitution,
details: [
{
type: 'classroom',
contents: lesson.classrooms
contents: lesson.classrooms.filter(x => x)
}
]
].filter(x => x.contents.length)
})
}
}
Expand Down
25 changes: 19 additions & 6 deletions website/src/utils/timetable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { DisplayedLesson, getLessonId, StorageModule } from '@/store/modules/sto

export function getTimetableData (entity: SelectedEntity | null, days: number[]): Map<number, Map<number, DisplayedLesson>> {
const dataSource = entity?.type !== EntityType.EmptyClassrooms ? StorageModule.timetable : StorageModule.emptyClassrooms
const substitutionsSource = entity?.type === EntityType.Class ? new Map(StorageModule.substitutions) : new Map()
const substitutionsSource = new Map(StorageModule.substitutions)

// Note: Substitutions may not work correctly for classroom because source data are not always complete
// This can't be fixed unless we get better source of substitutions (like official API)

const displayedLessons: Map<number, Map<number, DisplayedLesson>> = new Map()
for (const lesson of dataSource || []) {
Expand Down Expand Up @@ -36,13 +39,20 @@ export function getTimetableData (entity: SelectedEntity | null, days: number[])
})
}

// TODO: Add support for substitutions for teachers and classrooms

// Add substitution if it exists
// Currently only works for classes
if (SettingsModule.showSubstitutions && substitutionsSource.has(getLessonId(lesson))) {
for (const substitution of substitutionsSource.get(getLessonId(lesson))) {
if (substitution.subject) {
for (const substitution of (substitutionsSource.get(getLessonId(lesson)) || [])) {
// Check if teacher/classroom is correct for substitution
let isCorrectSubstitutionEntity = false
if (entity?.type === EntityType.Class || entity?.type === EntityType.EmptyClassrooms) {
isCorrectSubstitutionEntity = true
} else if (entity?.type === EntityType.Teacher) {
isCorrectSubstitutionEntity = entity.data.includes(substitution.teacher)
} else if (entity?.type === EntityType.Classroom) {
isCorrectSubstitutionEntity = entity.data.includes(substitution.classroom)
}

if (substitution.subject && isCorrectSubstitutionEntity) {
/* eslint-disable no-unused-expressions */
displayedLessons.get(lesson.day)?.get(lesson.time)?.subjects.push(substitution.subject)
displayedLessons.get(lesson.day)?.get(lesson.time)?.classes.push(substitution.class)
Expand Down Expand Up @@ -97,6 +107,9 @@ export function getTimetableData (entity: SelectedEntity | null, days: number[])
classrooms: [],
substitution: true
})
} else {
const displayedLesson = displayedLessons.get(substitutionList[0].day)?.get(substitutionList[0].time)
if (displayedLesson) displayedLesson.substitution = true
}

for (const substitution of substitutionList) {
Expand Down
Loading

0 comments on commit 2607619

Please sign in to comment.