Add Django 2+ support
2 files changed, 32 insertions(+), 31 deletions(-)

M trello_broker/migrations/0001_initial.py
M trello_broker/models.py
M trello_broker/migrations/0001_initial.py +24 -30
@@ 1,12 1,14 @@ 
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+# Generated by Django 2.1.1 on 2018-10-31 19:38
 
-from django.db import models, migrations
+from django.db import migrations, models
+import django.db.models.deletion
 import django.utils.timezone
 
 
 class Migration(migrations.Migration):
 
+    initial = True
+
     dependencies = [
     ]
 

          
@@ 14,74 16,70 @@ class Migration(migrations.Migration):
         migrations.CreateModel(
             name='BitBucketRepo',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('created', models.DateTimeField(default=django.utils.timezone.now)),
                 ('modified', models.DateTimeField(default=django.utils.timezone.now)),
                 ('name', models.CharField(help_text='Name of the repo. Used for internal identification', max_length=100)),
                 ('slug', models.SlugField(help_text='Slug ID given by BitBucket for this repository.', max_length=100)),
-                ('access_key', models.CharField(help_text='Secret key used to "authenticate" the request. If saved here the key must be appended to the BitBucket hook URL like so: http://yourserver.com/broker/?access_key=YOUR_ACCESS_KEY', max_length=100, blank=True)),
+                ('access_key', models.CharField(blank=True, help_text='Secret key used to "authenticate" the request. If saved here the key must be appended to the BitBucket hook URL like so: http://yourserver.com/broker/?access_key=YOUR_ACCESS_KEY', max_length=100)),
             ],
             options={
                 'verbose_name': 'BitBucket Repository',
                 'verbose_name_plural': 'BitBucket Repositories',
             },
-            bases=(models.Model,),
         ),
         migrations.CreateModel(
             name='BitBucketRule',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('created', models.DateTimeField(default=django.utils.timezone.now)),
                 ('modified', models.DateTimeField(default=django.utils.timezone.now)),
                 ('action', models.PositiveIntegerField(choices=[(1, 'Referenced'), (2, 'Fixes / Closes')])),
                 ('update', models.BooleanField(default=True, help_text='If checked, card will be updated with commit comment.')),
                 ('archive', models.BooleanField(default=False, help_text='If checked, card will be archived.')),
                 ('move', models.BooleanField(default=False, help_text='If checked, card will be moved to specified Trello List.')),
-                ('repo', models.ForeignKey(related_name='rules', to='trello_broker.BitBucketRepo')),
+                ('repo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rules', to='trello_broker.BitBucketRepo')),
             ],
             options={
                 'verbose_name': 'BitBucket Rule',
                 'verbose_name_plural': 'BitBucket Rules',
             },
-            bases=(models.Model,),
         ),
         migrations.CreateModel(
             name='TrelloBoard',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('created', models.DateTimeField(default=django.utils.timezone.now)),
                 ('modified', models.DateTimeField(default=django.utils.timezone.now)),
-                ('name', models.CharField(max_length=100, blank=True)),
-                ('status', models.PositiveIntegerField(default=0, choices=[(0, 'Active'), (1, 'Archived')])),
+                ('name', models.CharField(blank=True, max_length=100)),
+                ('status', models.PositiveIntegerField(choices=[(0, 'Active'), (1, 'Archived')], default=0)),
                 ('trello_id', models.CharField(max_length=100)),
             ],
             options={
                 'verbose_name': 'Trello Board',
                 'verbose_name_plural': 'Trello Boards',
             },
-            bases=(models.Model,),
         ),
         migrations.CreateModel(
             name='TrelloList',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('created', models.DateTimeField(default=django.utils.timezone.now)),
                 ('modified', models.DateTimeField(default=django.utils.timezone.now)),
                 ('name', models.CharField(max_length=100)),
-                ('status', models.PositiveIntegerField(default=0, choices=[(0, 'Active'), (1, 'Archived')])),
+                ('status', models.PositiveIntegerField(choices=[(0, 'Active'), (1, 'Archived')], default=0)),
                 ('trello_id', models.CharField(max_length=100)),
-                ('trello_board', models.ForeignKey(related_name='trello_lists', to='trello_broker.TrelloBoard')),
+                ('trello_board', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='trello_lists', to='trello_broker.TrelloBoard')),
             ],
             options={
                 'verbose_name': 'Trello List',
                 'verbose_name_plural': 'Trello Lists',
             },
