Skip to content
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

create a collage from the top grants in matching pool #8674

Merged
merged 7 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
369 changes: 369 additions & 0 deletions app/assets/v2/js/lib/collage.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions app/grants/templates/grants/collage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% load static compress %}

<style type="text/css">
img{
}
</style>
<div class="Collage effect-parent">
{% for url in urls %}
{% if url.0 %}
<img src={{url.0}} data-scale="{{url.1}}">
{% endif %}
{% endfor %}

</div>


<script src="{% static "v2/js/lib/jquery.js" %}"></script>
<script src="{% static "v2/js/lib/collage.js" %}"></script>

3 changes: 2 additions & 1 deletion app/grants/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
grants, grants_addr_as_json, grants_bulk_add, grants_by_grant_type, grants_cart_view, grants_info, grants_landing,
ingest_contributions, ingest_contributions_view, invoice, leaderboard, manage_ethereum_cart_data,
new_matching_partner, profile, quickstart, remove_grant_from_collection, save_collection, subscription_cancel,
toggle_grant_favorite, verify_grant,
toggle_grant_favorite, verify_grant, collage
)

app_name = 'grants/'
Expand Down Expand Up @@ -58,6 +58,7 @@
path('<int:grant_id>/activity', grant_activity, name='log_activity'),
path('bulk_cart', bulk_grants_for_cart, name='bulk_grants_for_cart'),
path('<int:grant_id>/favorite', toggle_grant_favorite, name='favorite_grant'),
path('collage', collage, name='collage'),
path('activity', grant_activity, name='log_activity'),

path('cart_thumb/<str:profile>/<str:grants>', cart_thumbnail, name='cart_thumbnail'),
Expand Down
46 changes: 46 additions & 0 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3055,6 +3055,52 @@ def add_grant_from_collection(request, collection_id):
'grants': grants,
})

des_urls = '''
https://c.gitcoin.co/grants/585d392a242103745b40d0e763ef5c17/Screen_Shot_2020-01-08_at_16.58.17.png
https://c.gitcoin.co/grants/b6511284c11682532274e0a34342249f/bitcoinmalaysia.png
https://c.gitcoin.co/grants/e1cf1b8778f29c49dff65ed3be4928d0/CheeseLogo_250px.png
https://c.gitcoin.co/grants/3ecf3eb0214a58fc3b068fae9f45ffbe/BANKLESS_logo_text_noLV.jpg
https://c.gitcoin.co/grants/f1c27815bc10332bff4a6264ae971fca/2.jpg
https://c.gitcoin.co/grants/46305a72ce062b63a53b0ebe12becda7/Picture1.png
https://c.gitcoin.co/grants/5d05dcc46be53030475cdbdf646b8afd/Mol_LeArt_-_White.png
https://c.gitcoin.co/grants/6ae1a8d3a8752d352247615b877cd02d/contraktor.png
https://c.gitcoin.co/grants/ce84fcbf185bd593e54f5c810d060aac/triad_gw_2.jpg
https://c.gitcoin.co/grants/b8fcf1833fee32fc4be6fba254c1d912/cashu.png
'''

import math
def get_urls(scale):
import random
global des_urls
urls = des_urls.split("\n")

return_me = []
scale_by = scale
# set default, for when no CLR match enabled
for grant in Grant.objects.filter(is_clr_active=True).order_by('-clr_prediction_curve__0__1'):
url = None
if grant.logo:
url = grant.logo.url
if settings.DEBUG:
url = urls[random.randint(0, len(urls) - 2)]
else:
url = f'https://gitcoin.co/static/v2/images/grants/logos/{grant.id % 3}.png'
size = scale_by * math.sqrt(math.sqrt(grant.clr_match_estimate_this_round))
return_me.append((url, size))
return return_me


@staff_member_required
def collage(request):
scale = float(request.GET.get('scale', 0.03))
context = {
'urls': get_urls(scale)
}

response = TemplateResponse(request, 'grants/collage.html', context=context)
return response


@cache_page(60 * 60)
def cart_thumbnail(request, profile, grants):
width = int(request.GET.get('w', 348 * 5))
Expand Down
2 changes: 1 addition & 1 deletion app/marketing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

redis = RedisService().redis

rate_limit = '11/m' if not settings.FLUSH_QUEUE and not settings.MARKETING_FLUSH_QUEUE else '30000/s'
rate_limit = '30000/s' if settings.FLUSH_QUEUE or settings.MARKETING_FLUSH_QUEUE else '7/m'

