Skip to content

Commit 9d65713

Browse files
feat: toggle landing page slider (#10580)
1 parent f61d234 commit 9d65713

File tree

4 files changed

+83
-9
lines changed

4 files changed

+83
-9
lines changed

app/assets/v2/scss/jtbd.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
width: 20%;
4444
margin-left: 40%;
4545
}
46-
background-image: url(static('v2/images/home/GR13_desktopBanner_bg.png'));
4746
background-size: 100% auto;
4847
background-repeat: no-repeat;
4948
min-height: 450px;

app/marketing/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def membership_length_in_days(self, instance):
135135

136136
class ImageDropZoneAdmin(admin.ModelAdmin):
137137
ordering = ['-id']
138-
list_display = ['name', 'image']
138+
list_display = ['pk', 'name', 'image']
139139

140140

141141
admin.site.register(MarketingCallback, GeneralAdmin)

app/retail/templates/home/index2021.html

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,60 @@
128128
<div class="header">
129129
{% include 'home/nav.html' %}
130130
</div>
131+
{% if landingBanner.slides|length > 1 %}
132+
<header class="grad home-carousel">
133+
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
134+
<ol class="carousel-indicators home">
135+
{% for slide in landingBanner.slides %}
136+
{% if forloop.first %}
137+
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
138+
{% else %}
139+
<li data-target="#carouselExampleIndicators" data-slide-to="{{ forloop.counter0 }}"></li>
140+
{% endif %}
141+
{% endfor %}
142+
</ol>
143+
<div class="carousel-inner">
144+
{% for slide in landingBanner.slides %}
145+
{% if forloop.first %}
146+
<div class="carousel-item active" data-carousel-item-href="{{ slide.buttonLink }}">
147+
{% else %}
148+
<div class="carousel-item" data-carousel-item-href="{{ slide.buttonLink }}">
149+
{% endif %}
150+
<div class="grants" style="background-image: url('{{ slide.backgroundImage }}')">
151+
<div class="d-flex flex-column justify-content-around container">
152+
<h3 class="dates gc-font-heading">{{ slide.title }}</h3>
153+
<img src="{{ slide.img }}">
154+
<h5>{{ slide.subtitle }}</h5>
155+
<a class="btn btn-lg btn-outline-primary" href="{{ slide.buttonLink}} ">
156+
{{ slide.buttonCTA }}
157+
</a>
158+
</div>
159+
</div>
160+
</div>
161+
{% endfor %}
162+
</div>
163+
</div>
164+
</header>
165+
166+
167+
168+
{% else %}
131169
<header class="grad">
132-
<!-- This can be converted to a carousel if needed for grants rounds: https://github.com/gitcoinco/web/pull/10276 -->
133170
<div class="container build-slide">
134171
<div class="row pt-5">
135172
<div class="col-12 col-md-6 d-flex flex-column justify-content-around">
136-
<h1 class="mt-5">Build and Fund the Open Web Together</h1>
137-
<p class="font-bigger-4 text-grey-400 font-weight-300">Connect with the community developing digital public goods, creating financial freedom, and defining the future of the open web.</p>
173+
<h1 class="mt-5">{{ landingBanner.slides.0.title }}</h1>
174+
<p class="font-bigger-4 text-grey-400 font-weight-300">{{ landingBanner.slides.0.subtitle }}</p>
138175
</div>
139176
<div class="col-12 col-md-6 header-image">
140-
<img class="mt-5" src="{% static "v2/images/home/Flying_ppl_optimized.svg" %}">
177+
<img class="mt-5" src="{{ landingBanner.slides.0.img }}">
141178
</div>
142179
</div>
143180
</div>
144181
</header>
145182

183+
{% endif %}
184+
146185
<section class="container my-5">
147186
<div class="row py-5 my-5">
148187
<div class="col-md-6 mb-5 mb-md-0">

app/retail/views.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
from app.utils import get_profiles_from_text
3737
from cacheops import cached_view
3838
from dashboard.models import (
39-
Activity, ActivityIndex, HackathonEvent, Profile, Tip, get_my_earnings_counter_profiles, get_my_grants,
39+
Activity, HackathonEvent, Profile, Tip
4040
)
4141
from dashboard.notifications import amount_usdt_open_work, open_bounties
4242
from dashboard.tasks import grant_update_email_task
4343
from economy.models import Token
4444
from marketing.mails import mention_email, new_funding_limit_increase_request, new_token_request, wall_post_email
45-
from marketing.models import EmailInventory
46-
from perftools.models import JSONStore
45+
from marketing.models import EmailInventory, ImageDropZone
46+
from perftools.models import JSONStore, StaticJsonEnv
4747
from ratelimit.decorators import ratelimit
4848
from retail.helpers import get_ip
4949
from townsquare.tasks import increment_view_counts
@@ -94,6 +94,42 @@ def index(request):
9494
}
9595
context.update(data_results)
9696

97+
try:
98+
landingBanner = StaticJsonEnv.objects.get(key='landingBanner').data
99+
slides = landingBanner['slides']
100+
101+
for index, slide in enumerate(slides):
102+
slides[index]['img'] = ImageDropZone.objects.get(pk=slide['img']).image.url
103+
if slide['backgroundImage']:
104+
slides[index]['backgroundImage'] = ImageDropZone.objects.get(pk=slide['backgroundImage']).image.url
105+
106+
107+
if len(slides) == 0:
108+
landingBanner = {
109+
'slides': [
110+
{
111+
'img': static('v2/images/home/Flying_ppl_optimized.svg'),
112+
'title': 'Build and Fund the Open Web Together',
113+
'subtitle': 'Connect with the community developing digital public goods, creating financial freedom, and defining the future of the open web.',
114+
}
115+
]
116+
}
117+
118+
landingBanner['slides'] = slides
119+
120+
except:
121+
landingBanner = {
122+
'slides': [
123+
{
124+
'img': static('v2/images/home/Flying_ppl_optimized.svg'),
125+
'title': 'Build and Fund the Open Web Together',
126+
'subtitle': 'Connect with the community developing digital public goods, creating financial freedom, and defining the future of the open web.',
127+
}
128+
]
129+
}
130+
131+
context.update({'landingBanner': landingBanner})
132+
97133
return TemplateResponse(request, 'home/index2021.html', context)
98134

99135
def index_old(request):

0 commit comments

Comments
 (0)