-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Badge titles on user's profile (#524)
* Use same border radius for next and prev buttons * refactor button border radius code * reverted master * automated and custom badges on user's profile * initially populate badges table * #1 patch after review * feature: change original badge title from admin panel * migration file of badge table Co-authored-by: Deepanshu039 <[email protected]>
- Loading branch information
1 parent
7415c8f
commit 2599069
Showing
13 changed files
with
316 additions
and
35 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
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
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
14 changes: 14 additions & 0 deletions
14
zubhub_backend/zubhub/creators/management/commands/initial_badges.txt
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,14 @@ | ||
Hatchling:0:1 | ||
Flying Bird:10:1 | ||
Master of the sky:50:1 | ||
Expert Builder:100:1 | ||
Helping Hand:10:2 | ||
Always Available:500:2 | ||
Expert Advisor:1000:2 | ||
Getting Famous:10:3 | ||
Person of Interest:100:3 | ||
Popular Projects:5000:3 | ||
Idea Factory:100000:3 | ||
Interesting Projects:10:4 | ||
Favourite Kid:500:4 | ||
Captain Projects:1000:4 |
22 changes: 22 additions & 0 deletions
22
zubhub_backend/zubhub/creators/management/commands/populate_initial_badges.py
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,22 @@ | ||
from creators.models import Badge | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Populate Badge table with initial badges' | ||
|
||
def handle(self, *args, **kwargs): | ||
if Badge.objects.all().count() == 0: | ||
with open("./zubhub/creators/management/commands/initial_badges.txt", "r") as badges: | ||
badges = badges.readlines() | ||
for badge in badges: | ||
remove_col=badge.split(':') | ||
remove_col[2]=remove_col[2].split('\n')[0] | ||
title=remove_col[0] | ||
value=int(remove_col[1]) | ||
category_type=int(remove_col[2]) | ||
Badge.objects.create(badge_title = title, threshold_value=value, | ||
type= category_type ) | ||
self.stdout.write(self.style.SUCCESS('The Badge table has been successfully populated!')) | ||
else: | ||
self.stdout.write(self.style.NOTICE('The Badge table is already populated')) |
32 changes: 32 additions & 0 deletions
32
zubhub_backend/zubhub/creators/migrations/0009_auto_20220822_0842.py
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,32 @@ | ||
# Generated by Django 3.2 on 2022-08-22 08:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('creators', '0008_auto_20220222_0254'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Badge', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('type', models.PositiveSmallIntegerField(choices=[(1, 'Projects'), (2, 'Comments'), (3, 'Views'), (4, 'Likes')])), | ||
('threshold_value', models.IntegerField(blank=True, default=0)), | ||
('badge_title', models.CharField(default='', max_length=225)), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name='setting', | ||
name='contact', | ||
field=models.PositiveSmallIntegerField(blank=True, choices=[(1, 'WHATSAPP'), (2, 'EMAIL'), (3, 'SMS'), (4, 'WEB')], default=3, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='creator', | ||
name='badges', | ||
field=models.ManyToManyField(blank=True, related_name='creators', to='creators.Badge'), | ||
), | ||
] |
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
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
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
Oops, something went wrong.