Commit a10c4a3e authored by Stephen Finucane's avatar Stephen Finucane Committed by Damien Lespiau
Browse files

models: Resolve issues with Patch.state



The initial migration was incomplete: running 'makemigrations' on
the current codebase would produce a migration which could not be
applied. Fix this issue and add a suitable migration to resolve the
issue henceforth.
Signed-off-by: default avatarStephen Finucane <stephen.finucane@intel.com>
Acked-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
parent c8223d87
......@@ -2,12 +2,12 @@
from __future__ import unicode_literals
from django.db import models, migrations
from django.core.management import call_command
import datetime
import patchwork.models
import django.db.models.deletion
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('patchwork', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='patch',
name='state',
field=models.ForeignKey(to='patchwork.State', null=True),
),
]
......@@ -244,7 +244,7 @@ class Patch(models.Model):
date = models.DateTimeField(default=datetime.datetime.now)
submitter = models.ForeignKey(Person)
delegate = models.ForeignKey(User, blank = True, null = True)
state = models.ForeignKey(State, default=get_default_initial_patch_state)
state = models.ForeignKey(State, null=True)
archived = models.BooleanField(default = False)
headers = models.TextField(blank = True)
content = models.TextField(null = True, blank = True)
......@@ -290,10 +290,8 @@ class Patch(models.Model):
self._set_tag(tag, counter[tag])
def save(self):
try:
s = self.state
except:
self.state = State.objects.get(ordering = 0)
if not hasattr(self, 'state') or not self.state:
self.state = get_default_initial_patch_state()
if self.hash is None and self.content is not None:
self.hash = hash_patch(self.content).hexdigest()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment