Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion assets/css/ep2019-customisations.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@
font-style: italic;
}

#announcement {
background: #E88100;
/* full width minus scrollbar*/
padding: 42px;
box-shadow: 0px 0px 20px 0px rgba(255,255,255,1);
margin: auto;
max-width: 800px;
}

#background_image {
background: url("/static/img/ep2020-background-ccd.jpg");
background-size: cover;
color: white;
min-height: 90px;
padding-bottom: 4em;
}
.jumbotron { background: transparent; color: white; }
.jumbotron { background: transparent; color: white; padding: 4em 0 13em 0;}
.text-underline { text-decoration: underline; }

.page { min-height: 500px; padding-bottom: 10em; padding-top: 4em}
Expand Down
10 changes: 3 additions & 7 deletions conference/homepage.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.conf import settings
from django.template.response import TemplateResponse
from django.utils.lorem_ipsum import words, paragraphs
from django.conf import settings

from .models import News, Sponsor
from .models import Sponsor


CCD_GOOGLEMAPS_URL = "https://goo.gl/maps/X57SxAPbiJV3Fcig9"
Expand All @@ -12,10 +12,7 @@


def homepage(request):
latest_3_news = News.objects.filter(
status=News.STATUS.PUBLISHED,
conference__code=settings.CONFERENCE_CONFERENCE,
)[:3]
# Static homepage, used in ep2019. In ep2020, homepage is served by the CMS
sponsors = Sponsor.objects.filter(
sponsorincome__conference=settings.CONFERENCE_CONFERENCE
)
Expand All @@ -24,7 +21,6 @@ def homepage(request):
request,
"conference/homepage/home.html",
{
"latest_3_news": latest_3_news,
"sponsors": sponsors,
"CCD_GOOGLEMAPS_URL": CCD_GOOGLEMAPS_URL,
"CCD_OSM_URL": CCD_OSM_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from conference.accounts import get_or_create_attendee_profile_for_new_user
from conference.fares import set_early_bird_fare_dates, set_other_fares_dates

from tests.common_tools import get_default_conference
from tests.common_tools import get_default_conference, create_homepage_in_cms
from tests.factories import SponsorIncomeFactory, TalkFactory, DEFAULT_VAT_RATE, OrderFactory


Expand All @@ -39,6 +39,7 @@ class Command(BaseCommand):
@transaction.atomic
def handle(self, *args, **options):
conference = get_default_conference()
create_homepage_in_cms()

today = timezone.now().date()
ExchangeRate.objects.create(
Expand Down
8 changes: 8 additions & 0 deletions conference/templatetags/conference.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re

from django import template
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse

Expand Down Expand Up @@ -102,6 +103,13 @@ def profile_data(uid):
return dataaccess.profile_data(uid)


@register.simple_tag()
def sponsor_data():
return models.Sponsor.objects.filter(
sponsorincome__conference=settings.CONFERENCE_CONFERENCE
)


@register.filter
def attrib_(ob, attrib):
try:
Expand Down
2 changes: 1 addition & 1 deletion pycon/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ def _(x):
}
CMS_TEMPLATES = (
# ('conference/content/generic_content_page.html', 'Generic Content Page'),
# ('conference/homepage/home.html', 'Homepage'),
('conference/content/generic_content_page_with_sidebar.html',
'Generic Content Page (with sidebar)'),
('conference/homepage/home_template.html', 'Homepage'),
)
PAGE_TEMPLATES = (
('conference/content/generic_content_page_with_sidebar.html',
Expand Down
4 changes: 1 addition & 3 deletions pycon/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from conference.homepage import (
generic_content_page,
generic_content_page_with_sidebar,
homepage,
)
from conference.news import news_list
from conference.talk_voting import urlpatterns as talk_voting_urls
Expand All @@ -26,7 +25,6 @@
admin.site.index_template = 'p3/admin/index.html'

urlpatterns = [
re_path(r'^$', homepage, name='homepage'),
re_path(r'^generic-content-page/$', generic_content_page),
re_path(r'^generic-content-page/with-sidebar/$', generic_content_page_with_sidebar),
re_path(r'^user-panel/', include((user_panel_urls, 'conference'), namespace="user_panel")),
Expand All @@ -51,7 +49,7 @@
re_path(r'^login/', RedirectView.as_view(pattern_name='auth:login', permanent=False)),
re_path('', include(('django.contrib.auth.urls', 'auth'), namespace='auth')),

# production debug panel, doesn't even have a name=
# production debug panel
re_path(r'^nothing-to-see-here/', include((debugpanel_urls, 'conference'), namespace='debug_panel')),
]

Expand Down
8 changes: 6 additions & 2 deletions templates/conference/header/_homepage_jumbotron.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ <h1 class="display-3"><span class='text-secondary'>euro</span> <strong class='te
<h2>July 20-26th 2020, Dublin, Ireland</h2>
{% endcomment %}


{% comment %}
<div style='margin-top: 30em'>
{% if 0 %}
NOTE(artcz): Disabled because we will open ticket sales a bit later after launch
<p><a href='{% page_url 'tickets' %}' class='btn btn-outline-light btn-lg'>Get the tickets</a></p>
<p><a style='font-size: 1.5em; padding: .5em 2em;' href='{% page_url 'tickets' %}' class='btn btn-light btn-lg'>Buy tickets</a></p>
{% endif %}
</div>
{% endcomment %}
</div>
</div>
<div id="announcement">
{% placeholder "text" %}
</div>
31 changes: 0 additions & 31 deletions templates/conference/homepage/_news.html

This file was deleted.

2 changes: 0 additions & 2 deletions templates/conference/homepage/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

{% include "conference/homepage/_schedule_overview.html" %}

{% include "conference/homepage/_news.html" %}

{% include "conference/homepage/_venue.html" %}

{% include "conference/homepage/_sponsors.html" %}
Expand Down
18 changes: 18 additions & 0 deletions templates/conference/homepage/home_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "conference/base.html" %}

{% load conference %}

{% block body %}

{% include "conference/header/_with_jumbotron.html" %}

{% include "conference/homepage/_schedule_overview.html" %}

{% include "conference/homepage/_venue.html" with CCD_GOOGLEMAPS_URL="https://goo.gl/maps/X57SxAPbiJV3Fcig9" CCD_OSM_URL="https://www.openstreetmap.org/way/60270053" %}

{% sponsor_data as sponsors %}
{% include "conference/homepage/_sponsors.html" with sponsors=sponsors%}

{% include "conference/footer/footer.html" %}

{% endblock body %}
22 changes: 13 additions & 9 deletions tests/common_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
from datetime import date
from urllib.parse import urlparse

from cms.api import create_page
from wsgiref.simple_server import make_server

from django.conf import settings
from django.core import mail
from django.core.cache import cache
from django.utils import timezone

from assopy.models import Vat, VatFare
from conference.accounts import get_or_create_attendee_profile_for_new_user
from conference.models import AttendeeProfile, TALK_STATUS, Fare
from conference.models import TALK_STATUS, Fare
from conference.fares import pre_create_typical_fares_for_conference

from . import factories

HTTP_OK = 200
DEFAULT_VAT_RATE = "7.7" # 7.7%
DEFAULT_VAT_RATE = "23" # 23%


def template_used(response, template_name, http_status=HTTP_OK):
Expand Down Expand Up @@ -163,12 +164,6 @@ def clear_all_the_caches():
cache.clear()


def is_using_jinja2_template(response):
res = response.resolve_template(response.template_name)
assert res.backend.name == "jinja2", res.backed.name
return True


def setup_conference_with_typical_fares(start=date(2020, 7, 20), end=date(2020, 7, 26)):
conference = get_default_conference(
conference_start=start,
Expand Down Expand Up @@ -220,3 +215,12 @@ def create_talk_for_user(user, **kwargs):
def create_user():
user = factories.UserFactory(is_active=True)
return user


def create_homepage_in_cms():
homepage = create_page(
title='Homepage', template='conference/homepage/home_template.html', language='en',
reverse_id='homepage', published=True, publication_date=timezone.now())
homepage.set_as_homepage()

return homepage
79 changes: 9 additions & 70 deletions tests/test_homepage.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,26 @@
from datetime import timedelta

from django.conf import settings
from django.utils import timezone

from tests.common_tools import template_used
from tests.factories import ConferenceFactory, SponsorFactory, NewsFactory
from tests.common_tools import get_default_conference
from tests.factories import SponsorFactory
from tests.common_tools import create_homepage_in_cms


def test_get_homepage(db, client):
create_homepage_in_cms()
url = "/"
response = client.get(url)

assert response.status_code == 200
assert template_used(response, "conference/homepage/home.html")
assert template_used(response, "conference/homepage/home_template.html")
assert template_used(response, "conference/homepage/_venue.html")
assert template_used(response, "conference/homepage/_sponsors.html")
assert template_used(response, "conference/homepage/_schedule_overview.html")
assert template_used(response, "conference/header/_with_jumbotron.html")
assert b"EuroPython 2020" in response.content


def test_homepage_contains_last_3_news_for_current_conference(db, client):
get_default_conference()

first_news = NewsFactory(
title="First news",
published_date=timezone.now() - timedelta(days=4),
)
second_news = NewsFactory(
title="Second news",
published_date=timezone.now() - timedelta(days=3),
)
third_news = NewsFactory(
title="Third news",
published_date=timezone.now() - timedelta(days=2),
)
fourth_news = NewsFactory(
title="Fourth news",
published_date=timezone.now() - timedelta(days=1),
)

url = "/"
response = client.get(url)

assert first_news.title not in response.content.decode()
assert second_news.title in response.content.decode()
assert third_news.content in response.content.decode()
assert fourth_news.title in response.content.decode()


def test_homepage_doesnt_display_news_from_non_current_conference(db, client):
current_conf = get_default_conference()
other_conf = ConferenceFactory(code="other", name="other conf")

current_news = NewsFactory(
conference=current_conf,
published_date=timezone.now() - timedelta(days=2),
)
old_news = NewsFactory(
conference=other_conf,
published_date=timezone.now() - timedelta(days=365),
)

url = "/"
response = client.get(url)

assert current_news.title in response.content.decode()
assert old_news.title not in response.content.decode()


def test_homepage_news_supports_html_tags(db, client):
current_conf = get_default_conference()

current_news = NewsFactory(
conference=current_conf,
content='<b>This is a test news item</b>'
)

url = "/"
response = client.get(url)

assert current_news.content in response.content.decode()
assert '&lt;b&gt;' not in response.content.decode()


def test_homepage_doesnt_contain_sponsor_if_no_income(db, client):
create_homepage_in_cms()
sponsor = SponsorFactory(
alt_text="Sponsor Alt Text", title_text="Sponsor Title Text"
)
Expand All @@ -99,6 +35,7 @@ def test_homepage_doesnt_contain_sponsor_if_no_income(db, client):
def test_homepage_doesnt_contain_sponsor_if_income_for_different_conference(
db, client
):
create_homepage_in_cms()

sponsor = SponsorFactory(
alt_text="Sponsor Alt Text", title_text="Sponsor Title Text"
Expand All @@ -115,6 +52,7 @@ def test_homepage_doesnt_contain_sponsor_if_income_for_different_conference(
def test_homepage_contains_sponsors_if_income_for_current_conference(
db, client
):
create_homepage_in_cms()
sponsor = SponsorFactory(
alt_text="Sponsor Alt Text", title_text="Sponsor Title Text"
)
Expand All @@ -129,6 +67,7 @@ def test_homepage_contains_sponsors_if_income_for_current_conference(


def test_homepage_contains_googleanalytics(db, client):
create_homepage_in_cms()
url = "/"
response = client.get(url)
assert response.status_code == 200
Expand Down
Loading