Render user display names in trophy messages
Review Request #9932 — Created May 11, 2018 and submitted
Trophy message rendering has been reworked. Instead of a method that
everyTrophyType
subclass must implement, instead they must only add a
format string attribute. By default, the recipient's name is the only
provided parameter, butTrophyType.format_display_text
can be
overridden to add extra context. All builtin trophies have been updated
to use this new behaviour.
Ran unit tests.
Description | From | Last Updated |
---|---|---|
I think there was a misunderstanding on what I was saying regarding legacy support. if a trophy only implements get_display_text, … |
chipx86 | |
"favor" |
chipx86 | |
This is currently checking for its own existence. It should be display_format_str. We can also keep all the legacy support … |
chipx86 | |
I think the review request ID should be a standard thing passed. This lets us simplify all subclasses. |
chipx86 | |
F401 'reviewboard.accounts.models.Trophy' imported but unused |
reviewbot | |
Needs to be in alphabetical order. |
chipx86 | |
F401 'reviewboard.accounts.trophies.MilestoneTrophy' imported but unused |
reviewbot | |
F841 local variable 'trophy' is assigned to but never used |
reviewbot | |
E303 too many blank lines (2) |
reviewbot | |
F401 'warnings.catch_warnings' imported but unused |
reviewbot | |
F401 'warnings' imported but unused |
reviewbot | |
F401 'warnings.catch_warnings' imported but unused |
reviewbot |
- Description:
-
Trophy message rendering has been reworked. Instead of a method that
every TrophyType
subclass must implement, instead they must only add aformat string attribute. By default, the recipient's name is the only provided parameter, but TrophyType.format_display_text
can beoverridden to add extra context. All builtin trophies have been updated to use this new behaviour. + + TODO: Add unit tests for future proofing the old-style trophies.
-
-
-
This is currently checking for its own existence. It should be
display_format_str
.We can also keep all the legacy support confined here, reducing the work needed in the caller, by doing:
if self.display_format_str is None: warnings.warn(...) return self.get_display_text(trophy)
-
I think the review request ID should be a standard thing passed. This lets us simplify all subclasses.
- Change Summary:
-
Addressed feedback.
- Commit:
-
91831baf554be59df7a4bf0a91f9c3d178a87daef711b850b2226b3db020113065f222045a2a17e6
Checks run (2 succeeded)
- Change Summary:
-
Add more tests
- Commit:
-
f711b850b2226b3db020113065f222045a2a17e6b00fa01a5554f2cfe683b802a08d7c23789f6816
- Description:
-
Trophy message rendering has been reworked. Instead of a method that
every TrophyType
subclass must implement, instead they must only add aformat string attribute. By default, the recipient's name is the only provided parameter, but TrophyType.format_display_text
can beoverridden to add extra context. All builtin trophies have been updated to use this new behaviour. - - TODO: Add unit tests for future proofing the old-style trophies.
- Change Summary:
-
Remove unused import.
- Commit:
-
b00fa01a5554f2cfe683b802a08d7c23789f6816541e5d5d9c9fe6915ff869753b4ce1918a4ea698
Checks run (2 succeeded)
- Change Summary:
-
Addressed feedback.
- Commit:
-
541e5d5d9c9fe6915ff869753b4ce1918a4ea6988326d1628f049b84f29f9bd07443ecba520e87e2
- Change Summary:
-
Flake8 fixups
- Commit:
-
8326d1628f049b84f29f9bd07443ecba520e87e2e1e5c5cffc1c2ae16ee577d3b2dface1751bbe08
Checks run (2 succeeded)
- Change Summary:
-
Fix weirdo catch_warnings edge case
- Commit:
-
e1e5c5cffc1c2ae16ee577d3b2dface1751bbe085aa4fb701384a5599b6f0ec66578cad27d467948