FIX: Use correct badge slug within notifications

This commit is contained in:
Gerhard Schlager 2015-09-24 00:36:09 +02:00
parent 25e9aa7653
commit 445bd033d2
2 changed files with 9 additions and 3 deletions

View File

@ -22,8 +22,14 @@ export default Ember.Component.extend({
const it = this.get('notification');
const badgeId = it.get("data.badge_id");
if (badgeId) {
const badgeName = it.get("data.badge_name");
return Discourse.getURL('/badges/' + badgeId + '/' + badgeName.replace(/[^A-Za-z0-9_]+/g, '-').toLowerCase());
var badgeSlug = it.get("data.badge_slug");
if (!badgeSlug) {
const badgeName = it.get("data.badge_name");
badgeSlug = badgeName.replace(/[^A-Za-z0-9_]+/g, '-').toLowerCase();
}
return Discourse.getURL('/badges/' + badgeId + '/' + badgeSlug);
}
const topicId = it.get('topic_id');

View File

@ -44,7 +44,7 @@ class BadgeGranter
I18n.with_locale(@user.effective_locale) do
notification = @user.notifications.create(
notification_type: Notification.types[:granted_badge],
data: { badge_id: @badge.id, badge_name: @badge.display_name }.to_json)
data: { badge_id: @badge.id, badge_name: @badge.display_name, badge_slug: @badge.slug }.to_json)
user_badge.update_attributes notification_id: notification.id
end
end