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

Feature/convert2grant #7359

Merged
merged 25 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8295862
chg create common function for project data
sanchaymittal Sep 10, 2020
7c82b96
new: add convert to grant button
sanchaymittal Sep 10, 2020
e1791c9
Add: project_link optional integerfield in grants
sanchaymittal Sep 11, 2020
9c2e793
Add project_link field to export serializer
sanchaymittal Sep 12, 2020
186462e
Add button to visit and donate to the grant converted
sanchaymittal Sep 12, 2020
a08f9d7
Chg: add grant_link field to hackathon project
sanchaymittal Sep 12, 2020
496c02d
Add grant_link in serializer & grant-tag to card
sanchaymittal Sep 12, 2020
2729ac0
Add: grants filter for projects tab for hackathon.
sanchaymittal Sep 12, 2020
60c7d2f
Add: ordering of project based on grants
sanchaymittal Sep 12, 2020
29f7ea5
Add replace winner ribbon with tag
sanchaymittal Sep 13, 2020
85d7c44
chg: project-card with winner & grant tag for tribe
sanchaymittal Sep 13, 2020
420e31c
Add: grant & winner filter in tribe
sanchaymittal Sep 13, 2020
57e3d5d
build fix
sanchaymittal Sep 13, 2020
143c4c5
chg: temp solution to update HackathonProject data
sanchaymittal Sep 13, 2020
d567c3b
chg: grant link field change from url to char.
sanchaymittal Sep 13, 2020
2998638
fix: requested changes
sanchaymittal Sep 14, 2020
8f72132
chg: winner tag with the ribbon used prior
sanchaymittal Sep 14, 2020
b1f5ba7
chg: grant_link from char to foriegn key grant
sanchaymittal Sep 21, 2020
a8a1fea
fix: requested changes
sanchaymittal Sep 29, 2020
47b6fa7
fix: squash migrations
sanchaymittal Sep 29, 2020
6db4371
fix: requested changes
sanchaymittal Sep 29, 2020
036db4d
fix: fix indent & squash migrations.
sanchaymittal Oct 1, 2020
e384bc9
fix: migration file.
sanchaymittal Oct 7, 2020
ac98c75
fix: indentation
sanchaymittal Oct 9, 2020
d9439e8
add: validation for covert to grant query
sanchaymittal Oct 12, 2020
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
2 changes: 1 addition & 1 deletion app/assets/v2/css/dashboard-vue-hackathon.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
position: absolute;
display: block;
width: 225px;
padding: 15px 0;
padding: 8px 0;
background-color: #25E899;
box-shadow: 0 5px 10px rgba(0, 0, 0, .1);
color: #000;
Expand Down
5 changes: 5 additions & 0 deletions app/assets/v2/images/grants/grants-logo-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions app/assets/v2/images/grants/grants-tag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/v2/js/grants/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const init = () => {
}
formData.append('contract_version', $('#contract_version').val());
formData.append('transaction_hash', $('#transaction_hash').val());
formData.append('project_pk', $('#project_pk').val());
if ($('#network').val()) {
formData.append('network', $('#network').val());
} else {
Expand Down
3 changes: 2 additions & 1 deletion app/assets/v2/js/vue-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ Vue.component('project-card', {
template: `<div class="card card-user shadow-sm border-0">
<div class="card card-project">
<b-form-checkbox v-if="is_staff" switch v-model="project.winner" style="padding:0;float:left;" @change="markWinner($event, project)">mark winner</b-form-checkbox>
<button v-on:click="projectModal" class="position-absolute btn btn-gc-green btn-sm m-2" id="edit-btn" v-bind:class="{ 'd-none': !edit }">edit</button>
<button v-on:click="projectModal" class="position-absolute btn btn-gc-green btn-sm m-2" style="left: 0.5rem; top: 3rem" id="edit-btn" v-bind:class="{ 'd-none': !edit }">edit</button>
<img v-if="project.grant_obj" class="position-absolute" style="left: 1rem" src="${static_url}v2/images/grants/grants-tag.svg" alt="grant_tag"/>
<img v-if="project.badge" class="position-absolute card-badge" width="50" :src="profile.badge" alt="badge" />
<div class="card-bg rounded-top">
<div v-if="project.winner" class="ribbon ribbon-top-right"><span>winner</span></div>
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class HackathonRegistrationAdmin(admin.ModelAdmin):


class HackathonProjectAdmin(admin.ModelAdmin):
list_display = ['pk', 'img', 'name', 'bounty', 'hackathon_link', 'usernames', 'status', 'sponsor']
list_display = ['pk', 'img', 'name', 'bounty', 'hackathon_link', 'grant_obj', 'usernames', 'status', 'sponsor']
raw_id_fields = ['profiles', 'bounty', 'hackathon']
search_fields = ['name', 'summary', 'status']

Expand Down
20 changes: 20 additions & 0 deletions app/dashboard/migrations/0154_hackathonproject_grant_obj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.2.4 on 2020-10-07 13:20

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('grants', '0088_auto_20200924_1536'),
('dashboard', '0153_hackathonevent_use_circle'),
]

operations = [
migrations.AddField(
model_name='hackathonproject',
name='grant_obj',
field=models.ForeignKey(blank=True, help_text='Link to grant if project is converted to grant', null=True, on_delete=django.db.models.deletion.SET_NULL, to='grants.Grant'),
),
]
8 changes: 8 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5120,6 +5120,13 @@ class HackathonProject(SuperModel):
chat_channel_id = models.CharField(max_length=255, blank=True, null=True)
winner = models.BooleanField(default=False)
extra = JSONField(default=dict, blank=True, null=True)
grant_obj = models.ForeignKey(
'grants.Grant',
null=True,
sanchaymittal marked this conversation as resolved.
Show resolved Hide resolved
blank=True,
on_delete=models.SET_NULL,
help_text=_('Link to grant if project is converted to grant')
)

class Meta:
ordering = ['-name']
Expand Down Expand Up @@ -5177,6 +5184,7 @@ def to_json(self):
'paid': paid,
'payment_date': date(submission.accepted_on, 'Y-m-d H:i') if paid else '',
'winner': self.winner,
'grant_obj': self.grant_obj,
'extra': self.extra,
'timestamp': submission.created_on.timestamp() if submission else 0
}
Expand Down
11 changes: 7 additions & 4 deletions app/dashboard/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class HackathonProjectSerializer(serializers.ModelSerializer):

class Meta:
model = HackathonProject
fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'admin_url')
fields = ('pk', 'chat_channel_id', 'status', 'badge', 'bounty', 'name', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo', 'message', 'looking_members', 'winner', 'grant_obj', 'admin_url')
depth = 1


Expand Down Expand Up @@ -252,7 +252,7 @@ def get_queryset(self):
hackathon_event = HackathonEvent.objects.last()

queryset = HackathonProject.objects.filter(hackathon=hackathon_event).exclude(
status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', order_by, 'id')
status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_obj', order_by, 'id')

if sponsor:
queryset = queryset.filter(
Expand All @@ -261,7 +261,7 @@ def get_queryset(self):
elif sponsor:
queryset = HackathonProject.objects.filter(Q(hackathon__sponsor_profiles__handle__iexact=sponsor) | Q(
bounty__bounty_owner_github_username=sponsor)).exclude(
status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', order_by, 'id')
status='invalid').prefetch_related('profiles', 'bounty').order_by('-winner', 'grant_obj', order_by, 'id')

projects = []
for project in queryset:
Expand All @@ -283,7 +283,6 @@ def get_queryset(self):
queryset = queryset.filter(
Q(profiles__keywords__icontains=skills)
)

if rating:
queryset = queryset.filter(
Q(rating__gte=rating)
Expand All @@ -293,6 +292,10 @@ def get_queryset(self):
queryset = queryset.filter(
Q(winner=True)
)
if 'grants' in filters:
queryset = queryset.filter(
Q(grant_obj__isnull=False)
)
if 'lfm' in filters:
queryset = queryset.filter(
Q(looking_members=True)
Expand Down
25 changes: 16 additions & 9 deletions app/dashboard/templates/dashboard/hackathon/project_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,25 @@
</div>
{% endif %}
<div id="hackathon-project-app" class="px-md-5" style="background-color: #FBFBFB" v-cloak>
<div class="row">
<div id="project-details" class="col-12 pr-0 ">
<div id="project-details" class="pr-0 ">
<div class="float-right mt-5 mr-5 px-5 py-3">

{% if project_obj.grant_url %}
<b-link href="{{ project_obj.grant_url }}" class="d-none d-md-block btn btn-gc-blue btn-block font-subheader btn-lg m-2"> <img class="mr-2" src="{% static 'v2/images/grants/grants-logo-2.svg' %}" alt="Triangles"> {% if is_member %} EDIT GRANT {% else %} DONATE TO GRANT {% endif %} </b-link>
{% endif %}

{% if is_member %}
<button @click="projectModal" class="d-none d-md-block btn btn-outline-gc-blue btn-lg float-right mt-5 mr-5 px-5 py-3 font-subheader"><i class="fa fa-pencil mr-2"></i> Edit project</button>
{% endif %}
<div class="row">
<div class="col-12 col-md-6 col-lg-8 px-5 px-md-0">
{% include 'project/detail/info.html' %}
</div>
{% if not project_obj.grant_url %}
<b-link href="{% url 'grants:new' %}?project_id={{project_obj.id}}" class="d-none d-md-block btn btn-gc-blue btn-block font-subheader btn-lg m-2"> <img class="mr-2" src="{% static 'v2/images/grants/grants-logo-2.svg' %}" alt="Create"> CREATE GRANT</b-link>
{% endif %}
<button @click="projectModal" class="d-none d-md-block btn btn-outline-gc-blue btn-block font-subheader btn-lg m-2"><i class="fa fa-pencil mr-2"></i> EDIT PROJECT</button>
{% endif %}
</div>
sanchaymittal marked this conversation as resolved.
Show resolved Hide resolved

<div class="px-5 px-md-0">
{% include 'project/detail/info.html' %}
</div>
</div>
</div>
</div>
{% include 'shared/bottom_notification.html' %}
{% include 'shared/analytics.html' %}
Expand Down
5 changes: 3 additions & 2 deletions app/dashboard/templates/dashboard/index-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ <h1 class="font-title font-weight-semibold">Hackathon Coming Soon!</h1>
<b-form-checkbox value="lfm" v-model="params.filters" name="lfm" switch>
Looking for Members
</b-form-checkbox>
<b-form-checkbox value="grants" v-model="params.filters" name="grants" switch>
Grants
</b-form-checkbox>
</div>
<div class="pb-4 border-bottom form-group">
<label for="project_sponsors" class="font-weight-bold">Sponsor</label>
Expand All @@ -299,8 +302,6 @@ <h1 class="font-title font-weight-semibold">Hackathon Coming Soon!</h1>
</select2>
</div>
</div>


<button class="btn blue font-caption px-0 btn-block font-weight-semibold" @click="params = {}; searchTerm = ''; searchProjects();">Reset Filters</button>
<p class="font-body mx-2 mb-2 mt-4 mx-lg-0 mt-lg-2">
<span class="font-weight-bold">[[ numProjects ]]</span> projects found
Expand Down
Loading