* Add a default message to badge award action Because: - The only badges routinely awarded manually use the same message - Right now, unfriendly/unsafe UI can result in an error notification The only badges that are currently awarded manually (afaik) have the message "Congrats!!!" so for the time being, if a message is not supplied to the UI, it will simply use the "Congrats!!!" message as a default. That being said, I'm not totally convinced this message won't work for the long term. Generally, if we are awarding badges by hand, I'd imagine we'd want a specific message explaining why we are doing that, or just be okay with "Congrats!" After talking with Peter about it, the longer term goal should be to move badge messages into the database so they can be modified in the app and not hardcoded. That also make sense regarding the effort to genericize the app eventually. * Test Badge notifications
22 lines
583 B
Ruby
22 lines
583 B
Ruby
class Internal::BadgesController < Internal::ApplicationController
|
|
layout "internal"
|
|
|
|
def index
|
|
@badges = Badge.all
|
|
end
|
|
|
|
def award_badges
|
|
usernames = permitted_params[:usernames].split(/\s*,\s*/)
|
|
badge_slug = permitted_params[:badge]
|
|
message = permitted_params[:message_markdown].presence || "Congrats!"
|
|
BadgeRewarder.award_badges(usernames, badge_slug, message)
|
|
flash[:success] = "BadgeRewarder task ran!"
|
|
redirect_to internal_badges_url
|
|
end
|
|
|
|
private
|
|
|
|
def permitted_params
|
|
params.permit(:usernames, :badge, :message_markdown)
|
|
end
|
|
end
|