Skip to content

Commit

Permalink
Hackathons List Page (#6297)
Browse files Browse the repository at this point in the history
* add nav

* finish new hackthon section;move subscription section

* update hackathon card

* add tribes section

* add featured hackathon section in header

* style: center text;change margins

* style: remove gutter width;resize image

* style: add image height;remove margins from featured image

* add customisable width/height for featured logo

* style: handle smaller screens

* fix: recreate migrations

* add no-featured-hackathon section

* TODO: filtering tribes

TODO: if no hackathon is ongoing, default to tribes who participated in
the most number of hackathons.
TODO: if no hackathon going, show tribes that most recently
listed their bounties.

* style: update margins

* fix: stop changing featured bool on each save

* style: fix tribes grid and columns

add rows to help space elements out properly and fix grid sizes.

* fix: duplicate listing of same tribe

* handle showing tribes from most recent finsihed hackathon

* feat: set a default tab on hackathons list

if current hackathons exists, the tab is defaulted to current.
if there are no current hackathons, the default tab is upcoming.
otherwise, the default tab is finish.

* refactor: make variables plural

* show top four tribes if no current or upcoming hackathon exists

* fix migrations

* refactor: move repetitive code into `get_hackathon_events`

* rename get_hackathon_events to get_hackathon_event

* refactor tribes filtering

* move functions to dashboard.utils

`get_hackathon_event`, `get_tribe`, `tribe_fields`,
and `hackathons_funded`

* fix migrations

* fix: missing import

* fix: recreate migrations

* Fix styles and index errors

* Remove unused images and fix extension

* feat: add workshops

* fix: misspelled attribute

* add speaker avatar;finish workshops section

* fix: recreate migrations

needed merges and create missing migrations for commit:
c6510fd

* remove uneeded margin

* update copy

* fix: recreate migrations

* fix: padding and copy position

* fix: recreate migrations

* fix:recreate migrations

* add back prize amount and number of hackers

* fix: recreate migrations

* fix subscription sextion layout

* fix hackathon section

better adjust to changes introduced in:
#6722
#6766

* fix: card-logo larger than card-header for some images

* add back deleted curly

* fix: skip overhead of dropdown of profile instances

* adjust workshop layout

- remove `workshop-cover` class -was made an ID in error
- set a `width` for speaker avatar
- set width for workshop title instead of using a column

* remove cover_max_width from HackathonWorkshop model

* recreate migrations

* adjust layout for hackathon card prize amount and builders row

* recreate migrations

* receate migrations

* recreate migrations

* recreate migrations

* recreate migrations

* refactor: use bootstrap position-relative class

* refactor: remove commented lines

* recreate migrations

* recreate mgrations

* remove featured hackathon

* remove workshops section

* remove tribe sections and trbe util functions

* updste header background, logo and details

* remove value of prizes and number of builders from card

* recreate migrations

* use footer colour

* update subscription section

* update tab section

add a third item to the tab tuple to act as title in views.
previous version (title, count)
new version (id, title, count)

done so I do not have rework it too much. This way, the title can be variable
and can be renamed fairly simply while the the id remains constant.

* update form button padding

* add hackathon summary to model and template

* remove lines in pre_save signal pertaining to removal of featured hackathon from model

* fix display of hackathon summary

* decrease padding to keep buttons on same line

* maek hackathon summary font smaller

* set secondary buttons

* add sponsors list to hackathon card

* remove count from tabs

* adjust tablist sizing on smaller screens

* remove styles and refactor

* increase width of cards, logo sizes, and handle sizes for smaller screens

* update cards

* add showcase button

* recreate migrations

* recreate migrations

* remove unused files

* style: revert to previous style

* style: add line

* style: use `let`

* use zoek1's updates

changes from PR #7087 :

0745546#diff-704cfd344337eee34d60c4265c814b3f

* recreate migrations

Co-authored-by: Miguel Angel G <[email protected]>
  • Loading branch information
walidmujahid and zoek1 authored Aug 4, 2020
1 parent 483f70c commit 4f25869
Show file tree
Hide file tree
Showing 10 changed files with 313 additions and 113 deletions.
8 changes: 8 additions & 0 deletions app/assets/v2/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ figure:hover::before {
.video-row {
grid-template-columns: 1fr;
}

.box-cta {
margin: 0 !important;
}

.work-internet {
width: 17rem;
}
}

@media (max-width: 768px) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions app/assets/v2/js/pages/hackathon-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$(document).ready(function() {
$(document).on('click', '#tabs a', function(e) {
e.preventDefault();
let target = $(this).data('href');

$('.hackathons-list').addClass('hidden');
$('.nav-link').removeClass('active');
$('.nav-link').css('font-weight', '');
$(this).addClass('active');
$(this).css('font-weight', '700');


$('.hackathon-list').addClass('hidden');
$('.hackathon-list.' + target).removeClass('hidden');

$('html,body').animate({
scrollTop: '+=1px'
});
});
});
21 changes: 16 additions & 5 deletions app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
from adminsortable2.admin import SortableInlineAdminMixin

from .models import (
Activity, Answer, BlockedURLFilter, BlockedUser, Bounty, BountyEvent, BountyFulfillment, BountyInvites,
BountySyncRequest, CoinRedemption, CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, FundRequest,
HackathonEvent, HackathonProject, HackathonRegistration, HackathonSponsor, Interest, Investigation, LabsResearch,
ObjectView, Option, Poll, PollMedia, PortfolioItem, Profile, ProfileVerification, ProfileView, Question,
SearchHistory, Sponsor, Tip, TipPayout, TokenApproval, TribeMember, TribesSubscription, UserAction,
Activity, Answer, BlockedURLFilter, BlockedUser, Bounty, BountyEvent,
BountyFulfillment, BountyInvites, BountySyncRequest, CoinRedemption,
CoinRedemptionRequest, Coupon, Earning, FeedbackEntry, FundRequest,
HackathonEvent, HackathonProject, HackathonRegistration, HackathonSponsor,
HackathonWorkshop, Interest, Investigation, LabsResearch, ObjectView,
Option, Poll, PollMedia, PortfolioItem, Profile, ProfileVerification,
ProfileView, Question, SearchHistory, Sponsor, Tip, TipPayout,
TokenApproval, TribeMember, TribesSubscription, UserAction,
UserVerificationModel,
)

Expand Down Expand Up @@ -367,6 +370,13 @@ class HackathonSponsorAdmin(admin.ModelAdmin):
list_display = ['pk', 'hackathon', 'sponsor', 'sponsor_type']


class HackathonWorkshopAdmin(admin.ModelAdmin):
"""The admin object for the HackathonWorkshop model."""

raw_id_fields = ['speaker']
list_display = ['pk', 'start_date', 'hackathon', 'speaker', 'url']


class SponsorAdmin(admin.ModelAdmin):
"""The admin object for the Sponsor model."""

Expand Down Expand Up @@ -589,6 +599,7 @@ class ProfileVerificationAdmin(admin.ModelAdmin):
admin.site.register(Sponsor, SponsorAdmin)
admin.site.register(HackathonEvent, HackathonEventAdmin)
admin.site.register(HackathonSponsor, HackathonSponsorAdmin)
admin.site.register(HackathonWorkshop, HackathonWorkshopAdmin)
admin.site.register(HackathonRegistration, HackathonRegistrationAdmin)
admin.site.register(HackathonProject, HackathonProjectAdmin)
admin.site.register(FeedbackEntry, FeedbackAdmin)
Expand Down
45 changes: 45 additions & 0 deletions app/dashboard/migrations/0135_auto_20200728_1656.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 2.2.4 on 2020-07-28 16:56

import datetime
from django.db import migrations, models
import django.db.models.deletion
from django.utils.timezone import utc
import economy.models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0134_auto_20200728_1114'),
]

