Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Rework frontpage (#368)
Browse files Browse the repository at this point in the history
* Point frontpage to LAN, add news to navbar, fix navbar overflow

* Add alternative LAN schedule link
  • Loading branch information
HON95 authored Aug 3, 2022
1 parent e771cb1 commit ccd41e3
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 94 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added marketing email opt-in for users on sign-up and profile pages.
- Added payment logging.
- Added optional colored borders for ticket on the ticket page.
- Added optional alternative schedule link for LANs.

### Changed

Expand All @@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Made the site domain in emails use the site framework domain, so make sure it's set properly.
- Updated default logging settings.
- Made age check fail for people over 150 years.
- Made frontpage redirect to LAN instead of showing news, and replace LAN button on navbar with news button.

### Deprecated

Expand All @@ -28,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed graceful shutdown for production mode.
- Fixed navbar overflow for medium screen sizes.

### Security

Expand Down
11 changes: 7 additions & 4 deletions apps/competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,15 @@ def translate_competitions(competitions):
def schedule(request):
lans = LAN.objects.filter(end_date__gt=datetime.now()).order_by('-start_date')

if lans.count() == 1:
next_lan = lans[0]
return redirect('schedule_details', lan_id=next_lan.id)
else:
if lans.count() != 1:
return redirect('schedule_lan_list')

lan = lans[0]
if lan.schedule_link:
return redirect(lan.schedule_link)

return redirect('schedule_details', lan_id=lan.id)


@require_safe
def schedule_lan_list(request):
Expand Down
20 changes: 20 additions & 0 deletions apps/lan/migrations/0025_lan_schedule_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2022-08-03 15:18
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('lan', '0024_auto_20220803_1317'),
]

operations = [
migrations.AddField(
model_name='lan',
name='schedule_link',
field=models.CharField(blank=True, help_text='URL to an alternative schedule page.', max_length=300, verbose_name='schedule link'),
),
]
1 change: 1 addition & 0 deletions apps/lan/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class LAN(TranslatableModel):
frontpage_media_link = models.CharField(_(u'frontpage media link'), max_length=300, help_text=_(u'URL for embedded media on front page.'), blank=True)
frontpage_media_type = models.CharField(_(u'frontpage media type'), max_length=10, choices=MEDIA_TYPES, default=MEDIA_TYPE_IMAGE, help_text=_(u'Type of the optional embedded media on front page.'))
rules_link = models.CharField(_(u'rules link'), max_length=300, help_text=_(u'URL to rules which users have to accept to buy tickets.'), blank=True)
schedule_link = models.CharField(_(u'schedule link'), max_length=300, help_text=_(u'URL to an alternative schedule page.'), blank=True)

@property
def attendees(self):
Expand Down
9 changes: 7 additions & 2 deletions apps/lan/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.utils.translation import pgettext, ugettext as _
from django.views.decorators.http import require_POST, require_safe

from apps.lan.models import Attendee, Directions, LAN, Ticket
from apps.lan.models import Attendee, Directions, LAN, Stream, Ticket


@require_safe
Expand Down Expand Up @@ -53,7 +53,12 @@ def details(request, lan):

directions = Directions.objects.filter(lan=lan)

return render(request, 'lan/details.html', {'lan': lan, 'active': active, 'directions': directions})
stream = None
streams = Stream.objects.filter(active=True).order_by('-pk')[:1]
if len(streams) > 0:
stream = streams[0]

return render(request, 'lan/details.html', {'lan': lan, 'active': active, 'directions': directions, 'stream': stream})


@require_safe
Expand Down
9 changes: 2 additions & 7 deletions apps/news/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.datetime_safe import datetime

from apps.lan.models import LAN, Stream
from apps.lan.models import LAN
from apps.news.models import Article


Expand All @@ -17,7 +17,6 @@ def main(request, page):
return redirect('archive_main')

paginator = Paginator(articles, 10) # Articles per page
streams = Stream.objects.filter(active=True).order_by('-pk')[:1]

try:
articles = paginator.page(page)
Expand All @@ -28,11 +27,7 @@ def main(request, page):
# If page is out of range (e.g. 9999), deliver last page of results.
articles = paginator.page(paginator.num_pages)

