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

migrates all quest rewards over to the xdai network #7852

Merged
merged 2 commits into from
Nov 11, 2020
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
3 changes: 2 additions & 1 deletion app/assets/v2/js/kudos-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function kudosSearch(elem) {
var auto_terms = [ 'rare', 'common', 'ninja', 'soft skills', 'programming' ];
var name = $(this).attr('name');
var filter_by_address = $(this).attr('filter_by_address');
var filter_by_network = $(this).attr('filter_by_network');

if (name == 'enemy') {
auto_terms = [ 'samurai', 'evil', 'undead', 'bot', 'cellarius', 'devcon', 'meme', 'doge', 'bowtie', 'moloch' ];
Expand All @@ -32,7 +33,7 @@ function kudosSearch(elem) {

let query = {
term: params.term[0] === '@' ? params.term.slice(1) : params.term,
network: 'mainnet',
network: filter_by_network,
filter_by_address: typeof filter_by_address != 'undefined' && filter_by_address ? filter_by_address : ''
};

Expand Down
8 changes: 8 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,14 @@ def get_natural_value(self):
def value_true(self):
return self.get_natural_value()

@property
def receive_tx_blockexplorer_link(self):
if self.network == 'xdai':
return f"https://explorer.anyblock.tools/ethereum/poa/xdai/transaction/{self.receive_txid}"
if self.network == 'mainnet':
return f"https://etherscan.io/tx/{self.receive_txid}"
return f"https://{self.network}.etherscan.io/tx/{self.receive_txid}"

@property
def amount_in_wei(self):
token = addr_to_token(self.tokenAddress)
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/templates/shared/add_kudos.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
<input type="hidden" name="keywords" value="{{keywords}}">
<div class="my-2">
<select name="{{name}}" filter_by_address="{{filter_by_address}}" class="kudos-search custom-select gc-border-blue">
<select name="{{name}}" filter_by_address="{{filter_by_address}}" filter_by_network="{% if kudos_network %}{{kudos_network}}{% else %}mainnet{%endif%}" class="kudos-search custom-select gc-border-blue">
<option></option>
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/kudos/templates/shared/kudos_card_hover_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
{% if tk.github_url %}
<a href="{{tk.github_url}}" target="_blank">{% trans 'Issue url' %}</a>
{% endif %}
<a title="{% trans 'tx in etherscan' %}" href="{% if not kt.network == 'mainnet' %}https://{{ kt.network }}.etherscan.io/tx/{{ kt.txid }}{% else %}https://etherscan.io/tx/{{ kt.txid }}{% endif %}" target="_blank" class="mb-1">{{ kt.txid|humanize_address }}</a>
<a title="{% trans 'tx in etherscan' %}" href="{{kt.receive_tx_blockexplorer_link}}" target="_blank" class="mb-1">{{ kt.txid|humanize_address }}</a>
</div>
{% endfor %}
2 changes: 1 addition & 1 deletion app/kudos/templates/transaction/receive_bulk.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1>{% trans "Congrats!" %} 🎉</h1>
{% if kudos_transfer.tx_status == 'not_subed' %}
to your Gitcoin profile. The web3 transaction will be submitted when gas fees are below 10 gWei.
{% elif kudos_transfer.receive_txid != 'pending_celery' %}
via transaction <a href="https://etherscan.io/tx/{{kudos_transfer.receive_txid}}"><span id="trans_id">{{kudos_transfer.receive_txid}}</span></a>
via transaction <a href="{{kudos_transfer.receive_tx_blockexplorer_link}}"><span id="trans_id">{{kudos_transfer.receive_txid}}</span></a>
{% else %}
{% endif %}

Expand Down
30 changes: 30 additions & 0 deletions app/quests/migrations/0028_auto_20201109_2213.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 2.2.4 on 2020-11-09 22:13

from django.db import migrations


def forwards(apps, schema_editor):
from quests.models import Quest
for quest in Quest.objects.filter(visible=True):
if quest.kudos_reward.on_xdai:
quest.kudos_reward = quest.kudos_reward.on_xdai
quest.save()
print(f'migrated {quest.pk}');
else:
print(f'could not migrate {quest.pk}');
quest.visible=False
quest.save()


def backwards(apps, schema_editor):
pass

class Migration(migrations.Migration):

dependencies = [
('quests', '0027_auto_20200520_1454'),
]

operations = [
migrations.RunPython(forwards, backwards),
]
4 changes: 2 additions & 2 deletions app/quests/templates/quests/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ <h4>
<input name=enemy type="hidden" value={{package.enemy}}>
<a class="remove" href=#>Remove</a>
<div class=hidden>
{% include 'shared/add_kudos.html' with name='enemy2' %}
{% include 'shared/add_kudos.html' with name='enemy2' kudos_network='xdai' %}
</div>
{% else %}
{% include 'shared/add_kudos.html' with name='enemy' %}
{% include 'shared/add_kudos.html' with name='enemy' kudos_network='xdai' %}
{% endif %}
</div>
<div class="form-group">
Expand Down