operations = [
migrations.AddField(
model_name='hackathonevent',
name='hackathon_summary',
field=models.CharField(blank=True, help_text='280 char summary that shows up on hackathon cards on the hackathon list page', max_length=280),
),
migrations.AlterField(
model_name='tribessubscription',
name='expires_on',
field=models.DateTimeField(blank=True, default=datetime.datetime(2021, 7, 28, 16, 56, 46, 271248, tzinfo=utc), null=True),
),
migrations.CreateModel(
name='HackathonWorkshop',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)),
('modified_on', models.DateTimeField(default=economy.models.get_time)),
('name', models.CharField(max_length=255)),
('start_date', models.DateTimeField()),
('cover', models.ImageField(upload_to='')),
('url', models.URLField(help_text='Blog link, calendar link, or other.')),
('visible', models.BooleanField(default=True, help_text='Can this HackathonWorkshop be seen on /hackathons ?')),
('hackathon', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='workshop_event', to='dashboard.HackathonEvent')),
('speaker', models.ForeignKey(help_text='Main speaker profile.', on_delete=django.db.models.deletion.CASCADE, related_name='workshop_speaker', to='dashboard.Profile')),
],
options={
'abstract': False,
},
),
]
24 changes: 24 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4702,10 +4702,12 @@ class HackathonEvent(SuperModel):
sponsors = models.ManyToManyField(Sponsor, through='HackathonSponsor')
sponsor_profiles = models.ManyToManyField('dashboard.Profile', blank=True, limit_choices_to={'data__type': 'Organization'})
show_results = models.BooleanField(help_text=_('Hide/Show the links to access hackathon results'), default=True)
hackathon_summary = models.CharField(max_length=280, blank=True, help_text=_('280 char summary that shows up on hackathon cards on the hackathon list page'))
description = models.TextField(default='', blank=True, help_text=_('HTML rich description.'))
quest_link = models.CharField(max_length=255, blank=True)
chat_channel_id = models.CharField(max_length=255, blank=True, null=True)
visible = models.BooleanField(help_text=_('Can this HackathonEvent be seeing on /hackathons ?'), default=True)