@app.shared_task(bind=True, rate_limit=rate_limit)
def new_bounty_daily(self, email_subscriber_id, retry: bool = True) -> None:
Expand Down
53 changes: 3 additions & 50 deletions app/retail/templates/emails/grants/successful_contribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,8 @@
{% block content %}

<style>
hr {
width: 80%;
height: 2px;
border-radius: 25px;
border: none;
background-color: #D2D2D2;
}

.grant-header {
width: 100%;
text-align: center;
}

.left-grant-Header {
display: inline-block;
}

.right-grant-header {
display: inline-block;
}

.right-grant-header>h2 {
font-size: 20px;
line-height: 1.5em;
}

.grant-info {
Expand All @@ -65,7 +43,6 @@
.grant-description {
max-width: 50rem;
margin: 1.5rem auto;
text-align: center;
}

.grant-contribution {
Expand All @@ -74,16 +51,6 @@
font-size: 1rem;
}

.grant-button {
padding: 12px 36px;
font-size: 12px;
border-radius: 3px;
text-decoration: none;
background-color: #0D0764;
color: white;
font-weight: 600;
}

#grow-oss {
margin-top: 50px;
margin-bottom: 50px;
Expand All @@ -93,27 +60,13 @@
max-width: 25rem;
width: 100%;
}

@media screen and (min-width: 598px) {
.right-grant-header {
padding-left: 40px;
transform: translateY(-12.5%);
text-align: left;
}

.left-grant-Header>img {
transform: translateY(13.5%);
}
}
</style>

<div id="content-body">
<img class="center-img bounties-img" src="{% static 'v2/images/emails/grants.png' %}">
<div class="grant-header">
<div class="left-grant-Header">
<img src="{% static "v2/images/heart-robot.png" %}" alt="{% trans " Gitcoin Heart Robot" %}" title="{% trans "Gitcoin Heart Robot" %}">
</div>
<div class="right-grant-header" style="margin-top: 4em;">
<img src="{% static "v2/images/heart-robot.png" %}" alt="{% trans " Gitcoin Heart Robot" %}" title="{% trans "Gitcoin Heart Robot" %}">
<div style="margin-top: 4em;">
<h1 style="text-transform: none;">{% trans "Your contribution of" %} {{ subscription.amount_per_period|floatformat:3|intcomma }} {{ subscription.token_symbol }} {% trans "to " %} {{ grant.title }} {% trans " was successful" %}!
</h1>
<h2 style="text-transform: none;">{% trans "The world of open source is a better place because of you." %}
Expand Down Expand Up @@ -155,7 +108,7 @@ <h2 style="text-transform: none;">{% trans "The world of open source is a better
</div>

<br>
<a class="grant-button" href="{% url 'grants:details' grant.id grant.slug %}?{{ utm_tracking }}">{% trans "View Grant" %}</a>
<a class="button" href="{% url 'grants:details' grant.id grant.slug %}?{{ utm_tracking }}">{% trans "View Grant" %}</a>
<br>
<br>
<p>{% trans "If you ever need to, you can cancel your support" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,8 @@
{% block content %}

<style>
hr {
width: 80%;
height: 2px;
border-radius: 25px;
border: none;
background-color: #D2D2D2;
}

.grant-header {
width: 100%;
text-align: center;
}

.left-grant-header {
display: inline-block;
}

.right-grant-header {
display: inline-block;
}

.right-grant-header>h2 {
font-size: 20px;
line-height: 1.5em;
}

.grant-info {
Expand All @@ -65,7 +43,6 @@
.grant-description {
max-width: 50rem;
margin: 1.5rem auto;
text-align: center;
}

.grant-button {
Expand All @@ -86,30 +63,14 @@
max-width: 25rem;
width: 100%;
}

@media (min-width : 1386px) {
.left-grant-header>img {
transform: translateY(13.5%);
}
}

@media screen and (min-width: 598px) {
.right-grant-header {
padding-left: 40px;
transform: translateY(-12.5%);
text-align: left;
}
}
</style>
<div id="content-body">
<img class="center-img bounties-img" src="{% static 'v2/images/emails/grants.png' %}">
{% for grant_with_subscription in grants_with_subscription %}
{% with subscription=grant_with_subscription.subscription grant=grant_with_subscription.grant %}
<div class="grant-header">
<div class="left-grant-header">
<img src="{% static "v2/images/heart-robot.png" %}" alt="{% trans "Gitcoin Heart Robot" %}" title="{% trans "Gitcoin Heart Robot" %}">
</div>
<div class="right-grant-header">
<img src="{% static "v2/images/heart-robot.png" %}" alt="{% trans "Gitcoin Heart Robot" %}" title="{% trans "Gitcoin Heart Robot" %}">
<div style="margin-top: 4em;">
<h1 style="text-transform: none;">{% trans "Thank you for supporting" %} {{ grant.title }}!
</h1>
<h2 style="text-transform: none;">{% trans "The world of open source is a better place because of you." %}
Expand Down
79 changes: 47 additions & 32 deletions app/retail/templates/emails/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
}

h4, .h4 {
text-align: center;
padding-top: 40px;
}

Expand Down Expand Up @@ -768,8 +767,27 @@
width: 100%;
}

#footer {
padding-top: 40px;
color: #757087 !important;
}

.footer-links {
margin: 3em 1.4em;
margin: -53px 0px 110px 20px;
}

.footer-links div {
width: 25%;
float: left;
}

.footer-links div img {
float: right;
}

.footer-socials {
width: 3em;
height: auto;
}
}

Expand Down Expand Up @@ -798,8 +816,28 @@
width: 90%;
}

#footer {
padding-top: 40px;
margin: 0px 180px 0px 180px;
color: #757087 !important;
}

.footer-links {
margin: auto;
margin: -53px 0px 110px 0px;
}

.footer-links div {
width: 25%;
float: left;
}

.footer-links div img {
float: right;
}

.footer-socials {
width: 3em;
height: auto;
}
}

Expand All @@ -813,29 +851,6 @@
margin: 0.5em auto 0.5em auto;
}

#footer {
color: #757087 !important;
}

.footer-links {
max-width: 800px;
text-align: justify;
/* margin: auto; */
margin-top: 3em;
margin-bottom: 2em;
}

.footer-links:after {
content: "";
display: inline-block;
width: 100%;
}

.footer-socials {
width: 3em;
height: auto;
}

.bounties-img {
max-width: 20em;
height: auto;
Expand All @@ -852,17 +867,17 @@
{% endblock %}
</div>
<div id="footer">
<a href="https://www.facebook.com/GetGitcoin"><img class="footer-socials" src="{% static "v2/images/emails/facebook.png" %}"></a>
<div class="footer-links">
{% block footer_links %}
<a href="https://www.facebook.com/GetGitcoin"><img class="footer-socials" src="{% static "v2/images/emails/facebook.png" %}"></a>

<a href="https://www.youtube.com/channel/UCeKRqRjzSzq5yP-zUPwc6_w"><img class="footer-socials" src="{% static "v2/images/emails/youtube.png" %}"></a>
<div><a href="https://www.youtube.com/channel/UCeKRqRjzSzq5yP-zUPwc6_w"><img class="footer-socials" src="{% static "v2/images/emails/youtube.png" %}"></a></div>

<a href="https://www.twitter.com/gitcoin"><img class="footer-socials" src="{% static "v2/images/emails/twitter.png" %}"></a>
<div><a href="https://www.twitter.com/gitcoin"><img class="footer-socials" src="{% static "v2/images/emails/twitter.png" %}"></a></div>

<a href="https://github.com/gitcoinco/"><img class="footer-socials" src="{% static "v2/images/emails/github.png" %}"></a>
<div><a href="https://github.com/gitcoinco/"><img class="footer-socials" src="{% static "v2/images/emails/github.png" %}"></a></div>

<a href="mailto:[email protected]"><img class="footer-socials" src="{% static "v2/images/emails/email.png" %}"></a>
<div><a href="mailto:[email protected]"><img class="footer-socials" src="{% static "v2/images/emails/email.png" %}"></a></div>
{% endblock %}
</div>
<center style="margin-bottom: 80px;">
Expand All @@ -874,7 +889,7 @@
<p>
{% trans "Want to change how you receive these emails?" %}
<br>
{% trans "You can update your " %} <a href="{% url "email_settings" subscriber.priv %}{% if email_type %}?type={{email_type}}{% endif %}">{% trans "preferences" %}</a> or <a href="{% url "email_settings" subscriber.priv %}{% if email_type %}?type={{email_type}}{% endif %}">{% trans "unsubscribe" %}</a> {% trans "from this list." %}
{% trans "You can update your " %} <a href="{% url 'email_settings' subscriber.priv %}{% if email_type %}?type={{email_type}}{% endif %}">{% trans "preferences" %}</a> or <a href="{% url 'email_settings' subscriber.priv %}{% if email_type %}?type={{email_type}}{% endif %}">{% trans "unsubscribe" %}</a> {% trans "from this list." %}
</p>
</center>
</div>
Expand Down