From a49be9e61f2713163c7307f8ebb1942b23824cbe Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 9 Nov 2016 14:55:37 -0500 Subject: [PATCH 1/3] blank=True, not null=True --- core/migrations/0008_auto_20161109_1448.py | 19 +++++++++++++++++++ core/models/bibmodels.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 core/migrations/0008_auto_20161109_1448.py diff --git a/core/migrations/0008_auto_20161109_1448.py b/core/migrations/0008_auto_20161109_1448.py new file mode 100644 index 00000000..df83407b --- /dev/null +++ b/core/migrations/0008_auto_20161109_1448.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0007_auto_20160923_1314'), + ] + + operations = [ + migrations.AlterField( + model_name='work', + name='related', + field=models.ManyToManyField(related_name='reverse_related', through='core.WorkRelation', to='core.Work', blank=True), + ), + ] diff --git a/core/models/bibmodels.py b/core/models/bibmodels.py index 61313bf8..a758fdea 100644 --- a/core/models/bibmodels.py +++ b/core/models/bibmodels.py @@ -99,7 +99,7 @@ class Work(models.Model): featured = models.DateTimeField(null=True, blank=True, db_index=True,) is_free = models.BooleanField(default=False) landings = GenericRelation(Landing, related_query_name='works') - related = models.ManyToManyField('self', symmetrical=False, null=True, through='WorkRelation', related_name='reverse_related') + related = models.ManyToManyField('self', symmetrical=False, blank=True, through='WorkRelation', related_name='reverse_related') age_level = models.CharField(max_length=5, choices=AGE_LEVEL_CHOICES, default='', blank=True) class Meta: From b252d0b7df105553b124b1c2745f5a4b34e73113 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 9 Nov 2016 15:24:11 -0500 Subject: [PATCH 2/3] fix block edit issues: 1. IPAddressField is deprecated. We can change this without consequence because the underlying field type is not changed. 2. New admin was not wired up. 3. There was a admin bug when one end of the block is zero. --- libraryauth/admin.py | 7 ++++++- libraryauth/models.py | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libraryauth/admin.py b/libraryauth/admin.py index 4844d659..11eb8217 100644 --- a/libraryauth/admin.py +++ b/libraryauth/admin.py @@ -5,7 +5,7 @@ from selectable.base import ModelLookup from selectable.registry import registry from django import forms -from django.contrib.admin import ModelAdmin +from django.contrib.admin import ModelAdmin, site from django.contrib.auth.models import User, Group class UserLookup(ModelLookup): @@ -47,3 +47,8 @@ class CardPatternAdmin(ModelAdmin): class EmailPatternAdmin(ModelAdmin): list_display = ('library', 'pattern', ) search_fields = ('library__name',) + +site.register(models.Library, LibraryAdmin) +site.register(models.Block, BlockAdmin) +site.register(models.CardPattern, CardPatternAdmin) +site.register(models.EmailPattern, EmailPatternAdmin) \ No newline at end of file diff --git a/libraryauth/models.py b/libraryauth/models.py index e30968bb..4af5c30a 100644 --- a/libraryauth/models.py +++ b/libraryauth/models.py @@ -140,7 +140,7 @@ class IP(object): if not isinstance(other, IP): other = IP(other) - if self.int and other.int: + if self.int is not None and other.int is not None: return self.int.__cmp__(other.int) raise ValueError('Invalid arguments') @@ -177,7 +177,7 @@ class IPAddressFormField(BaseIPAddressField): raise ValidationError(self.default_error_messages['invalid'], code='invalid') -class IPAddressModelField(models.IPAddressField): +class IPAddressModelField(models.GenericIPAddressField): __metaclass__ = models.SubfieldBase empty_strings_allowed = False @@ -205,10 +205,10 @@ class IPAddressModelField(models.IPAddressField): def formfield(self, **kwargs): defaults = {'form_class': IPAddressFormField} defaults.update(kwargs) - return super(models.IPAddressField, self).formfield(**defaults) + return super(models.GenericIPAddressField, self).formfield(**defaults) def deconstruct(self): - name, path, args, kwargs = super(models.IPAddressField, self).deconstruct() + name, path, args, kwargs = super(models.GenericIPAddressField, self).deconstruct() return name, path, args, kwargs class Block(models.Model): From c393740999406e9d99bb5ad8e2afdd9280e71759 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 9 Nov 2016 16:21:31 -0500 Subject: [PATCH 3/3] not sure when this slipped in --- frontend/templates/libraryauth/edit.html | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/templates/libraryauth/edit.html b/frontend/templates/libraryauth/edit.html index 78531997..4f7b963b 100644 --- a/frontend/templates/libraryauth/edit.html +++ b/frontend/templates/libraryauth/edit.html @@ -4,6 +4,7 @@ {% block extra_extra_head %} {{ block.super }} +