Badges are earned by users for meeting some conditions defined in the badge.json file
A Badge object (database model) is then created linking a user to a badge.
conditions
Condition is a sql check to be made for awarding a badge.
You have access to the variable NEW if you set the trigger_contition to “update” or “insert”. This is the database object after update or insert.
You have access to the variable OLD if you set the trigger_contition to “update” or “delete”. This is the database object after update or delete.
triggers
We want the badges to be given as soon as a condition is meet. Even if the event come from an event outside the Django application.
We do not want to relly on celery to periodicaly check for badges
Too often : this is a performance bootleneck
Too late : annoying for users
The check for each badge is checked when “something” change.
To create the database triggers that will be responsible for badge earning run:
>>> python manage.py create_badge_triggers
When you change badge.json (adding, updating or deleting badges) run this commande to reflect those changes in the database.
badge.json example
` [{"name": "Pionner", "code": "pionner", "condition": "age(NEW.date_joined) > interval '1 year'", "trigger_condition": "update", "trigger_table": "auth_user", "user_field": "id" }, {"name": "Collector", "code": "collector" "condition": "count(id) >= 5 from dummy_sketch where user_id = NEW.user_id", "trigger_condition": "insert", "trigger_table": "dummy_sketch", "user_field": "user_id" }, {"name": "Star", "code": "star", "condition": "hit_views > 1000 ", "trigger_condition": "update", "trigger_table": "dummy_sketch", "user_field": "user_id" }] ` name is the name of the badge as it will be displayed in the front or the API.
code is th unique code name of the badge
condition is the query that will be issued to check if the badge should be earned
trigger_contition tell when the check must be made. One of insert, update or delete
INSTALL
see INSTALL file for instructions.
Metadata
Release files for django-pg-badges 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-pg-badges-0.1.tar.gz | 6.2 kB | Without provenance | Details for django-pg-badges-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django-pg-badges-0.1.linux-x86_64.tar.gz | Details for django-pg-badges-0.1.linux-x86_64.tar.gz |
Total release size: 17.3 kB
Release files / django-pg-badges-0.1.tar.gz
| Download URL | django-pg-badges-0.1.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f92f8a8ebfdff42e1e39433ffc844c4d46360de48c0f41f31c0e54e85b13204
|
|
BLAKE2b-256 checksum How to use checksums |
1f9a70cebf1594a84db0b697c2ae4dc5aa16a6c24184b57eee165de5af1b145f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django-pg-badges-0.1.linux-x86_64.tar.gz
| Download URL | django-pg-badges-0.1.linux-x86_64.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0fd0cf3e69959cf3462388f4d3608b5ec83bda55fe9c9ffacd67147ac9b0af7
|
|
BLAKE2b-256 checksum How to use checksums |
6e9db38f2bbf8d988da316c177d83e765d2969c9530eb6042d7dfe708cace472
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-pg-badges 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.