Commit 547ab2c5 authored by Julian Rother's avatar Julian Rother
Browse files

Implemented public service announcements

parent d8ec3c15
......@@ -183,6 +183,18 @@ CREATE TABLE IF NOT EXISTS `videos_data` (
`video_format` INTEGER NOT NULL,
`hash` varchar(32) NOT NULL
);
CREATE TABLE IF NOT EXISTS `announcements` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`text` text NOT NULL,
`internal` text NOT NULL,
`level` INTEGER NOT NULL DEFAULT 0,
`visible` INTEGER NOT NULL DEFAULT 0,
`deleted` INTEGER NOT NULL DEFAULT 0,
`time_created` datetime NOT NULL,
`time_updated` datetime NOT NULL,
`created_by` INTEGER NOT NULL
);
CREATE VIEW IF NOT EXISTS `courses` AS select * from `courses_data` where (not(`courses_data`.`deleted`));
CREATE VIEW IF NOT EXISTS `lectures` AS select * from `lectures_data` where (not(`lectures_data`.`deleted`));
CREATE VIEW IF NOT EXISTS `videos` AS select * from `videos_data` where (not(`videos_data`.`deleted`));
......
......@@ -115,6 +115,10 @@ def human_date(d):
def rfc3339(d):
return d.strftime('%Y-%m-%dT%H:%M:%S+02:00')
@app.template_global()
def get_announcements(minlevel=0):
return query('SELECT * FROM announcements WHERE NOT deleted AND (? OR visible) AND level >= ? ORDER BY level DESC', ismod(), minlevel)
@app.route('/')
@register_navbar('Home', icon='home')
def index():
......
{% set page_border = page_border|default(1) -%}
{% set page_border = page_border|default(1) %}
{% set min_announcement_level = min_announcement_level|default(1) %}
{% set announcement_levels = {0: 'info', 1: 'info', 2: 'warning', 3: 'danger'} %}
<!DOCTYPE html>
<html>
......@@ -102,6 +104,9 @@
{% for msg in get_flashed_messages() %}
<div class="alert alert-danger" role="alert">{{ msg }}</div>
{% endfor %}
{% for msg in get_announcements(min_announcement_level) %}
<div class="alert alert-{{announcement_levels.get(msg.level, 'info')}}" role="alert">{{ msg.text|safe }}</div>
{% endfor %}
{% block content %}
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
......
{% from 'macros.html' import preview %}
{% extends "base.html" %}
{% set page_border = 0 %}
{% set min_announcement_level = 0 %}
{% block content %}
<div class="row">
<div class="col-md-6 panel-group">
......
Supports Markdown
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