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

feat: hackathon explorer background + sponsor is dynamic #4831

Merged
merged 5 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
112 changes: 23 additions & 89 deletions app/assets/v2/css/hackathons/explorer.css
Original file line number Diff line number Diff line change
@@ -1,117 +1,51 @@
.banner .img-holder {

.banner {
background: linear-gradient(161deg, rgba(55,27,181,1) 37%, rgba(255,51,117,1) 100%);
}

.banner img {
margin: 1em;
align-items: center;
display: flex;
transition: all .2s ease-in-out;
}

.banner .img-holder--dark {
background-color:#333;
}

.banner .img-holder--light {
background-color:#eee;
}

.banner .sponsors-gold .img-holder {
width: 113px;
height: 113px;
padding: 1em;
}

.banner .sponsors-silver .img-holder {
width: 75px;
height: 75px;
padding: 0.8em;
}

.banner .img-holder:hover {
transform: scale(1.1);
}

.ui-tooltip {
padding-top: 6px;
padding-bottom: 6px;
}

.ui-tooltip-content {
font-size: 0.75rem;
font-weight: 600;
}

.banner {
background: linear-gradient(161deg, rgba(55,27,181,1) 37%, rgba(255,51,117,1) 100%);
}

.banner .hackathon-logo {
max-width: 40rem;
}

.banner .img-holder {
width: 113px;
height: 113px;
padding: 1em;
}

.banner .hackathon-name {
font-size: 3rem;
font-size: 4rem;
letter-spacing: 12px;
line-height: 72px;
text-transform: uppercase;
}

/* Beyond Blockchain 2019 */
#beyondblockchain_2019 {
background: #121315;
}

#beyondblockchain_2019 .hackathon-name {
font-size: 4rem;
}

#beyondblockchain_2019 .sponsors-gold img,
#beyondblockchain_2019 .sponsors-silver img {
width: 12rem;
}

#beyondblockchain_2019 img.Alethio,
#beyondblockchain_2019 img.Arweave {
height: 3.5rem;
width: auto;
.banner img:hover {
transform: scale(1.1);
}

#beyondblockchain_2019 .img-holder {
width: auto;
height: auto;
padding: 0;
.banner .sponsors-gold img {
width: 11rem;
margin: 1em;
}

#beyondblockchain_2019 .sponsors-gold img {
max-height: 6rem;
.banner .sponsors-silver img {
width: 7.5rem;
margin: 0.8em;
}

#beyondblockchain_2019 .sponsors-gold {
.banner .sponsors-gold {
margin-bottom: 1rem;
}

#beyondblockchain_2019 img.Pegasys {
height: 4rem;
position: relative;
top: 1rem;
}

#beyondblockchain_2019 img.Portis {
height: 3rem;
position: relative;
top: 1.5rem;
}

#beyondblockchain_2019 img.Alethio,
#beyondblockchain_2019 img.TheGraph {
height: 4.5rem;
/* ETH Hack 2019 */
#ethhack_2019 .hackathon-name {
font-size: 3rem;
}

#beyondblockchain_2019 img.TheGraph {
position: relative;
top: -.4rem;
}
/* Beyond Blockchain 2019 */
#beyondblockchain_2019 {
background: #121315;
}
30 changes: 28 additions & 2 deletions app/dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

from .models import (
Activity, BlockedUser, Bounty, BountyFulfillment, BountyInvites, BountySyncRequest, CoinRedemption,
CoinRedemptionRequest, Coupon, FeedbackEntry, HackathonEvent, Interest, LabsResearch, Profile, RefundFeeRequest,
SearchHistory, Tip, TokenApproval, Tool, ToolVote, UserAction, UserVerificationModel,
CoinRedemptionRequest, Coupon, FeedbackEntry, HackathonEvent, HackathonSponsor, Interest, LabsResearch, Profile,
RefundFeeRequest, SearchHistory, Sponsor, Tip, TokenApproval, Tool, ToolVote, UserAction, UserVerificationModel,
)


Expand Down Expand Up @@ -243,6 +243,30 @@ def link(self, instance):
link.allow_tags = True


class HackathonSponsorAdmin(admin.ModelAdmin):
"""The admin object for the HackathonSponsor model."""

list_display = ['pk', 'hackathon', 'sponsor', 'sponsor_type']


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

list_display = ['pk', 'name', 'img']

def img(self, instance):
"""Returns a formatted HTML img node or 'n/a' if the HackathonEvent has no logo.

Returns:
str: A formatted HTML img node or 'n/a' if the HackathonEvent has no logo.
"""
logo = instance.logo_svg or instance.logo
if not logo:
return 'n/a'
img_html = format_html('<img src={} style="width: auto; max-height: 40px">', mark_safe(logo.url))
return img_html


class HackathonEventAdmin(admin.ModelAdmin):
"""The admin object for the HackathonEvent model."""