default_channels = ArrayField(models.CharField(max_length=255), blank=True, default=list)
objects = HackathonEventQuerySet.as_manager()
display_showcase = models.BooleanField(default=False)
Expand Down Expand Up @@ -4791,6 +4793,7 @@ def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)


# method for updating
@receiver(pre_save, sender=HackathonEvent, dispatch_uid="psave_hackathonevent")
def psave_hackathonevent(sender, instance, **kwargs):
Expand All @@ -4812,6 +4815,7 @@ def psave_hackathonevent(sender, instance, **kwargs):
)



class HackathonSponsor(SuperModel):
SPONSOR_TYPES = [
('G', 'Gold'),
Expand Down Expand Up @@ -5429,3 +5433,23 @@ class ProfileVerification(SuperModel):

def __str__(self):
return f'{self.phone_number} ({self.caller_type}) from {self.country_code} request ${self.delivery_method} code at {self.created_on}'


class HackathonWorkshop(SuperModel):
name = models.CharField(max_length=255)
start_date = models.DateTimeField()
cover = models.ImageField()
hackathon = models.ForeignKey(
'dashboard.HackathonEvent',
related_name='workshop_event',
on_delete=models.CASCADE,
blank=True, null=True
)
speaker = models.ForeignKey(
'dashboard.Profile',
related_name='workshop_speaker',
on_delete=models.CASCADE,
help_text='Main speaker profile.'
)
url = models.URLField(help_text='Blog link, calendar link, or other.')
visible = models.BooleanField(help_text=_('Can this HackathonWorkshop be seen on /hackathons ?'), default=True)
Loading

1 comment on commit 4f25869

@owocki
Copy link
Contributor

@owocki owocki commented on 4f25869 Aug 5, 2020

Choose a reason for hiding this comment

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

#7182

the hackathon page is now slow. feels like this should have gotten a round of performance-review before going live. anyone wanna refactor the pageto not hit the DB so many times or to be behind a warm cache?

Please sign in to comment.