diff --git a/aleksis/apps/untis/management/commands/untis_import_mysql_all.py b/aleksis/apps/untis/management/commands/untis_import_mysql_all.py index 8d184073f7314ab760e8d35b0124b4b24467af4a..0783196fd8cc77b72398a2c2fe8940e62214ec92 100644 --- a/aleksis/apps/untis/management/commands/untis_import_mysql_all.py +++ b/aleksis/apps/untis/management/commands/untis_import_mysql_all.py @@ -1,6 +1,6 @@ from django.core.management.base import BaseCommand -from ...tasks import untis_import_mysql_current_term, untis_import_mysql_all_terms +from ...tasks import untis_import_mysql_all_terms, untis_import_mysql_current_term class Command(BaseCommand): diff --git a/aleksis/apps/untis/migrations/0002_auto_20200820_1542.py b/aleksis/apps/untis/migrations/0002_auto_20200820_1542.py new file mode 100644 index 0000000000000000000000000000000000000000..a3d79487be9872fa30e8e36f9ebf1ed2eb6ca310 --- /dev/null +++ b/aleksis/apps/untis/migrations/0002_auto_20200820_1542.py @@ -0,0 +1,17 @@ +# Generated by Django 3.0.9 on 2020-08-20 13:42 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('untis', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='globalpermissions', + options={'managed': False, 'permissions': (('do_xml_import', 'Kann XML-Import durchführen'), ('assign_subjects_to_groups', 'Kann Fächer zu Gruppen zuzuordnen'))}, + ), + ] diff --git a/aleksis/apps/untis/tasks.py b/aleksis/apps/untis/tasks.py index b48e4567fb2c770d1331ae85fc763525356b6dfb..256dcba6163eb649f6c64c96062dd272d196295c 100644 --- a/aleksis/apps/untis/tasks.py +++ b/aleksis/apps/untis/tasks.py @@ -1,8 +1,7 @@ from aleksis.apps.untis.util.mysql.importers.terms import ( - get_terms_for_date, get_future_terms_for_date, + get_terms_for_date, ) - from aleksis.core.util.core_helpers import celery_optional from .util.mysql.main import untis_import_mysql as _untis_import_mysql @@ -37,6 +36,7 @@ def untis_import_mysql_current_next_term(): terms = terms.union(future_terms[0:1]) _untis_import_mysql(terms) + @celery_optional def untis_import_mysql_current_future_terms(): """Celery task for import of UNTIS data from MySQL (current and future terms).""" diff --git a/aleksis/apps/untis/util/mysql/importers/terms.py b/aleksis/apps/untis/util/mysql/importers/terms.py index e9c0fe8a3820f736537a978f3dd985b4e0cf2357..fec353f534d1f319b607e8a794a4ef1e012c9068 100644 --- a/aleksis/apps/untis/util/mysql/importers/terms.py +++ b/aleksis/apps/untis/util/mysql/importers/terms.py @@ -31,6 +31,7 @@ def get_terms_for_date(for_date: Optional[date] = None) -> QuerySet: return qs + def get_future_terms_for_date(for_date: Optional[date] = None) -> QuerySet: """Get all furture terms (after the current term).""" @@ -44,8 +45,6 @@ def get_future_terms_for_date(for_date: Optional[date] = None) -> QuerySet: return qs - - logger = logging.getLogger(__name__) @@ -88,7 +87,9 @@ def import_terms( schoolyear_id=school_year_id ) school_term_name = ( - school_year.text if school_year.text else school_year.schoolyearzoned + school_year.text + if school_year.text + else school_year.schoolyearzoned ) logger.info(f" Import school year {school_year_id} ...") diff --git a/aleksis/apps/untis/util/mysql/main.py b/aleksis/apps/untis/util/mysql/main.py index 6813f08d9c5749a66519d060b288d78d530fbdbc..d0902af6df1be2dd24b455ee2570b7fb5d5a757a 100644 --- a/aleksis/apps/untis/util/mysql/main.py +++ b/aleksis/apps/untis/util/mysql/main.py @@ -5,10 +5,7 @@ from django.db.models import QuerySet from tqdm import tqdm -from aleksis.apps.untis.util.mysql.importers.terms import ( - get_terms_for_date, - import_terms, -) +from aleksis.apps.untis.util.mysql.importers.terms import import_terms from aleksis.apps.untis.util.mysql.util import TQDM_DEFAULTS from .importers.absences import import_absences