Commit 821267c0 authored by berumuron's avatar berumuron
Browse files

add: #2 Hide future events by default

parent 688a560b
from datetime import datetime
from flask import Blueprint, request, redirect, url_for, flash, render_template, g
from .auth import login_required
......@@ -14,7 +16,9 @@ def index():
else:
events = Event.items()
return render_template("events/index.html", events=events)
return render_template(
"events/index.html", events=events, current_date=datetime.now()
)
@bp.route("/create", methods=("GET", "POST"))
......
......@@ -58,3 +58,26 @@ p:last-child {
margin-left: auto;
margin-right: auto;
}
/* Folder system */
.folder.folder-folded .folder-container {
display: none;
}
.folder .folder-toggle {
padding: 0;
font: inherit;
background: none;
border: none;
}
.folder .folder-toggle::after {
margin-left: .25rem;
content: "▿";
}
.folder.folder-folded .folder-toggle::after {
content: "▹";
}
(function () {
var folders = document.querySelectorAll('.folder');
folders.forEach(function (folder) {
var folderToggle = folder.querySelector('.folder-toggle');
folderToggle.onclick = function () {
folder.classList.toggle('folder-folded');
};
});
}());
......@@ -11,25 +11,39 @@
{% endif %}
{% for group_by_year in events|groupby('date.year')|sort(reverse=True) %}
<h2>{{ group_by_year.grouper }}</h2>
{% set year = group_by_year.grouper %}
<div class="events-by-year folder {{ 'folder-folded' if year > current_date.year }}">
<h2>
<button class="folder-toggle">
{{ year }}
</button>
</h2>
{% for group_by_month in group_by_year.list|groupby('date.month')|sort(reverse=True) %}
<div>
<h3>{{ group_by_month.grouper|to_month }}</h3>
<div class="folder-container">
{% for group_by_month in group_by_year.list|groupby('date.month')|sort(reverse=True) %}
{% set month = group_by_month.grouper %}
<div class="events-by-month folder {{ 'folder-folded' if year == current_date.year and month > current_date.month }}">
<h3>
<button class="folder-toggle">
{{ month|to_month }}
</button>
</h3>
<ul>
{% for event in group_by_month.list|sort(attribute='date', reverse=True) %}
<li>
{% if event.is_private %}
<span>🔒</span>
{% endif %}
<ul class="events folder-container">
{% for event in group_by_month.list|sort(attribute='date', reverse=True) %}
<li class="event">
{% if event.is_private %}
<span>🔒</span>
{% endif %}
{{ event.date.strftime('%d %b') }}&nbsp;: {{ event.title }}
</li>
{% endfor %}
</ul>
{{ event.date.strftime('%d %b') }}&nbsp;: {{ event.title }}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endblock %}
......@@ -29,5 +29,7 @@
<main class="app-page">
{% block content %}{% endblock %}
</main>
<script type="text/javascript" src="{{ url_for('static', filename='app.js') }}"></script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment