Просмотр исходного кода

Merge pull request #4207 from netbox-community/3848-django-3.0

Closes #3848: Django 3.0
Jeremy Stretch 6 лет назад
Родитель
Сommit
38ff01e874

+ 2 - 2
.travis.yml

@@ -3,10 +3,10 @@ services:
   - postgresql
   - redis-server
 addons:
-  postgresql: "9.4"
+  postgresql: "9.6"
 language: python
 python:
-  - "3.5"
+  - "3.6"
 install:
   - pip install -r requirements.txt
   - pip install pycodestyle

+ 28 - 0
netbox/dcim/migrations/0097_mptt_remove_indexes.py

@@ -0,0 +1,28 @@
+# Generated by Django 3.0.3 on 2020-02-18 21:02
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('dcim', '0096_interface_ordering'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='region',
+            name='level',
+            field=models.PositiveIntegerField(editable=False),
+        ),
+        migrations.AlterField(
+            model_name='region',
+            name='lft',
+            field=models.PositiveIntegerField(editable=False),
+        ),
+        migrations.AlterField(
+            model_name='region',
+            name='rght',
+            field=models.PositiveIntegerField(editable=False),
+        ),
+    ]

+ 1 - 1
netbox/dcim/tests/test_api.py

@@ -40,7 +40,7 @@ class AppTest(APITestCase):
         self.assertEqual(choices_to_dict(response.data.get('cable:status')), CableStatusChoices.as_dict())
         content_types = ContentType.objects.filter(CABLE_TERMINATION_MODELS)
         cable_termination_choices = {
-            "{}.{}".format(ct.app_label, ct.model): ct.name for ct in content_types
+            "{}.{}".format(ct.app_label, ct.model): str(ct) for ct in content_types
         }
         self.assertEqual(choices_to_dict(response.data.get('cable:termination_a_type')), cable_termination_choices)
         self.assertEqual(choices_to_dict(response.data.get('cable:termination_b_type')), cable_termination_choices)

+ 2 - 1
netbox/extras/forms.py

@@ -467,7 +467,8 @@ class ScriptForm(BootstrapMixin, forms.Form):
             self.fields['_commit'].initial = False
 
         # Move _commit to the end of the form
-        self.fields.move_to_end('_commit', True)
+        commit = self.fields.pop('_commit')
+        self.fields['_commit'] = commit
 
     @property
     def requires_input(self):

+ 1 - 1
netbox/extras/tests/test_api.py

@@ -37,7 +37,7 @@ class AppTest(APITestCase):
         # Graph
         content_types = ContentType.objects.filter(GRAPH_MODELS)
         graph_type_choices = {
-            "{}.{}".format(ct.app_label, ct.model): ct.name for ct in content_types
+            "{}.{}".format(ct.app_label, ct.model): str(ct) for ct in content_types
         }
         self.assertEqual(choices_to_dict(response.data.get('graph:type')), graph_type_choices)
         self.assertEqual(choices_to_dict(response.data.get('graph:template_language')), TemplateLanguageChoices.as_dict())

+ 11 - 0
netbox/secrets/__init__.py

@@ -0,0 +1,11 @@
+# TODO: Rename the secrets app, probably
+# Python 3.6 introduced a standard library named "secrets," which obviously conflicts with this Django app. To avoid
+# renaming the app, we hotwire the components of the standard library that Django calls. (I don't like this any more
+# than you do, but it works for now.) The only references to the secrets modules are in django/utils/crypto.py.
+#
+# First, we copy secrets.compare_digest, which comes from the hmac module:
+from hmac import compare_digest
+
+# Then, we instantiate SystemRandom and map its choice() function:
+from random import SystemRandom
+choice = SystemRandom().choice

+ 3 - 3
requirements.txt

@@ -1,9 +1,9 @@
-Django>=2.2,<2.3
+Django>=3.0,<3.1
 django-cacheops==4.2
 django-cors-headers==3.2.1
-django-debug-toolbar==2.1
+django-debug-toolbar==2.2
 django-filter==2.2.0
-django-mptt==0.9.1
+django-mptt==0.11.0
 django-pglocks==1.0.4
 django-prometheus==1.1.0
 django-rq==2.2.0