From: Stephen Finucane Date: Tue, 11 Sep 2018 22:39:54 +0000 (-0600) Subject: parser: Use 'objects.create' instead of 'save' X-Git-Tag: v2.2.0-rc1~223 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a86415c81f8f661a409baf1c33d766aa90945f37;p=thirdparty%2Fpatchwork.git parser: Use 'objects.create' instead of 'save' 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 Acked-by: Daniel Axtens --- diff --git a/patchwork/parser.py b/patchwork/parser.py index 6b7189cb..d6fa8437 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -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