Skip to content

Commit

Permalink
Projects Panel
Browse files Browse the repository at this point in the history
- all filters now working
- response data is correct, project cards fully functional
Hackathon Dashboard js
 - updated the sidebar bindings so they are working in the new layout
- general clean up
  • Loading branch information
androolloyd committed Apr 10, 2020
1 parent d0003bc commit 0b77f73
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
20 changes: 6 additions & 14 deletions app/assets/v2/js/pages/dashboard-hackathon.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@
}
_filters.forEach(filter => {
if (getParam(filter)) {
if (filter !== undefined && filter !== 'undefined') {
localStorage[filter] = getParam(filter).replace(/^,|,\s*$/g, '');
} else {
delete localStorage[filter];
}
localStorage[filter] = getParam(filter).replace(/^,|,\s*$/g, '');
}
});
};
Expand All @@ -131,10 +127,7 @@
}

_filters.forEach((filter) => {

if (localStorage[filter] === undefined || localStorage[filter] === 'undefined') {
delete localStorage[filter];
} else if (localStorage[filter] && localStorage[filter] !== 'any') {
if (localStorage[filter] && localStorage[filter] !== 'any') {
uri += (filter + '=' + localStorage[filter] + '&');
}
});
Expand Down Expand Up @@ -453,7 +446,7 @@

$('.loading_img').remove();
$('#bounties').append(loading_html);
$('.loading_img').css('display', 'block');
$('.loading_img').css('display', 'flex');

document.offset = parseInt(document.offset) + parseInt(results_limit);
refreshBounties(null, document.offset, true);
Expand Down Expand Up @@ -524,7 +517,7 @@

if (!append) {
$('.nonefound').css('display', 'none');
$('.loading').css('display', 'block');
$('.loading').css('display', 'flex');
$('.bounty_row').remove();
}

Expand Down Expand Up @@ -787,9 +780,8 @@
});

