Skip to content

Commit

Permalink
feature upcoming gitcoinco#6870
Browse files Browse the repository at this point in the history
  • Loading branch information
developerfred committed Jul 17, 2020
1 parent 4d82d0c commit 6c311f3
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 2 deletions.
56 changes: 56 additions & 0 deletions app/townsquare/templates/townsquare/shared/bounty-card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<div>
<div class="townsquare_block-header accordion active my-1" data-target="hackathons">
Latest Bounties
</div>
<div id="latest-bounties" class="mb-4">
{% for bounty in latest_bounties|slice:":4" %}
<div class="box-bounties-townsquare">

<div class="bountie townsquare" id="{{}}">
<div class="avatar-container col-1 justify-content-center hide_min_viewport">
<img src="https://gitcoin.co/dynamic/avatar/aragonone" class="avatar aragonone">
</div>

<div class="card flex-row" id="{{hackathon.slug}}">
<div class="card-header">
{% firstof hackathon.logo_svg or hackathon.logo as logo %}
{% if logo %}
<img class="hackathon-card-logo" src="{{MEDIA_URL}}{{logo}}" alt="Hackathon logo" />
{% else %}
<div class="hackathon-card-logo text-center px-3 font-caption">
<a href="{% url 'hackathon_onboard' hackathon.slug %}"> {{ hackathon.title }} </a>
</div>
{% endif %}
</div>

<div class="card-body">
<h5 class="font-subheader font-weight-semibold">
<a href="{% url 'hackathon' hackathon.slug %}" class="text-black" target="_blank"
rel="noopener noreferrer">
{{ hackathon.title }}
</a>
</h5>
<div class="font-smaller-2">
<span class="tag-hackathon">Hackathon</span>
<time class="font-weight-bold"
datetime="{{ hackathon.start_date|date:'c' }}">{{ hackathon.start|date:"m/d/Y" }}</time>
<span>-</span>
<time class="font-weight-bold"
datetime="{{ hackathon.end_date|date:'c' }}">{{ hackathon.end|date:"m/d/Y" }}</time>
</div>
<div class="mt-1 hackathon-actions">
{% if hackathon.end|timesince <= "1 min" %}
<a href="{% url 'hackathon_onboard' hackathon.slug %}">
Join Hackathon >
</a>
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
<p class="text-center bg-shade-0 mb-0 pb-3">
<a href="{% url 'explorer' %}" class="font-caption py-2" style="color: var(--link-color);">{% trans "Vew more bounties" %}</a>
</p>
</div>
</div>
50 changes: 50 additions & 0 deletions app/townsquare/templates/townsquare/shared/upcoming.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<div>
<div class="townsquare_block-header my-1" data-target="upcoming_events">
Upcoming
</div>
<div id="upcoming-events" class="mb-4">
{% for hackathon in upcoming_events|slice:":5" %}
<div class="box-hackathons-townsquare">
<div class="card flex-row" id="{{hackathon.slug}}">
<div class="card-header">
{% firstof hackathon.logo_svg or hackathon.logo as logo %}
{% if logo %}
<img class="hackathon-card-logo" src="{{MEDIA_URL}}{{logo}}" alt="Hackathon logo" />
{% else %}
<div class="hackathon-card-logo text-center px-3 font-caption">
<a href="{% url 'hackathon_onboard' hackathon.slug %}"> {{ hackathon.title }} </a>
</div>
{% endif %}
</div>

<div class="card-body">
<h5 class="font-subheader font-weight-semibold">
<a href="{% url 'hackathon' hackathon.slug %}" class="text-black" target="_blank"
rel="noopener noreferrer">
{{ hackathon.title }}
</a>
</h5>
<div class="font-smaller-2">
<span class="tag-hackathon">Hackathon</span>
<time class="font-weight-bold"
datetime="{{ hackathon.start_date|date:'c' }}">{{ hackathon.start|date:"m/d/Y" }}</time>
<span>-</span>
<time class="font-weight-bold"
datetime="{{ hackathon.end_date|date:'c' }}">{{ hackathon.end|date:"m/d/Y" }}</time>
</div>
<div class="mt-1 hackathon-actions">
{% if hackathon.end|timesince <= "1 min" %}
<a href="{% url 'hackathon_onboard' hackathon.slug %}">
Join Hackathon >
</a>
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
<p class="text-center bg-shade-0 mb-0 pb-3">
<a href="{% url 'get_hackathons' %}" class="font-caption py-2" style="color: var(--link-color);">{% trans "View more events" %}</a>
</p>
</div>
</div>
37 changes: 35 additions & 2 deletions app/townsquare/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def get_sidebar_tabs(request):
# setup tabs
hours = 24
hackathon_tabs = []
upcoming_events = []
tabs = [{
'title': f"Everywhere",
'slug': 'everywhere',
Expand Down Expand Up @@ -176,6 +177,7 @@ def get_sidebar_tabs(request):
start_date = timezone.now() + timezone.timedelta(days=10)
end_date = timezone.now() - timezone.timedelta(days=7)
hackathons = HackathonEvent.objects.filter(start_date__lt=start_date, end_date__gt=end_date, visible=True)
upcomings = HackathonEvent.objects.upcoming().filter(visible=True).order_by('start_date'),
if hackathons.count():
for hackathon in hackathons:
connect = {
Expand All @@ -188,6 +190,19 @@ def get_sidebar_tabs(request):
'helper_text': f'Go to {hackathon.name} Townsquare.',
}
hackathon_tabs = [connect] + hackathon_tabs

if upcomings.count():
for events in upcomings:
connect = {
'title': hackathon.name,
'logo': hackathon.logo,
'start': hackathon.start_date,
'end': hackathon.end_date,
'slug': f'hackathon:{hackathon.pk}',
'url_slug': hackathon.slug,
'helper_text': f'Go to {hackathon.name} Townsquare.',
}
upcoming_events = [connect] + upcoming_events


# set tab
Expand All @@ -207,7 +222,24 @@ def get_sidebar_tabs(request):
if "search-" in tab:
search = tab.split('-')[1]

return tabs, tab, is_search, search, hackathon_tabs
latest_bounties = []
bounties = list(Bounty.objects.filter(
Q(idx_status='open') | Q(override_status='open'),
current_bounty=True,
network=network,
bounty_owner_github_username__iexact=profile.handle,
).order_by('-interested__created', '-web3_created'))
if bounties.count():
for bounty in bounties:
connect = {
'title': bounty.title,
'id': bounty.id,
'sponser': bounty.org_name,
# 'prize': bounty.prize,
}
latest_bounties = [connect] + latest_bounties

return tabs, tab, is_search, search, hackathon_tabs, latest_bounties

def get_offers(request):
# get offers
Expand Down Expand Up @@ -425,7 +457,8 @@ def town_square(request):
'TOKENS': request.user.profile.token_approvals.all() if request.user.is_authenticated else [],
'following_tribes': following_tribes,
'suggested_tribes': suggested_tribes,
'audience': audience
'audience': audience,
'latest_bounties': latest_bounties
}

if 'tribe:' in tab:
Expand Down

0 comments on commit 6c311f3

Please sign in to comment.