| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,19 +217,9 @@ def timetable(self, start, end, **type_and_id): | |||
| 217 | 217 | # if we have to deal with an object in element_id, | |
| 218 | 218 | # its id gets placed here anyway | |
| 219 | 219 | ||
| 220 | - json_start = utils.datetime_utils.format_date(start) | ||
| 221 | - json_end = utils.datetime_utils.format_date(end) | ||
| 222 | - | ||
| 223 | - if json_start > json_end: | ||
| 224 | - raise ValueError('Start can\'t be later than the end.') | ||
| 225 | - | ||
| 226 | - parameters = { | ||
| 227 | - 'id': int(element_id), | ||
| 228 | - 'type': element_type_table[element_type], | ||
| 229 | - 'startDate': json_start, | ||
| 230 | - 'endDate': json_end | ||
| 231 | - } | ||
| 232 | - | ||
| 220 | + parameters = self._create_date_param(end, start, | ||
| 221 | + id=int(element_id), type = element_type_table[element_type]) | ||
| 222 | + parameters = parameters["options"] # getTimetable is without options! | ||
| 233 | 223 | return objects.PeriodList, 'getTimetable', parameters | |
| 234 | 224 | ||
| 235 | 225 | @result_wrapper | |
@@ -297,21 +287,7 @@ def substitutions(self, start, end, departmentId=0): | |||
| 297 | 287 | :rtype: :py:class:`webuntis.objects.SubstitutionList` | |
| 298 | 288 | """ | |
| 299 | 289 | ||
| 300 | - json_start = utils.datetime_utils.format_date(start) | ||
| 301 | - json_end = utils.datetime_utils.format_date(end) | ||
| 302 | - | ||
| 303 | - if json_start > json_end: | ||
| 304 | - raise ValueError('Start can\'t be later than the end.') | ||
| 305 | - | ||
| 306 | - parameters = { | ||
| 307 | - 'startDate': json_start, | ||
| 308 | - 'endDate': json_end, | ||
| 309 | - 'departmentId': departmentId | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - # if departmentId: | ||
| 313 | - # parameters['departmentId'] = departmentId | ||
| 314 | - | ||
| 290 | + parameters = self._create_date_param(end, start, departmentId = departmentId) | ||
| 315 | 291 | return objects.SubstitutionList, 'getSubstitutions', parameters | |
| 316 | 292 | ||
| 317 | 293 | @result_wrapper | |
@@ -359,18 +335,7 @@ def exams(self, start, end, examTypeId=0): | |||
| 359 | 335 | :rtype: :py:class:`webuntis.objects.ExamsList` | |
| 360 | 336 | """ | |
| 361 | 337 | ||
| 362 | - json_start = utils.datetime_utils.format_date(start) | ||
| 363 | - json_end = utils.datetime_utils.format_date(end) | ||
| 364 | - | ||
| 365 | - if json_start > json_end: | ||
| 366 | - raise ValueError('Start can\'t be later than the end.') | ||
| 367 | - | ||
| 368 | - parameters = { | ||
| 369 | - 'startDate': json_start, | ||
| 370 | - 'endDate': json_end, | ||
| 371 | - 'examTypeId': examTypeId | ||
| 372 | - } | ||
| 373 | - | ||
| 338 | + parameters = self._create_date_param(end, start, examTypeId = examTypeId) | ||
| 374 | 339 | return objects.ExamsList, 'getExams', parameters | |
| 375 | 340 | ||
| 376 | 341 | @result_wrapper | |
@@ -386,20 +351,23 @@ def timetableWithAbsences(self, start, end): | |||
| 386 | 351 | :rtype: :py:class:`webuntis.objects.AbsencesList` | |
| 387 | 352 | """ | |
| 388 | 353 | ||
| 354 | + parameters = self._create_date_param(end, start) | ||
| 355 | + | ||
| 356 | + return objects.AbsencesList, 'getTimetableWithAbsences', parameters | ||
| 357 | + | ||
| 358 | + @staticmethod | ||
| 359 | + def _create_date_param(end, start, **kwargs): | ||
| 389 | 360 | json_start = utils.datetime_utils.format_date(start) | |
| 390 | 361 | json_end = utils.datetime_utils.format_date(end) | |
| 391 | - | ||
| 392 | 362 | if json_start > json_end: | |
| 393 | 363 | raise ValueError('Start can\'t be later than the end.') | |
| 394 | - | ||
| 395 | 364 | parameters = { | |
| 396 | - "options": { | ||
| 365 | + "options": dict({ | ||
| 397 | 366 | 'startDate': json_start, | |
| 398 | 367 | 'endDate': json_end, | |
| 399 | - } | ||
| 368 | + }, **kwargs) | ||
| 400 | 369 | } | |
| 401 | - | ||
| 402 | - return objects.AbsencesList, 'getTimetableWithAbsences', parameters | ||
| 370 | + return parameters | ||
| 403 | 371 | ||
| 404 | 372 | ||
| 405 | 373 | class Session(JSONRPCSession, ResultWrapperMixin): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments