-
-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements a svg badge.. #1546
Implements a svg badge.. #1546
Conversation
.."Open bounties <n open bounties>" for the /funding/embed endpoint. <BASE_URL>/funding/embed/?repo=https://github.com/gitcoinco/web&badge=1 Fixes: #1378
app/dashboard/embed.py
Outdated
@@ -8,7 +8,22 @@ | |||
from ratelimit.decorators import ratelimit | |||
|
|||
AVATAR_BASE = 'assets/other/avatars/' | |||
|
|||
SVG_BADGE =\ | |||
"""\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E122 continuation line missing indentation or outdented
app/dashboard/embed.py
Outdated
@@ -101,6 +116,18 @@ def embed(request): | |||
return err_response | |||
|
|||
try: | |||
badge = request.GET.get('badge', False) | |||
if badge: | |||
open_bounties = Bounty.objects.current() \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E111 indentation is not a multiple of four
app/dashboard/embed.py
Outdated
idx_status__in=['open'] | ||
) | ||
|
||
return HttpResponse(SVG_BADGE.replace('N_BOUNTIES', str(len(open_bounties))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E111 indentation is not a multiple of four
app/dashboard/embed.py
Outdated
) | ||
|
||
return HttpResponse(SVG_BADGE.replace('N_BOUNTIES', str(len(open_bounties))), | ||
content_type='image/svg+xml'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E703 statement ends with a semicolon
Codecov Report
@@ Coverage Diff @@
## master #1546 +/- ##
==========================================
+ Coverage 28.25% 28.41% +0.15%
==========================================
Files 129 130 +1
Lines 9531 9576 +45
Branches 1235 1240 +5
==========================================
+ Hits 2693 2721 +28
- Misses 6740 6757 +17
Partials 98 98
Continue to review full report at Codecov.
|
Style fixes
Refactor the svg markup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
Can we update this single string SVG_BADGE
to use the Django template engine?
You can define the svg in a .txt file under dashboard/templates
and update N_BOUNTIES
to {{ bounties_count }}
- Then you'd call tmpl = loader.get_template('template/path.txt')
and tmpl.render({'bounties_count': open_bounties.count()})
Feel free to reach out on Slack or in this PR if you have any questions!
app/dashboard/embed.py
Outdated
) | ||
|
||
return HttpResponse( | ||
SVG_BADGE.replace('N_BOUNTIES', str(len(open_bounties))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to update this to use .count()
versus len()
to avoid performance issues.
Preview of badge provided by @pinkiebell |
Use the template engine to render the svg markup.
Make isort happy ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pinkiebell Thanks for turning around my comments - LGTM! 🚢
Welcome to the community!
.."Open bounties " for the /funding/embed endpoint.
<BASE_URL>/funding/embed/?repo=https://github.com/gitcoinco/web&badge=1
Fixes: #1378