if len(streams) > 0:
return render(request, 'news/news.html', {'lans': active_lans, 'articles': articles, 'page': page, 'stream': streams[0],
'languages': settings.LANGUAGES})
else:
return render(request, 'news/news.html', {'lans': active_lans, 'articles': articles, 'page': page, 'languages': settings.LANGUAGES})
return render(request, 'news/news.html', {'lans': active_lans, 'articles': articles, 'page': page, 'languages': settings.LANGUAGES})


def single(request, article_id):
Expand Down
10 changes: 8 additions & 2 deletions locale/nb/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-03 13:17+0200\n"
"POT-Creation-Date: 2022-08-03 15:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -525,6 +525,12 @@ msgstr "regellenke"
msgid "URL to rules which users have to accept to buy tickets."
msgstr "URL til regler som brukere må akseptere for å kjøpe billetter."

msgid "schedule link"
msgstr "tidsplanslenke"

msgid "URL to an alternative schedule page."
msgstr "URL til en alternativ tidsplanslenke."

msgid "upcoming"
msgstr "kommende"

Expand Down Expand Up @@ -1655,7 +1661,7 @@ msgid "No raffles for this LAN."
msgstr "Ingen trekninger for dette LAN-et."

msgid "No schedule for this LAN."
msgstr "Ingen timetabell for dette LAN-et."
msgstr "Ingen tidsplan for dette LAN-et."

msgid "Support"
msgstr "Brukerstøtte"
Expand Down
4 changes: 2 additions & 2 deletions studlan/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic.base import RedirectView

from apps.lan import views as lan_view
from apps.lan.models import LAN
from apps.misc import views as misc_view
from apps.news import views as news_view
from apps.sponsor import views as sponsor_view

urlpatterns = [
Expand All @@ -33,7 +33,7 @@
url(r'^messages/', include('postman.urls', namespace='postman')),

# Views
url(r'^$', news_view.main, name='root', kwargs={'page': 1}),
url(r'^$', RedirectView.as_view(url='/lan', permanent=False), name='root'),
url(r'^misc/remove_alert.html$', misc_view.remove_alert),
url(r'^misc/change_language$', misc_view.change_language),
url(r'^sponsors/', sponsor_view.index, name='sponsors'),
Expand Down
4 changes: 3 additions & 1 deletion templates/lan/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ <h1 class="page-header">{{ lan }}</h1>
</div>
{% endif %}

{% if lan.media_link %}
{% if stream %}
{% include "lan/stream.html" %}
{% elif lan.media_link %}
{% include "lan/media.html" with media_type=lan.media_type media_link=lan.media_link frontpage=0 %}
{% endif %}

Expand Down
21 changes: 21 additions & 0 deletions templates/lan/stream.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% load markdown_deux_tags %}

{% if stream %}
<div class="row">
<div class="col-md-9">
<div class="stream">
{% if stream.visible_title %}
<h3 class="stream-title">{{ stream.visible_title }}</h3>
{% endif %}
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" title="Stream" src="{{ stream.link | safe }}" allowfullscreen></iframe>
</div>
{% if stream.description %}
<div class="stream-desc">
{{ stream.description | markdown }}
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}
29 changes: 17 additions & 12 deletions templates/navigation.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{% load i18n %}
{% block navigation %}
<ul id="navbar" class="nav navbar-nav">
<li class="navbar-item"><a href="{% url 'lan_home' %}">{% trans "LAN" %}</a></li>
<li class="navbar-item"><a href="{% url 'lan_tickets_home' %}">{% trans "Tickets" %}</a></li>
<li class="navbar-item"><a href="{% url 'seatings' %}">{% trans "Seating" %}</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{% trans "Esports" %}<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="{% url 'competitions' %}">{% trans "Competitions" %}</a></li>
<li><a href="{% url 'teams' %}">{% trans "Teams" %}</a></li>
<li><a href="{% url 'schedule' %}">{% trans "Schedule" %}</a></li>
</ul>
</li>
<li class="navbar-item"><a href="{% url 'sponsors' %}">{% trans "Partners" %}</a></li>
<li class="navbar-item"><a href="{% url 'news_main' %}">{% trans "News" %}</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{% trans "LAN" %}<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="navbar-item"><a href="{% url 'lan_tickets_home' %}">{% trans "Tickets" %}</a></li>
<li class="navbar-item"><a href="{% url 'seatings' %}">{% trans "Seating" %}</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{% trans "Esports" %}<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="{% url 'competitions' %}">{% trans "Competitions" %}</a></li>
<li><a href="{% url 'teams' %}">{% trans "Teams" %}</a></li>
<li><a href="{% url 'schedule' %}">{% trans "Schedule" %}</a></li>
</ul>
</li>
<li class="navbar-item"><a href="{% url 'sponsors' %}">{% trans "Partners" %}</a></li>
</ul>
{% endblock navigation %}
5 changes: 2 additions & 3 deletions templates/news/archive.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "base.html" %}

