[PATCH 2/5] models: move _format_name to module for future use
Sean Farley
sean at farley.io
Wed Jul 12 04:41:36 AEST 2017
In a following patch, we'll use this method in another function.
Signed-off-by: Sean Farley <sean at farley.io>
---
patchwork/models.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
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()
--
2.13.2
More information about the Patchwork
mailing list