From 5cd643861b48768a90788f9d6ad3bacf7566e586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonah=20Br=C3=BCchert?= Date: Thu, 23 May 2024 04:02:21 +0200 Subject: Remove broken django version checks --- src/lib/Bcfg2/Reporting/Storage/DjangoORM.py | 11 ++++------- src/lib/Bcfg2/Reporting/models.py | 10 +--------- src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py | 6 +----- src/lib/Bcfg2/Server/Admin.py | 9 +-------- src/lib/Bcfg2/Server/Core.py | 7 ++----- src/lib/Bcfg2/Server/Plugins/Reporting.py | 6 +----- 6 files changed, 10 insertions(+), 39 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py b/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py index 57accdb3b..49089ae12 100644 --- a/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py +++ b/src/lib/Bcfg2/Reporting/Storage/DjangoORM.py @@ -43,13 +43,10 @@ def load_django_models(): def get_all_field_names(model): - if django.VERSION[0] == 1 and django.VERSION[1] >= 8: - return [field.name - for field in model._meta.get_fields() - if field.auto_created == False and - not (field.is_relation and field.related_model is None)] - else: - return model._meta.get_all_field_names() + return [field.name + for field in model._meta.get_fields() + if field.auto_created == False and + not (field.is_relation and field.related_model is None)] class DjangoORM(StorageBase): diff --git a/src/lib/Bcfg2/Reporting/models.py b/src/lib/Bcfg2/Reporting/models.py index 345dd1bc3..faa972204 100644 --- a/src/lib/Bcfg2/Reporting/models.py +++ b/src/lib/Bcfg2/Reporting/models.py @@ -62,15 +62,7 @@ def _quote(value): """ global _our_backend if not _our_backend: - if django.VERSION[0] == 1 and django.VERSION[1] >= 7: - _our_backend = connections[get_db_label('Reporting')].ops - else: - from django.db import backend - try: - _our_backend = backend.DatabaseOperations( - connections[get_db_label('Reporting')]) - except TypeError: - _our_backend = backend.DatabaseOperations() + _our_backend = connections[get_db_label('Reporting')].ops return _our_backend.quote_name(value) diff --git a/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py b/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py index b42c10766..92cbe1196 100644 --- a/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py +++ b/src/lib/Bcfg2/Reporting/templatetags/bcfg2_tags.py @@ -395,11 +395,7 @@ class SortLinkNode(template.Node): self.text = template.Variable(text) def _render_template(self, context): - if django.VERSION[0] == 1 and django.VERSION[1] >= 8: - return context.template.engine.from_string(self.__TMPL__) - else: - from django.template.loader import get_template_from_string - return get_template_from_string(self.__TMPL__).render(context) + return context.template.engine.from_string(self.__TMPL__) def render(self, context): try: diff --git a/src/lib/Bcfg2/Server/Admin.py b/src/lib/Bcfg2/Server/Admin.py index 98ce9e524..30c04411a 100644 --- a/src/lib/Bcfg2/Server/Admin.py +++ b/src/lib/Bcfg2/Server/Admin.py @@ -30,14 +30,7 @@ try: import Bcfg2.Server.models HAS_DJANGO = True - if django.VERSION[0] == 1 and django.VERSION[1] >= 7: - HAS_REPORTS = True - else: - try: - import south # pylint: disable=W0611 - HAS_REPORTS = True - except ImportError: - HAS_REPORTS = False + HAS_REPORTS = True except ImportError: HAS_DJANGO = False HAS_REPORTS = False diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 78eed4b3e..59e9254c1 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -87,11 +87,8 @@ def close_db_connection(func): self.logger.debug("%s: Closing database connection" % threading.current_thread().getName()) - if django.VERSION[0] == 1 and django.VERSION[1] >= 7: - for connection in django.db.connections.all(): - connection.close() - else: - django.db.close_connection() # pylint: disable=E1101 + for connection in django.db.connections.all(): + connection.close() return rv return inner diff --git a/src/lib/Bcfg2/Server/Plugins/Reporting.py b/src/lib/Bcfg2/Server/Plugins/Reporting.py index e372006c7..fcce10fc8 100644 --- a/src/lib/Bcfg2/Server/Plugins/Reporting.py +++ b/src/lib/Bcfg2/Server/Plugins/Reporting.py @@ -11,11 +11,7 @@ from Bcfg2.Server.Plugin import Statistics, PullSource, Threaded, \ try: import django - if django.VERSION[0] == 1 and django.VERSION[1] >= 7: - HAS_REPORTING = True - else: - import south # pylint: disable=W0611 - HAS_REPORTING = True + HAS_REPORTING = True except ImportError: HAS_REPORTING = False -- cgit v1.2.3-1-g7c22