diff mbox

[2/5] models: move _format_name to module for future use

Message ID 20170711184139.94122-2-sean@farley.io
State Accepted
Headers show

Commit Message

Sean Farley July 11, 2017, 6:41 p.m. UTC
In a following patch, we'll use this method in another function.

Signed-off-by: Sean Farley <sean@farley.io>
---
 patchwork/models.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Stephen Finucane July 12, 2017, 8:52 a.m. UTC | #1
On Tue, 2017-07-11 at 11:41 -0700, Sean Farley wrote:
> In a following patch, we'll use this method in another function.
> 
> Signed-off-by: Sean Farley <sean@farley.io>

I merged the next two patches with this one (with some slight changes), and
renamed the patch. For this aspect though:

Reviewed-by: Stephen Finucane <stephen@that.guru>
diff mbox

Patch

diff --git a/patchwork/models.py b/patchwork/models.py
index dcb4c55..df5c6fe 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -625,6 +625,9 @@  class Series(FilenameMixin, models.Model):
     def received_all(self):
         return self.total <= self.received_total
 
+    def _format_name(self, obj):
+        return obj.name.split(']')[-1]
+
     def add_cover_letter(self, cover):
         """Add a cover letter to the series.
 
@@ -632,9 +635,6 @@  class Series(FilenameMixin, models.Model):
         patches and cover letters.
         """
 
-        def _format_name(obj):
-            return obj.name.split(']')[-1]
-
         if self.cover_letter:
             # TODO(stephenfin): We may wish to raise an exception here in the
             # future
@@ -657,7 +657,7 @@  class Series(FilenameMixin, models.Model):
         # If none of the above are available, the name will be null.
 
         if not self.name:
-            self.name = _format_name(cover)
+            self.name = self._format_name(cover)
         else:
             try:
                 name = SeriesPatch.objects.get(series=self,
@@ -666,7 +666,7 @@  class Series(FilenameMixin, models.Model):
                 name = None
 
             if self.name == name:
-                self.name = _format_name(cover)
+                self.name = self._format_name(cover)
 
         self.save()