14
2

This question will be filled out with information on how to customize badges as part of the OSQA customization guide.

How do you customize badges or create new badges?

  • Base/abstract implementations of badges are implemented in forum/badges/base.py
  • The specific badges are Implemented in forum_modules/default_badges
    • badges.py - implementation of badges
    • settings.py - defines constants related to the badges

Modifying constants associated with badges should be a matter of modifying the contants in forum_modules/default_badges/settings.py (can someone confirm?)

Creating new badges:

  • Should a new module be created for custom badges ( forum_modules/custom_badges ?)
  • A few words on how badges are implemented in general and what each of the Abstract Badges are meant for would be useful.

Note: the sql_scripts/badges.sql file (and the entire sql directory) can be ignored and will be removed according to hernani's comment below)

This question is marked "community wiki".

asked 15 Apr '10, 11:38

Parand's gravatar image

Parand
1667810
accept rate: 0%

edited 15 Apr '10, 13:26

Nice start, Parand! I will try to make sure to go over this with Hernani to confirm the steps. It might be a good idea to grant you editing privileges on the wiki, too.

(15 Apr '10, 11:59) rickross ♦♦

Just to tell that this is not forgotten, I'll try to finish this tonight after migrating all our sites to the new codebase.

(16 Apr '10, 13:37) Hernani Cerq... ♦♦

A badge in OSQA is represented by a class inheriting from AbstractBadge, that you can find under forum/badges/base.py. Besides the AbstractBadges class there are a couple of helper subclasses:

  • PostCountableAbstractBadge is useful for creating badges that are triggered by some countable value update, such as the famous question badge, awarded when a question reaches x number of views.
  • ActivityCountAbstractBadge used to create badges awarded when a user executes a certain action x number of times.
  • FirstActivityAbstractBadge basically the same, but only triggered by the first action of that type.

The default_badges folder is a module that contains the default badges implementations, you don't even need to use that module, you can create your own implementations in a separate module, or as an addition to the defaults.

Now is all I have time for, but I'll come back a bit latter and edit this with more details and some concrete examples.

PS: That sql file (and the entire sql scripts folder can just be ignored, they we're forgotten there on git, but they are gone on svn).

link
This answer is marked "community wiki".

answered 15 Apr '10, 12:29

Hernani%20Cerqueira's gravatar image

Hernani Cerq... ♦♦
16.8k65975
accept rate: 52%

edited 15 Apr '10, 12:29

Presumably these custom badges aren't accessible via the admin console? (i.e. You need to jump into the python to tweak their settings)

(22 Oct '10, 10:09) camassey

@Camassey, those are accessible through the admin as well.

(22 Oct '10, 10:23) Hernani Cerq... ♦♦

@Hernâni Hmmm... That's odd, because there seem to be about 10 badges that don't show up in the Admin for ASK.SQLServerCentral.com - Does it make a difference if they were created for the StackExchange import, or is this just a bug?

(22 Oct '10, 12:47) camassey

@Camassey, some badges don't have any type of configuration. For example, the autobiographer badge, or all the badges that are "first something". In fact, ask.ssc has only the default set of badges, which happen to be contained in a module, so they are just like any other custom badges.

(23 Oct '10, 10:59) Hernani Cerq... ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×61
×44
×5

Asked: 15 Apr '10, 11:38

Seen: 1,461 times

Last updated: 23 Oct '10, 10:59

powered by OSQA