Expand Down Expand Up @@ -299,7 +323,9 @@ def link(self, instance):
admin.site.register(CoinRedemptionRequest, GeneralAdmin)
admin.site.register(Tool, ToolAdmin)
admin.site.register(ToolVote, ToolVoteAdmin)
admin.site.register(Sponsor, SponsorAdmin)
admin.site.register(HackathonEvent, HackathonEventAdmin)
admin.site.register(HackathonSponsor, HackathonSponsorAdmin)
admin.site.register(FeedbackEntry, FeedbackAdmin)
admin.site.register(LabsResearch)
admin.site.register(UserVerificationModel, VerificationAdmin)
Expand Down
66 changes: 66 additions & 0 deletions app/dashboard/migrations/0042_auto_20190719_2216.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated by Django 2.1.7 on 2019-07-19 22:16

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


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0041_auto_20190718_1222'),
]

operations = [
migrations.CreateModel(
name='HackathonSponsor',
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)),
('sponsor_type', models.CharField(choices=[('G', 'Gold'), ('S', 'Silver')], default='G', max_length=1)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Sponsor',
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(help_text='sponsor Name', max_length=255)),
('logo', models.ImageField(blank=True, help_text='sponsor logo', upload_to='')),
('logo_svg', models.FileField(blank=True, help_text='sponsor logo svg', upload_to='')),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='hackathonevent',
name='background_color',
field=models.CharField(blank=True, help_text='hexcode for the banner', max_length=255, null=True),
),
migrations.AlterField(
model_name='hackathonevent',
name='identifier',
field=models.CharField(default='', help_text='used for custom styling for the banner', max_length=255),
),
migrations.AddField(
model_name='hackathonsponsor',
name='hackathon',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='dashboard.HackathonEvent'),
),
migrations.AddField(
model_name='hackathonsponsor',
name='sponsor',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='dashboard.Sponsor'),
),
migrations.AddField(
model_name='hackathonevent',
name='sponsors',
field=models.ManyToManyField(through='dashboard.HackathonSponsor', to='dashboard.Sponsor'),
),
]
28 changes: 27 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3231,6 +3231,17 @@ def __str__(self):
return f'<BlockedUser: {self.handle}>'


class Sponsor(SuperModel):
"""Defines the Hackthon Sponsor"""

name = models.CharField(max_length=255, help_text='sponsor Name')
logo = models.ImageField(help_text='sponsor logo', blank=True)
logo_svg = models.FileField(help_text='sponsor logo svg', blank=True)

def __str__(self):
return self.name


class HackathonEvent(SuperModel):
"""Defines the HackathonEvent model."""

Expand All @@ -3240,7 +3251,9 @@ class HackathonEvent(SuperModel):
logo_svg = models.FileField(blank=True)
start_date = models.DateTimeField()
end_date = models.DateTimeField()
identifier = models.CharField(max_length=255, default='')
background_color = models.CharField(max_length=255, null=True, blank=True, help_text='hexcode for the banner')
identifier = models.CharField(max_length=255, default='', help_text='used for custom styling for the banner')
Copy link
Contributor

Choose a reason for hiding this comment

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

blank=True to make it not required?

Copy link
Member Author

Choose a reason for hiding this comment

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

default = '' would never make it blank :P

sponsors = models.ManyToManyField(Sponsor, through='HackathonSponsor')

def __str__(self):
"""String representation for HackathonEvent.
Expand All @@ -3258,6 +3271,19 @@ def save(self, *args, **kwargs):
super().save(*args, **kwargs)


class HackathonSponsor(SuperModel):
SPONSOR_TYPES = [
('G', 'Gold'),
('S', 'Silver'),
]
hackathon = models.ForeignKey('HackathonEvent', default=1, on_delete=models.CASCADE)
sponsor = models.ForeignKey('Sponsor', default=1, on_delete=models.CASCADE)
sponsor_type = models.CharField(
max_length=1,
choices=SPONSOR_TYPES,
default='G',
)

class FeedbackEntry(SuperModel):
bounty = models.ForeignKey(
'dashboard.Bounty',
Expand Down
4 changes: 3 additions & 1 deletion app/dashboard/templates/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
</div>
{% if hackathon %}
<link rel="stylesheet" href={% static "v2/css/hackathons/explorer.css" %}>
<div id="{{ hackathon.identifier }}" class="row pt-5 pb-5 text-center banner">
<div id="{{ hackathon.identifier }}" class="row pt-5 pb-5 text-center banner"
{% if hackathon.background_color %} style="background: {{ hackathon.background_color }}" {% endif %}
>
<div class="col g-font-muli">
<span class="hackathon-name d-block mt-5 text-white font-weight-semibold">{{ hackathon.name }}</span>
{% if hackathon.logo_svg %}
Expand Down
Loading