{% load i18n %}
{% load markdown_deux_tags %}
{% load markdown_deux_tags %}

{% block title %}
{% trans "News Archive" %}
Expand All @@ -12,9 +12,8 @@
<div class="row">
<div class="col-md-9">
<h1 class="page-header">{% trans "News Archive" %}</h1>

{% for article in articles.object_list %}
{% if not forloop.first %}
{% if not forloop.first %}
<hr />
{% endif %}
{% include "news/article_card.html" %}
Expand Down
6 changes: 2 additions & 4 deletions templates/news/article_tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
{% load markdown_deux_tags %}

<div class="article-tags">
{% if article.pinned %}
<span class="label label-default">{% trans "Pinned" %}</span>
{% endif %}
{% if article.pub_date and not hide_pub_date %}
<span class="label label-info">{{ article.pub_date|date:"d/m/Y" }} {{article.pub_date|time:"H:i"}}</span>
{% endif %}
{% if lans and lans|length > 1 %}
{% for lan in article.relevant_to.all %}
<span class="label label-primary"><a href="{{ lan.get_absolute_url }}">{{ lan }}</a></span>
{% endfor %}
{% if article.pinned %}
<span class="label label-default">{% trans "Pinned" %}</span>
{% endif %}
</div>
95 changes: 95 additions & 0 deletions templates/news/frontpage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{% extends "base.html" %}

{% load i18n %}
{% load markdown_deux_tags %}

{% block title %}
{% trans "Home" %}
{% endblock title %}

{% block content %}
{% if stream %}
<div class="row">
<div class="col-md-9">
<div class="stream">
{% if stream.visible_title %}
<h3 class="stream-title">{{ stream.visible_title }}</h3>
{% endif %}
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" title="Stream" src="{{ stream.link | safe }}" allowfullscreen></iframe>
</div>
{% if stream.description %}
<div class="stream-desc">
{{ stream.description | markdown }}
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}

<div class="row">
<div class="col-md-9">
{% if lans.count == 1 %}
<h1 class="page-header"><a href="{{ lans.0.get_absolute_url }}">{{ lans.0 }}</a></h1>
{% else %}
<h1 class="page-header">{% trans "LANs" %}</h1>
{% endif %}
</div>
</div>

{% if lans.count == 1 %}
{% if lans.0.frontpage_media_link %}
{% with lan=lans.0 %}
{% include "lan/media.html" with media_type=lan.frontpage_media_type media_link=lan.frontpage_media_link frontpage=1 %}
{% endwith %}
{% endif %}

<div class="row">
<div class="col-md-6 col-xs-7">
<p class="lead">{{ lans.0.start_date|date }} – {{ lans.0.end_date|date }}</p>
</div>
<div class="col-md-3 col-xs-5">
<a class="btn btn-primary pull-right" href="{{ lans.0.get_absolute_url }}">{% trans "Show LAN" %}</a>
</div>
</div>
{% else %}
<div class="row">
<div class="col-md-9">
<table class="table table-bordered table-hover click-table">
<tbody>
{% for lan in lans %}
<tr onclick="document.location='{{ lan.get_absolute_url }}';">
<td class="col-md-6 underline">{{ lan }}</td>
<td class="col-md-3">{{ lan.start_date|date }} – {{ lan.end_date|date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}

<div class="row">
<div class="col-md-9">
{% for article in articles.object_list %}
<hr />
{% include "news/article_card.html" %}
{% empty %}
<div class="alert alert-info">{% trans "No news." %}</div>
{% endfor %}
</div>
</div>

<div class="row news-pagination-container">
<div class="col-md-6">
{% include "news/pagination.html" with news_area='news' %}
</div>
<div class="col-md-3">
<a class="btn btn-primary pull-right" href="{% url 'archive_main' %}">
<span class="glyphicon glyphicon-folder-close" aria-hidden="true"></span>
{% trans "News archive" %}
</a>
</div>
</div>
{% endblock content %}
Loading

0 comments on commit ccd41e3

Please sign in to comment.