-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated site specific badges (#3026)
* initial * pre-commit fix * auto * user auth
- Loading branch information
1 parent
f2a261b
commit 3651750
Showing
3 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 5.1.3 on 2024-11-30 14:15 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("website", "0160_merge_20241129_0712"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="badge", | ||
name="icon", | ||
field=models.ImageField(blank=True, null=True, upload_to="badges/"), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Generated by Django 5.1.3 on 2024-11-30 14:15 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def add_new_badges(apps, schema_editor): | ||
# Get the Badge model | ||
Badge = apps.get_model("website", "Badge") | ||
|
||
# Define the new badges to add | ||
new_badges = [ | ||
{ | ||
"title": "First IP Reported", | ||
"description": "Awarded for reporting the first intellectual property.", | ||
"type": "automatic", | ||
}, | ||
{ | ||
"title": "First Bid Placed", | ||
"description": "Awarded for placing the first bid.", | ||
"type": "automatic", | ||
}, | ||
{ | ||
"title": "First Bug Bounty", | ||
"description": "Awarded for earning the first bug bounty.", | ||
"type": "automatic", | ||
}, | ||
{ | ||
"title": "First Suggestion", | ||
"description": "Awarded for making the first suggestion.", | ||
"type": "automatic", | ||
}, | ||
] | ||
|
||
# Loop through the new badges and create them if they don't already exist | ||
for badge in new_badges: | ||
Badge.objects.get_or_create( | ||
title=badge["title"], | ||
defaults={ | ||
"description": badge["description"], | ||
"type": badge["type"], | ||
}, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("website", "0161_alter_badge_icon"), # Adjust based on your actual previous migration | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(add_new_badges), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters