Make name the PK

This commit is contained in:
Tris 2021-09-17 15:10:53 +10:00
parent 8496309ad7
commit aa130808d4
4 changed files with 27 additions and 3 deletions

View File

@ -13,7 +13,7 @@ INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'byostorage',
'example'
#'example'
]
SECRET_KEY = 'shh!'

View File

@ -0,0 +1,22 @@
# Generated by Django 3.2.7 on 2021-09-17 00:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('byostorage', '0003_auto_20210323_1047'),
]
operations = [
migrations.RemoveField(
model_name='userstorage',
name='id',
),
migrations.AlterField(
model_name='userstorage',
name='name',
field=models.SlugField(help_text='Storage tag', max_length=20, primary_key=True, serialize=False),
),
]

View File

@ -46,7 +46,7 @@ class UserStorage(models.Model):
on_delete=models.CASCADE,
null=True, blank=True)
name = models.SlugField(max_length=20,
unique=True,
primary_key=True,
help_text="Storage tag")
storage = models.CharField(max_length=255,
choices=STORAGE_CLASS_OPTIONS,

View File

@ -5,7 +5,7 @@ from django.core.exceptions import ValidationError
from byostorage.models import UserStorage
from byostorage.user import BYOStorage
from example.models import LinkedStorageTestModel
#from example.models import LinkedStorageTestModel
import tempfile
import os.path
@ -84,6 +84,7 @@ class BYOStorageTestCase(TestCase):
one = storage.get_storage('one')
self.assertEqual(one.base_location, 'other/one')
"""
class BYOStorageFieldTestCase(TestCase):
def setUp(self):
@ -108,3 +109,4 @@ class BYOStorageFieldTestCase(TestCase):
self.assertEqual(os.listdir(os.path.join(self.test_dir.name, 'one')), [expected])
"""