Badges: Request for reason field on manual badge assignment


(PJH) #1

Request for a “Reason field” for manually awarded badges.

Use case: I’d like to say why someone’s a special snowflake, or link to the post where they failed to get the joke, or describe the bug that they found, or why they got one of the more positive sounding badges I’ll no doubt come up with given some thought…

Not sure how the UI would actually show the reason and how it would fit in with the current screens however…


Discourse Development Contribution Guidelines
#2

This would be good. I was curious what I’d done to deserve the “Touched in the head by an angel” badge.


(Sam Saffron) #3

Visual mocks for this, I do want to get this working.


(Kane York) #4

Same format as badges awarded for posts, but with the reason instead of the link.


(Sam Saffron) #5

not of that, of the admin interface. the first step is just having a way to select a post when you assign a badge, solves 90% of the issue.


(PJH) #6

I already have ideas on how to do that - and it can be done (along with auto-badge assignment) with what’s already extant - I just need to get round to doing it without the actual process taking ages or too much resource server-side.

Presuming that gets done - all that would be needed to address my initial request is a free-form field on manually assigned badges that aren’t related to an individual post.


(PJH) #7

SQL query for the badge to be awarded…

WITH replies AS (
    SELECT user_id, id, topic_id, post_number, reply_to_post_number
    FROM posts
    WHERE raw LIKE '%b3fe22f0-a01d-11e4-bcd8-0800200c9a66%' AND
    reply_to_post_number IS NOT NULL AND
    user_id IN  (
        SELECT gu.user_id
        FROM group_users gu
        WHERE group_id IN(
            SELECT g.id
            FROM groups g
            WHERE g.name IN ('staff')
        )
    )
)
SELECT p.user_id, p.id post_id, p.created_at granted_at, r.id
FROM posts p, replies r
WHERE r.reply_to_post_number = p.post_number AND
r.topic_id = p.topic_id and
(:backfill OR r.id IN (:post_ids) )

A member of staff replying to a post and including the UUID in the reply will award the badge to the post being replied to.

Clearly you’d use different UUIDs for different badges. Or any other string that wouldn’t normally appear in a staff member’s post.

Replace staff with

  • admin or
  • moderators or
  • trust_level_4 or
  • your own site specific group name if you want to create a group who’s members can award that particular badge.

if you want to change who can award badges in this fashion. That part can be a comma separated list if you want to have more than one group be able to award the badge.

The UUID (or whatever text is used) is checked for in raw, not cooked, so it could be hidden in a <!-- comment block -->

Or the <!-- comment block --> including the delimiters could be the the text.


What cool badge queries have you come up with?
(Kane York) #8

:+1: Yep, that’s definitely the correct trigger condition. :smiley:

Nice query.


(PJH) #9

That was the bit I wasn’t 100% sure on - the reply should trigger the award, but it should be awarded to the post being replied to.

(edit riking: fix terminology)


(Sam Saffron) #10

This is now implemented via:


(Sam Saffron) #11

Note, for the time being you can only specify a post, specifying anything else is going to require a larger and more complicated set of changes.


(Sam Saffron) #12

@PJH I was just thinking about this and I kind of feel the “linking to post” fully resolves this request, cause you can always create a brand new post that explains why someone got the badge and link to that. Its cleaner than carrying extra text around that does not live in a post.


(Sam Saffron) #13

@PJH should I close this?


(PJH) #14

Sure. ­ ­ ­ ­ ­


(Régis Hanol) #15