Skip to content

Commit

Permalink
Removed hardcoding of badge name
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmit Goswami committed Dec 19, 2024
1 parent c341a71 commit 5f7bdae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pontoon/batch/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def approve_translations(form, user, translations, locale):
if after_level > before_level:
badge_update["level"] = after_level
badge_update["name"] = "Review Master"
send_badge_notification(user, "Review Master Badge", after_level)
send_badge_notification(user, badge_update["name"], badge_update["level"])

# Approve translations.
translations.update(
Expand Down Expand Up @@ -155,7 +155,7 @@ def reject_translations(form, user, translations, locale):
if after_level > before_level:
badge_update["level"] = after_level
badge_update["name"] = "Review Master"
send_badge_notification(user, "Review Master Badge", after_level)
send_badge_notification(user, badge_update["name"], badge_update["level"])

# Reject translations.
suggestions.update(
Expand Down Expand Up @@ -258,7 +258,7 @@ def replace_translations(form, user, translations, locale):
if after_level > before_level:
badge_update["level"] = after_level
badge_update["name"] = "Translation Champion"
send_badge_notification(user, "Translation Champion Badge", after_level)
send_badge_notification(user, badge_update["name"], badge_update["level"])

changed_translation_pks = [c.pk for c in changed_translations]

Expand Down
6 changes: 3 additions & 3 deletions pontoon/translations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def create_translation(request):
# Send Translation Champion Badge notification information
translation_count = user.badges_translation_count
if translation_count in settings.BADGES_TRANSLATION_THRESHOLDS:
badge_name = "Translation Champion Badge"
badge_name = "Translation Champion"
badge_level = (
settings.BADGES_TRANSLATION_THRESHOLDS.index(translation_count) + 1
)
Expand Down Expand Up @@ -323,7 +323,7 @@ def approve_translation(request):
# Send Review Master Badge notification information
review_count = user.badges_review_count
if review_count in settings.BADGES_REVIEW_THRESHOLDS:
badge_name = "Review Master Badge"
badge_name = "Review Master"
badge_level = settings.BADGES_REVIEW_THRESHOLDS.index(review_count) + 1
_add_badge_data(response_data, user, badge_name, badge_level)

Expand Down Expand Up @@ -460,7 +460,7 @@ def reject_translation(request):
# Send Review Master Badge notification information
review_count = request.user.badges_review_count
if review_count in settings.BADGES_REVIEW_THRESHOLDS:
badge_name = "Review Master Badge"
badge_name = "Review Master"
badge_level = settings.BADGES_REVIEW_THRESHOLDS.index(review_count) + 1
_add_badge_data(response_data, request.user, badge_name, badge_level)

Expand Down
4 changes: 2 additions & 2 deletions translate/src/modules/editor/hooks/useSendTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export function useSendTranslation(): (ignoreWarnings?: boolean) => void {
);

const badgeLevel = content.badge_update?.level;
if (badgeLevel) {
if (content.badge_update?.name && badgeLevel) {
showBadgeTooltip({
badgeName: 'Translation Champion',
badgeName: content.badge_update?.name,
badgeLevel: badgeLevel,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ export function useUpdateTranslationStatus(

// Check for update in badge level
const badgeLevel = results.badge_update?.level;
if (badgeLevel) {
if (results.badge_update?.name && badgeLevel) {
showBadgeTooltip({
badgeName: 'Review Master',
badgeName: results.badge_update?.name,
badgeLevel: badgeLevel,
});
}
Expand Down

0 comments on commit 5f7bdae

Please sign in to comment.