Stephen Finucane <step...@that.guru> writes: > On Tue, 2017-07-11 at 11:41 -0700, Sean Farley wrote: >> This copies the same regex that parse uses to find the name. Perhaps future >> work should abstract this into a common method. >> >> Signed-off-by: Sean Farley <s...@farley.io> >> --- >> patchwork/models.py | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/patchwork/models.py b/patchwork/models.py >> index e1350c2..03109d3 100644 >> --- a/patchwork/models.py >> +++ b/patchwork/models.py >> @@ -619,7 +619,11 @@ class Series(FilenameMixin, models.Model): >> >> @staticmethod >> def _format_name(obj): >> -return obj.name.split(']')[-1].strip() >> +prefix_re = re.compile(r'^\[([^\]]*)\]\s*(.*)$') >> +match = prefix_re.match(obj.name) >> +if match: >> +return match.group(2) >> +return obj.name.strip() > > I'll admit, I initially thought this was wrong. The above will only handle a > single prefix (e.g. '[xxx] subject') and I thought you'd want to handle > multiple prefixes (e.g. '[xxx] [yyy] subject'). However, we don't store the > raw > subject in 'Submission.name' - rather, we take the original subject and clean > it up, and then store this [1]. After this cleanup, the subject is formatted > [2] as such: > > [xxx,yyy,...] subject > > ...so we'd only ever have to strip one set of prefixes. > >> @property >> def received_total(self): > > I've added a note to the above effect and applied the patch.
Oh, that's some nice analysis; thanks! I found the whole series name definition to be a bit wonky. Is there a definition of what it should be?
signature.asc
Description: PGP signature
_______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork