]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: Use 'objects.create' instead of 'save'
authorStephen Finucane <stephen@that.guru>
Tue, 11 Sep 2018 22:39:54 +0000 (16:39 -0600)
committerStephen Finucane <stephen@that.guru>
Wed, 31 Oct 2018 10:49:50 +0000 (10:49 +0000)
As noted in the Django documentation [1], this lets us do things in one
step.

[1] https://docs.djangoproject.com/en/dev/topics/db/queries/#creating-objects

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
patchwork/parser.py

index 6b7189cb138a7d21c92eb92d50c951ff8a119c2d..d6fa84372121b3c913f6a8ee9481445ab7207532 100644 (file)
@@ -1034,12 +1034,12 @@ def parse_mail(mail, list_id=None):
         # - there is an existing series, but it already has a patch with this
         #   number in it
         if not series or Patch.objects.filter(series=series, number=x).count():
-            series = Series(project=project,
-                            date=date,
-                            submitter=author,
-                            version=version,
-                            total=n)
-            series.save()
+            series = Series.objects.create(
+                project=project,
+                date=date,
+                submitter=author,
+                version=version,
+                total=n)
 
             # NOTE(stephenfin) We must save references for series. We
             # do this to handle the case where a later patch is
@@ -1109,12 +1109,12 @@ def parse_mail(mail, list_id=None):
                     msgid=msgid, series__project=project).first().series
 
             if not series:
-                series = Series(project=project,
-                                date=date,
-                                submitter=author,
-                                version=version,
-                                total=n)
-                series.save()
+                series = Series.objects.create(
+                    project=project,
+                    date=date,
+                    submitter=author,
+                    version=version,
+                    total=n)
 
                 # we don't save the in-reply-to or references fields
                 # for a cover letter, as they can't refer to the same