-            bases=(models.Model,),
         ),
         migrations.CreateModel(
             name='TrelloToken',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('created', models.DateTimeField(default=django.utils.timezone.now)),
                 ('modified', models.DateTimeField(default=django.utils.timezone.now)),
                 ('name', models.CharField(help_text='Name of the account. Used for internal identification', max_length=100)),

          
@@ 92,32 90,28 @@ class Migration(migrations.Migration):
                 'verbose_name': 'Trello Token',
                 'verbose_name_plural': 'Trello Tokens',
             },
-            bases=(models.Model,),
         ),
         migrations.AddField(
             model_name='trelloboard',
             name='trello_token',
-            field=models.ForeignKey(to='trello_broker.TrelloToken'),
-            preserve_default=True,
+            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='trello_broker.TrelloToken'),
         ),
         migrations.AddField(
             model_name='bitbucketrule',
             name='trello_list',
-            field=models.ForeignKey(blank=True, to='trello_broker.TrelloList', null=True),
-            preserve_default=True,
-        ),
-        migrations.AlterUniqueTogether(
-            name='bitbucketrule',
-            unique_together=set([('repo', 'action')]),
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='trello_broker.TrelloList'),
         ),
         migrations.AddField(
             model_name='bitbucketrepo',
             name='trello_board',
-            field=models.ForeignKey(related_name='repos', to='trello_broker.TrelloBoard'),
-            preserve_default=True,
+            field=models.ForeignKey(limit_choices_to={'status': 0}, on_delete=django.db.models.deletion.CASCADE, related_name='repos', to='trello_broker.TrelloBoard'),
+        ),
+        migrations.AlterUniqueTogether(
+            name='bitbucketrule',
+            unique_together={('repo', 'action')},
         ),
         migrations.AlterUniqueTogether(
             name='bitbucketrepo',
-            unique_together=set([('slug', 'access_key')]),
+            unique_together={('slug', 'access_key')},
         ),
     ]

          
M trello_broker/models.py +8 -1
@@ 58,7 58,10 @@ class TrelloToken(BaseModel):
 
 
 class TrelloBoard(BaseModel):
-    trello_token = models.ForeignKey('trello_broker.TrelloToken')
+    trello_token = models.ForeignKey(
+        'trello_broker.TrelloToken',
+        on_delete=models.CASCADE
+    )
     name = models.CharField(max_length=100, blank=True)
     status = models.PositiveIntegerField(
         default=STATUS_ACTIVE,

          
@@ 114,6 117,7 @@ class TrelloList(BaseModel):
     trello_board = models.ForeignKey(
         'trello_broker.TrelloBoard',
         related_name='trello_lists',
+        on_delete=models.CASCADE
     )
     name = models.CharField(max_length=100)
     status = models.PositiveIntegerField(

          
@@ 164,6 168,7 @@ class BitBucketRepo(BaseModel):
         'trello_broker.TrelloBoard',
         limit_choices_to={'status': STATUS_ACTIVE},
         related_name='repos',
+        on_delete=models.CASCADE
     )
 
     class Meta:

          
@@ 198,6 203,7 @@ class BitBucketRule(BaseModel):
     repo = models.ForeignKey(
         'trello_broker.BitBucketRepo',
         related_name='rules',
+        on_delete=models.CASCADE
     )
     action = models.PositiveIntegerField(
         choices=ACTION_CHOICES,

          
@@ 219,6 225,7 @@ class BitBucketRule(BaseModel):
         'trello_broker.TrelloList',
         null=True,
         blank=True,
+        on_delete=models.SET_NULL
     )
 
     class Meta: