Skip to content

Commit

Permalink
show blockexplorer url of transaction in email, retires old "x times"…
Browse files Browse the repository at this point in the history
… language in emails (#8520)

* block explorer url on emails

* show the block explorer URL in emails

* update

Co-authored-by: Kevin Owocki <[email protected]>
  • Loading branch information
owocki and Kevin Owocki authored Mar 10, 2021
1 parent c73ba50 commit 9b2b3d7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
10 changes: 10 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,16 @@ class Contribution(SuperModel):
)
anonymous = models.BooleanField(default=False, help_text=_('Whether users can view the profile for this project or not'))

@property
def blockexplorer_url(self):
if self.checkout_type == 'eth_zksync':
return f'https://zkscan.io/explorer/transactions/{self.split_tx_id.replace("sync-tx:", "")}'
if self.checkout_type == 'eth_std':
network_sub = f"{{self.subscription.network}}." if self.subscription and self.subscription.network != 'mainnet' else ''
return f'https://{network_sub}etherscan.io/tx/{self.split_tx_id}'
# TODO: support all block explorers for diff chains
return ''

def get_absolute_url(self):
return self.subscription.grant.url + '?tab=transactions'

Expand Down
12 changes: 7 additions & 5 deletions app/retail/templates/emails/grants/new_supporter.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,9 @@ <h1 style="text-transform: none;">{{ grant.title }}{% trans " has a new supporte
<a class="supporterName" href="{% url 'profile' subscription.contributor_profile.handle %}">
{{ subscription.contributor_profile.handle }}
</a>
<p>{% trans "has begun contributing" %}</p>
<p>{% trans "has contributed" %}</p>
<p style="padding-top:0;margin-top:.5rem">
<strong>{{ subscription.amount_per_period|floatformat:4|intcomma }} {{ subscription.token_symbol }} </strong>
{% if subscription.num_tx_approved > 1 %}
{% trans "every" %} {{ subscription.frequency }} {{ subscription.frequency_unit }}
{% endif %}
<strong> {{subscription.num_tx_approved|floatformat}} time{{ subscription.num_tx_approved|pluralize }}</strong>
</p>

{% if subscription.comments %}
Expand All @@ -83,8 +79,14 @@ <h1 style="text-transform: none;">{{ grant.title }}{% trans " has a new supporte
{% endif %}
<p>
<a href="{{grant.url}}" class="button" style="display: inline-block; margin-top:10px;">View Grant</a>
{% if subscription.subscription_contribution.first.blockexplorer_url %}
<br>
<br>
<a href="{{subscription.subscription_contribution.first.blockexplorer_url}}">View transaction</a>
{% endif %}

</p>
</div>
<hr>
{% endblock %}

4 changes: 2 additions & 2 deletions app/retail/templates/emails/grants/new_supporter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

{{ subscription.amount_per_period|floatformat:4|intcomma }}

{% trans " has begun contributing" %}
{% trans " has contributed" %}

{{ subscription.amount_per_period|floatformat:4|intcomma }} {{ subscription.token_symbol }} {% trans "per" %} {{ subscription.frequency }} {{ subscription.frequency_unit }}
{{ subscription.amount_per_period|floatformat:4|intcomma }} {{ subscription.token_symbol }}

{% trans "You can see the transaction on Etherscan" %} at
{% if subscription.network == 'mainnet' %}
Expand Down

0 comments on commit 9b2b3d7

Please sign in to comment.