[PATCH v2 01/10] models: Resolve issues with Patch.state
Damien Lespiau
damien.lespiau at intel.com
Fri Oct 2 01:09:18 AEST 2015
On Thu, Oct 01, 2015 at 03:52:25PM +0100, Stephen Finucane wrote:
> @@ -243,7 +243,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)
I was wondering, is it necessary to change the null contraint here?
--
Damien
> archived = models.BooleanField(default = False)
> headers = models.TextField(blank = True)
> content = models.TextField(null = True, blank = True)
> @@ -279,10 +279,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()
> --
> 2.0.0
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
More information about the Patchwork
mailing list