Skip to content

Commit feeb45f

Browse files
owockizoek1
authored andcommitted
1 parent d883bf2 commit feeb45f

File tree

2 files changed

+18
-38
lines changed

2 files changed

+18
-38
lines changed

app/assets/v2/js/grants/detail.js

+12-34
Original file line numberDiff line numberDiff line change
@@ -200,40 +200,18 @@ $(document).ready(function() {
200200

201201
$('#cancel_grant').on('click', function(e) {
202202
$('.modal-cancel-grants').on('click', function(e) {
203-
let contract_address = $('#contract_address').val();
204-
let grant_cancel_tx_id;
205-
let deployedSubscription = new web3.eth.Contract(compiledSubscription.abi, contract_address);
206-
207-
web3.eth.getAccounts(function(err, accounts) {
208-
deployedSubscription.methods.endContract()
209-
.send({
210-
from: accounts[0],
211-
gas: 3000000
212-
}).on('transactionHash', function(transactionHash) {
213-
grant_cancel_tx_id = $('#grant_cancel_tx_id').val();
214-
const linkURL = get_etherscan_url(transactionHash);
215-
216-
document.issueURL = linkURL;
217-
$('#transaction_url').attr('href', linkURL);
218-
$('.modal .close').trigger('click');
219-
enableWaitState('#grants-details');
220-
})
221-
.on('confirmation', function(confirmationNumber, receipt) {
222-
$.ajax({
223-
type: 'post',
224-
url: '',
225-
data: {
226-
'contract_address': contract_address,
227-
'grant_cancel_tx_id': grant_cancel_tx_id
228-
},
229-
success: function(json) {
230-
window.location.reload(false);
231-
},
232-
error: function() {
233-
_alert({ message: gettext('Canceling your grant failed to save. Please try again.') }, 'error');
234-
}
235-
});
236-
});
203+
$.ajax({
204+
type: 'post',
205+
url: '',
206+
data: {
207+
'grant_cancel_tx_id': '0x0',
208+
},
209+
success: function(json) {
210+
window.location.reload(false);
211+
},
212+
error: function() {
213+
_alert({ message: gettext('Canceling your grant failed to save. Please try again.') }, 'error');
214+
}
237215
});
238216
});
239217
});

app/grants/views.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,11 @@ def get_grants(request):
290290
if grant_stats.exists():
291291
grant_amount = lazy_round_number(grant_stats.first().val)
292292

293-
contributions = Contribution.objects.filter(
294-
id__in=request.user.profile.grant_contributor.filter(subscription_contribution__success=True).values(
295-
'subscription_contribution__id')).prefetch_related('subscription')
293+
contributions = Contribution.objects.none()
294+
if request.user.is_authenticated:
295+
contributions = Contribution.objects.filter(
296+
id__in=request.user.profile.grant_contributor.filter(subscription_contribution__success=True).values(
297+
'subscription_contribution__id')).prefetch_related('subscription')
296298

297299
contributions_by_grant = {}
298300
for contribution in contributions:
@@ -735,7 +737,7 @@ def grant_details(request, grant_id, grant_slug):
735737
grant.save()
736738
record_grant_activity_helper('update_grant', grant, profile)
737739
return redirect(reverse('grants:details', args=(grant.pk, grant.slug)))
738-
if 'contract_address' in request.POST:
740+
if 'grant_cancel_tx_id' in request.POST:
739741
grant.cancel_tx_id = request.POST.get('grant_cancel_tx_id', '')
740742
grant.active = False
741743
grant.save()

0 commit comments

Comments
 (0)