- {% for event in events %}
-
+ {% group_by_field events types 'type' as events_grouped_by_type %}
+ {% for events_by_type in events_grouped_by_type %}
-
+
+ {% if events_by_type.list|length %}
+ {% for events_in_column in events_by_type.list|group_in_columns:3 %}
+
+ {% include 'shared/footer.html' %}
+ {% include 'shared/footer_scripts.html' with slim=1 %}
+
+ {% block 'scripts' %}
+
+
+
+
+
+
+ {% endblock %}
diff --git a/app/dashboard/templatetags/group_by_field.py b/app/dashboard/templatetags/group_by_field.py
new file mode 100644
index 00000000000..fe68c981476
--- /dev/null
+++ b/app/dashboard/templatetags/group_by_field.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+"""Define the add_url_schema template tag to allow cleaning up url in templates.
+
+Copyright (C) 2021 Gitcoin Core
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+
+"""
+from django import template
+
+register = template.Library()
+
+@register.simple_tag
+def group_by_field(list_input, fields, field):
+ """Groups list_input into columns by pivotting on the given field (for each of the given fields)"""
+ output = []
+ for fields_val in fields:
+ # collect columns details into a dict ({field:fields_val, 'list':[...]})
+ group = {}
+ # eg group.type = "current"
+ group[field] = fields_val
+ # collate the list by pivotting only the matching elements
+ group['list'] = [ele for ele in list_input if ele[field] == fields_val]
+ # appending each dict to the output
+ output.append(group)
+
+ return output
diff --git a/app/dashboard/templatetags/group_in_columns.py b/app/dashboard/templatetags/group_in_columns.py
new file mode 100644
index 00000000000..f2c27036f2c
--- /dev/null
+++ b/app/dashboard/templatetags/group_in_columns.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+"""Define the add_url_schema template tag to allow cleaning up url in templates.
+
+Copyright (C) 2021 Gitcoin Core
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+
+"""
+import itertools
+
+from django import template
+
+register = template.Library()
+
+@register.filter
+def group_in_columns(list_input, number_of_columns):
+ """Groups list_input into columns based on the number_of_columns required (to be used in a loop)"""
+ columns = int(number_of_columns)
+ items = iter(list_input)
+ while True:
+ column = list(itertools.islice(items, columns))
+ if column:
+ yield column
+ else:
+ break
diff --git a/app/dashboard/views.py b/app/dashboard/views.py
index deec8404d41..3c81f6e88e8 100644
--- a/app/dashboard/views.py
+++ b/app/dashboard/views.py
@@ -24,6 +24,7 @@
import html
import json
import logging
+import random
import re
import time
import uuid
@@ -5415,29 +5416,53 @@ def hackathon_registration(request):
def get_hackathons(request):
"""Handle rendering all Hackathons."""
- if settings.DEBUG:
- from perftools.management.commands import create_page_cache
+ sponsors = []
+ events = get_hackathon_events()
- create_page_cache.create_hackathon_list_page_cache()
+ num_current = 0
+ num_upcoming = 0
+ num_finished = 0
+
+ # count the number of each event type
+ for ele in events:
+ if ele['type'] == 'current':
+ num_current += 1
+ elif ele['type'] == 'upcoming':
+ num_upcoming += 1
+ elif ele['type'] == 'finished':
+ num_finished += 1
+
+ # curate the sponsors list
+ if ele.get('sponsor_profiles'):
+ sponsors.extend(ele.get('sponsor_profiles'))
- events = get_hackathon_events()
- num_current = len([ele for ele in events if ele['type'] == 'current'])
- num_upcoming = len([ele for ele in events if ele['type'] == 'upcoming'])
- num_finished = len([ele for ele in events if ele['type'] == 'finished'])
tabs = [
('current', 'happening now', num_current),
('upcoming', 'upcoming', num_upcoming),
('finished', 'completed', num_finished),
]
+ # shuffle the sponsors
+ random.shuffle(sponsors)
+
params = {
'active': 'hackathons',
'title': 'Hackathons',
- 'avatar_url': request.build_absolute_uri(static('v2/images/twitter_cards/tw_cards-02.png')),
+ 'avatar_url': request.build_absolute_uri(static('v2/images/twitter_cards/tw_hackathon-list.png')),
'card_desc': "Gitcoin runs Virtual Hackathons. Learn, earn, and connect with the best hackers in the space -- only on Gitcoin.",
'tabs': tabs,
+ 'types': ['current', 'upcoming', 'finished'],
'events': events,
+ 'sponsors': sponsors[:33],
'default_tab': get_hackathons_page_default_tabs(),
+ 'testimonial': {
+ 'handle': '@cryptomental',
+ 'comment': "I think the great thing about Gitcoin is how easy it is for projects to reach out to worldwide talent. Gitcoin helps to find people who have time to contribute and increase speed of project development. Thanks to Gitcoin a bunch of interesting OpenSource projects got my attention!",
+ 'avatar_url': '',
+ 'github_handle': 'cryptomental',
+ 'twitter_handle': '',
+ 'role': 'Front End Developer'
+ }
}
return TemplateResponse(request, 'dashboard/hackathon/hackathons.html', params)
diff --git a/app/retail/templates/about.html b/app/retail/templates/about.html
index 15a1c59d883..bf7af5b511c 100644
--- a/app/retail/templates/about.html
+++ b/app/retail/templates/about.html
@@ -290,112 +290,12 @@
Get the latest from Gitcoin
{% include 'shared/footer.html' %}
{% include 'shared/footer_scripts.html' with slim=1 %}
-
+
+
diff --git a/app/retail/templates/gas_history.html b/app/retail/templates/gas_history.html
index f17d1249f6e..b4091f76672 100644
--- a/app/retail/templates/gas_history.html
+++ b/app/retail/templates/gas_history.html
@@ -46,12 +46,12 @@
{% trans "Gas History" %} ({{breakdown}}) {% trans "Alpha"
{% endif %}
-
+
- {% for id, title in tabs %}
+ {% for id, title, num in tabs %}