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

Convert to Grant #8154

Merged
merged 8 commits into from
Dec 22, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ app/cache/
# Autogenerated Documentation
_build/
**/.vs
**/dist
8 changes: 6 additions & 2 deletions app/assets/v2/js/grants/_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ Vue.mixin({
'X-CSRFToken': $("input[name='csrfmiddlewaretoken']").val()
};

const apiUrlGrant = '/grants/new';

let apiUrlGrant = '/grants/new';
if (vm.queryParams.get('related_hackathon_project_id')) {
apiUrlGrant += `?related_hackathon_project_id=${vm.queryParams.get('related_hackathon_project_id')}`
}
$.ajax({
type: 'post',
url: apiUrlGrant,
Expand Down Expand Up @@ -375,12 +377,14 @@ if (document.getElementById('gc-new-grant')) {
const writeToRoot = ['chainId'];
const writeToBody = [
'title',
'description_rich',
'reference_url',
'twitter_handle_1',
'twitter_handle_2',
'github_project_url',
'eth_payout_address',
'grant_type',
'team_members',
'grant_categories'
];

Expand Down
7 changes: 6 additions & 1 deletion app/assets/v2/js/grants/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,15 @@ function saveGrant(grantData, isFinal) {
let csrftoken = $("#create-grant input[name='csrfmiddlewaretoken']").val();

$('#new_button').attr('disabled', 'disabled');
let newGrantURL = '/grants/new';
const queryParams = new URLSearchParams(window.location.search)
if (queryParams.get('related_hackathon_project_id')) {
newGrantURL += `?related_hackathon_project_id=${queryParams.get('related_hackathon_project_id')}`
}

$.ajax({
type: 'post',
url: '/grants/new',
url: newGrantURL,
processData: false,
contentType: false,
data: grantData,
Expand Down
3 changes: 3 additions & 0 deletions app/dashboard/templates/project/detail/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
{% endif %}

{% if is_member %}
{% if not project_obj.grant_url %}
<a :href="`/grants/new?title=${project.name}&description_rich=${project.summary}&reference_url=${project.work_url}&github_project_url=${project.work_url}&related_hackathon_project_id=${project.id}`" target="_blank" class="project__action--admin btn button-white btn-block font-subheader btn-lg m-2"><i class="fa fa-plus mr-2"></i>CONVERT TO GRANT</a>
{% endif %}
Comment on lines +53 to +55
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<button @click="$emit('project:edit')" class="project__action--admin btn button-white btn-block font-subheader btn-lg m-2"><i class="fa fa-pencil mr-2"></i> EDIT PROJECT</button>
{% endif %}
</div>
Expand Down
10 changes: 9 additions & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.humanize.templatetags.humanize import intword, naturaltime
from django.core.paginator import EmptyPage, Paginator
from django.db import connection
from django.db import connection, transaction
from django.db.models import Avg, Count, Max, Q, Subquery
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect
Expand Down Expand Up @@ -1656,6 +1656,7 @@ def grant_new_whitelabel(request):


@login_required
@transaction.atomic
def grant_new(request):
"""Handle new grant."""

Expand Down Expand Up @@ -1761,6 +1762,13 @@ def grant_new(request):

grant = Grant.objects.create(**grant_kwargs)

hackathon_project_id = request.GET.get('related_hackathon_project_id')
if hackathon_project_id:
hackathon_project = HackathonProject.objects.filter(id=hackathon_project_id).first()
if hackathon_project and hackathon_project.profiles.filter(pk=profile.id).exists():
hackathon_project.grant_obj = grant
hackathon_project.save()

team_members = (team_members[0].split(','))
team_members.append(profile.id)
team_members = list(set(team_members))
Expand Down