Skip to content

Commit ddee452

Browse files
authored
Merge pull request #403 from wikimediabrasil/batch-title-in-edit-summary
batch title in edit summary
2 parents 8e94d54 + 750d6b1 commit ddee452

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

src/core/models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,10 +1463,9 @@ def edit_summary(self):
14631463
summaries.extend([c.user_summary for c in getattr(self, "previous_commands", [])])
14641464
combined = " | ".join([s for s in summaries[::-1] if bool(s)])
14651465
editgroups = self.editgroups_summary()
1466-
if editgroups:
1467-
return f"{editgroups}: {combined}" if combined else editgroups
1468-
else:
1469-
return combined
1466+
title = str(self.batch.name)
1467+
summary_parts = [editgroups, title, combined]
1468+
return ": ".join([s for s in summary_parts if len(s) > 0])
14701469

14711470
def editgroups_summary(self):
14721471
"""

src/core/tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def test_api_body(self):
647647
batch_id = batch.id
648648
cmd = batch.commands()[0]
649649
comment = (
650-
f"QuickStatements 3.0 [[:toollabs:qs-dev/batch/{batch_id}|batch #{batch_id}]]: hello"
650+
f"QuickStatements 3.0 [[:toollabs:qs-dev/batch/{batch_id}|batch #{batch_id}]]: b: hello"
651651
)
652652
self.assertEqual(
653653
cmd.api_body(self.api_client),

src/core/tests/test_batch.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,20 @@ def test_edit_summary_with_editgroups(self):
271271
)
272272
batch_id = batch.id
273273
cmd = BatchCommand.objects.get(batch=batch, index=0)
274+
self.assertEqual(
275+
cmd.edit_summary(),
276+
f"QuickStatements 3.0 [[:toollabs:abcdef/batch/{batch_id}|batch #{batch_id}]]: b: my comment",
277+
)
278+
cmd = BatchCommand.objects.get(batch=batch, index=1)
279+
self.assertEqual(
280+
cmd.edit_summary(),
281+
f"QuickStatements 3.0 [[:toollabs:abcdef/batch/{batch_id}|batch #{batch_id}]]: b",
282+
)
283+
batch = BatchFactory.load_from_parser(
284+
v1, "", "u", "Q1|P1|Q2 /* my comment */||Q1|P1|Q3"
285+
)
286+
batch_id = batch.id
287+
cmd = BatchCommand.objects.get(batch=batch, index=0)
274288
self.assertEqual(
275289
cmd.edit_summary(),
276290
f"QuickStatements 3.0 [[:toollabs:abcdef/batch/{batch_id}|batch #{batch_id}]]: my comment",
@@ -821,6 +835,18 @@ def test_edit_summary_with_editgroups(self):
821835
batch = BatchFactory.load_from_parser(par, "b", "u", COMMAND)
822836
batch_id = batch.id
823837
cmd = BatchCommand.objects.get(batch=batch, index=0)
838+
self.assertEqual(
839+
cmd.edit_summary(),
840+
f"QuickStatements 3.0 [[:toollabs:abcdef/batch/{batch_id}|batch #{batch_id}]]: b: my comment",
841+
)
842+
cmd = BatchCommand.objects.get(batch=batch, index=1)
843+
self.assertEqual(
844+
cmd.edit_summary(),
845+
f"QuickStatements 3.0 [[:toollabs:abcdef/batch/{batch_id}|batch #{batch_id}]]: b",
846+
)
847+
batch = BatchFactory.load_from_parser(par, "", "u", COMMAND)
848+
batch_id = batch.id
849+
cmd = BatchCommand.objects.get(batch=batch, index=0)
824850
self.assertEqual(
825851
cmd.edit_summary(),
826852
f"QuickStatements 3.0 [[:toollabs:abcdef/batch/{batch_id}|batch #{batch_id}]]: my comment",
@@ -838,11 +864,16 @@ def test_edit_summary_without_editgroups(self):
838864
Q4115189,Q5,
839865
"""
840866
par = CSVCommandParser()
841-
batch = BatchFactory.load_from_parser(par, "b", "u", COMMAND)
867+
batch = BatchFactory.load_from_parser(par, "", "u", COMMAND)
842868
cmd = BatchCommand.objects.get(batch=batch, index=0)
843869
self.assertEqual(cmd.edit_summary(), "my comment")
844870
cmd = BatchCommand.objects.get(batch=batch, index=1)
845871
self.assertEqual(cmd.edit_summary(), "")
872+
batch = BatchFactory.load_from_parser(par, "b", "u", COMMAND)
873+
cmd = BatchCommand.objects.get(batch=batch, index=0)
874+
self.assertEqual(cmd.edit_summary(), "b: my comment")
875+
cmd = BatchCommand.objects.get(batch=batch, index=1)
876+
self.assertEqual(cmd.edit_summary(), "b")
846877

847878
def test_remove_statemeny_by_value(self):
848879
COMMAND = """qid,P31,-P31

0 commit comments

Comments
 (0)