$(`
.sidebar_search input[type=radio], .sidebar_search input[type=checkbox],
.sidebar_search .js-select2, #org
`).on('change', function(e) {
#sidebar_container input[type=radio], #sidebar_container input[type=checkbox],
#sidebar_container .js-select2, #orgs`).on('change', function(e) {
reset_offset();
refreshBounties(null, 0, false);
e.preventDefault();
Expand Down
6 changes: 5 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4616,7 +4616,6 @@ class HackathonSponsor(SuperModel):
)
chat_channel_id = models.CharField(max_length=255, blank=True, null=True)


class HackathonProject(SuperModel):
PROJECT_STATUS = [
('invalid', 'invalid'),
Expand Down Expand Up @@ -4677,7 +4676,12 @@ def get_absolute_url(self):

from rest_framework import serializers

from .router import BountySerializer

class HackathonProjectSerializer(serializers.ModelSerializer):
bounty = BountySerializer()
profiles = ProfileSerializer(many=True)

class Meta:
model = HackathonProject
fields = ('chat_channel_id', 'status', 'badge', 'bounty', 'summary', 'work_url', 'profiles', 'hackathon', 'summary', 'logo')
Expand Down
25 changes: 11 additions & 14 deletions app/dashboard/templates/dashboard/index-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
</div>
{% endif %}

<div id="dashboard-content" class="container-fluid no-gutter" style="">
<div id="dashboard-content" class="container-fluid no-gutter" style="min-height:600px;">
<div id="dashboard-vue-app" class="row" v-cloak>
<div :id="hackathonObj.identifier" class="d-flex col-12 justify-content-between flex-column flex-md-row align-items-center p-3 banner hackathon-banner">
<div class="offset-lg-2 col-lg-10 col-12 hackathon-text pl-4">
Expand Down Expand Up @@ -418,7 +418,7 @@ <h3>{% trans "No results found." %}</h3>
<b-tab class="col-12" title-item-class="navigation" lazy>
<template v-slot:title>
<div class="mt-4">
Projects
{% trans "Projects" %}
<span class="nav-badge d-none">[[ hackathonProjects.length ]]</span>
</div>
</template>
Expand All @@ -441,7 +441,7 @@ <h3>{% trans "No results found." %}</h3>
<div class="pb-4 border-bottom form-group">
<label for="project_sponsors" class="font-weight-bold">Sponsor</label>
<div id="project_sponsors" class="form__select2">
<select2 v-model.trim="params.sponsors" data-minimum-results-for-search="Infinity" class="form-control">
<select2 v-model.trim="params.sponsor" data-minimum-results-for-search="Infinity" class="form-control">
<option value="" selected="true">All</option>
<option v-for="option in hackathonSponsors" v-bind:value="option.org_name">
[[ option.display_name ]]
Expand All @@ -450,7 +450,7 @@ <h3>{% trans "No results found." %}</h3>
</div>
</div>
<div class="g-multiselect pb-4 border-bottom form-group">
<label for="skills" class="font-weight-bold">Skills</label>
<label for="skills" class="font-weight-bold">Member Skills</label>
<div class="form__select2">
<select2 :options="skills" v-model="params.skills" data-placeholder="e.g. HTML, CSS" data-tags="true" multiple class="form-control">
<option disabled value="0">Select one</option>
Expand All @@ -476,12 +476,9 @@ <h3>{% trans "No results found." %}</h3>
<div class="card card-project">
<img v-if="project.badge" class="position-absolute card-badge" width="50" :src="profile.badge" alt="badge" />

<button v-if="project" onclick="@projectModal(project.bounty, project.pk)" class="position-absolute btn btn-gc-green btn-sm m-2">edit</button>


<div class="card-bg rounded-top" style="">
<!--<img v-if="project.logo" class="card-project-logo m-auto rounded shadow" height="87" width="87" :src="project.logo" alt="Hackathon logo" />-->
<!--<img v-else class="card-project-logo m-auto rounded shadow" height="87" width="87" :src="project.bounty.logo" alt="Bounty Logo" />-->
<img v-if="project.logo" class="card-project-logo m-auto rounded shadow" height="87" width="87" :src="project.logo" alt="Hackathon logo" />
<img v-else class="card-project-logo m-auto rounded shadow" height="87" width="87" :src="project.bounty.avatar_url" alt="Bounty Logo" />
</div>
<div class="card-body">
<h5 class="card-title font-weight-bold text-left">[[ project.name ]]</h5>
Expand All @@ -491,15 +488,15 @@ <h5 class="card-title font-weight-bold text-left">[[ project.name ]]</h5>
</p>
<div class="text-left">
<a :href="project.work_url" target="_blank" class="btn btn-sm btn-gc-blue font-smaller-2 font-weight-semibold">View Project</a>
<a :href="project.work_url" class="btn btn-sm btn-outline-gc-blue font-smaller-2 font-weight-semibold">View Bounty</a>
<a :href="project.bounty.url" class="btn btn-sm btn-outline-gc-blue font-smaller-2 font-weight-semibold">View Bounty</a>
</div>
</div>

<div class="my-3 mb-2 text-left">
<b class="font-weight-bold font-smaller-3">Team Members</b>
<div class="mt-1">
<a v-for="profile in project.profiles" href="{% url 'profile' profile %}" class="">
<!--<img :src="`${profile.avatar_url}`" :alt="`@${profile}`" :title="`@${profile}`" width="30" height="30" class="rounded-circle">-->
<a v-for="profile in project.profiles" :href=`/profile/${profile.handle}` class="">
<b-img-lazy :src="profile.avatar_url" :alt=`"@${profile.handle}"` :title="profile.handle" width="30" height="30" class="rounded-circle"></b-img-lazy>
</a>
</div>
</div>
Expand All @@ -513,8 +510,8 @@ <h5 class="info-card-title uppercase">Looking for team members</h5>

<div class="font-smaller-2 mt-4">
<b class="font-weight-bold">Sponsored by</b>
<!--<img class="" width="20" :src="project.bounty.avatar_url" :alt="project.bounty.org_name" />-->
<!--<a href="">[[ project.bounty.org_name ]]</a>-->
<img class="" width="20" :src="project.bounty.avatar_url" :alt="project.bounty.org_name" />
<a href="">[[ project.bounty.org_name ]]</a>
</div>
</div>
</div>
Expand Down
28 changes: 14 additions & 14 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,7 @@ def projects_fetch(request):
except HackathonEvent.DoesNotExist:
hackathon_event = HackathonEvent.objects.last()

projects = HackathonProject.objects.filter(hackathon=hackathon_event).exclude(status='invalid').prefetch_related(
'profiles').order_by(order_by).select_related('bounty')
projects = HackathonProject.objects.filter(hackathon=hackathon_event).exclude(status='invalid').prefetch_related('profiles', 'bounty').order_by(order_by)

if q:
projects = projects.filter(
Expand All @@ -957,11 +956,15 @@ def projects_fetch(request):
)

if sponsor:
projects_sponsor = []
for project in projects:
if sponsor == project.bounty.org_name:
projects_sponsor.append(project)
projects = projects_sponsor
print(sponsor)
projects = projects.filter(
Q(bounty__github_url__icontains=sponsor)
)

if skills:
projects = projects.filter(
Q(profiles__keywords__icontains=skills)
)

if filters == 'winners':
projects = projects.filter(
Expand All @@ -977,18 +980,15 @@ def projects_fetch(request):
except EmptyPage:
projects_paginated = projects_paginator.page(projects_paginator.num_pages)

# projects_data = HackathonProjectSerializer(projects)
# print(projects_data)

# from rest_framework.renderers import JSONRenderer

projects_data = HackathonProjectSerializer(projects.all(), many=True)

params = {
'data': list(projects.values())
'data': projects_data.data
}
params['has_next'] = projects_paginator.page(page).has_next()
params['count'] = projects_paginator.count
params['num_pages'] = projects_paginator.num_pages

return JsonResponse(params, status=200, safe=False)

@require_GET
Expand Down Expand Up @@ -3739,7 +3739,7 @@ class Meta:
from rest_framework.renderers import JSONRenderer
from django.core.serializers.json import DjangoJSONEncoder
hackathon_json = JSONRenderer().render(HackathonEventSerializer(hackathon_event).data)
print(hackathon_json)

params = {
'active': 'dashboard',
'type': 'hackathon',
Expand Down

0 comments on commit 0b77f73

Please sign in to comment.