Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store a link back to the triggering event. #31

Merged
merged 1 commit into from
Mar 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions fedbadges/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _load_badge_from_yaml(self, fname):
log.error("Loading %r failed with %r" % (fname, e))
return None

def award_badge(self, username, badge_rule):
def award_badge(self, username, badge_rule, link=None):
""" A high level way to issue a badge to a Person.

It adds the person if they don't exist, and creates an assertion for
Expand Down Expand Up @@ -151,7 +151,7 @@ def award_badge(self, username, badge_rule):

try:
transaction.begin()
self.tahrir.add_assertion(badge_rule.badge_id, email, None)
self.tahrir.add_assertion(badge_rule.badge_id, email, None, link)
transaction.commit()
except:
transaction.abort()
Expand All @@ -165,6 +165,10 @@ def deferred_consume(self, msg):
# Strip the moksha envelope
msg = msg['body']

default = "https://apps.fedoraproject.org/datagrepper"
link = self.hub.config.get('fedbadges.datagrepper_url', default) + \
"/id?id=%s&is_raw=True&size=extra-large" % msg['msg_id']

# Define this so we can refer to it in error handling below
badge_rule = None

Expand All @@ -173,7 +177,7 @@ def deferred_consume(self, msg):
for badge_rule in self.badge_rules:
try:
for recipient in badge_rule.matches(msg):
self.award_badge(recipient, badge_rule)
self.award_badge(recipient, badge_rule, link)
except Exception as e:
log.error("Failure in badge awarder! %r Details follow:" % e)
log.error("Considering badge: %r" % badge_rule)
Expand Down
2 changes: 2 additions & 0 deletions fedmsg.d/badges-global.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
),
},

"fedbadges.datagrepper_url": "https://apps.fedoraproject.org/datagrepper",

# Some configuration for the pkgdb criteria handler
"fedbadges.rules.utils.use_pkgdb2": False,
"fedbadges.rules.utils.pkgdb_url": 'https://admin.fedoraproject.org/pkgdb',
Expand Down