Allow empty order numbers in django admin for Entitlements
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.25 on 2019-10-23 15:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('entitlements', '0011_historicalcourseentitlement'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='courseentitlement',
|
||||
name='order_number',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalcourseentitlement',
|
||||
name='order_number',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
]
|
||||
@@ -172,7 +172,7 @@ class CourseEntitlement(TimeStampedModel):
|
||||
blank=True,
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
order_number = models.CharField(max_length=128, null=True)
|
||||
order_number = models.CharField(max_length=128, null=True, blank=True)
|
||||
refund_locked = models.BooleanField(default=False)
|
||||
_policy = models.ForeignKey(CourseEntitlementPolicy, null=True, blank=True, on_delete=models.CASCADE)
|
||||
|
||||
@@ -449,6 +449,14 @@ class CourseEntitlement(TimeStampedModel):
|
||||
# Force Transaction reset with an Integrity error exception, this will revert all previous transactions
|
||||
raise IntegrityError
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""
|
||||
Null out empty strings in order_number
|
||||
"""
|
||||
if not self.order_number:
|
||||
self.order_number = None
|
||||
super(CourseEntitlement, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseEntitlementSupportDetail(TimeStampedModel):
|
||||
|
||||
Reference in New Issue
Block a user