Commit 9399cc95 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Show protocols (although right now there aren't any)

parent 22493f04
......@@ -29,7 +29,6 @@ class LdapManager:
if not self.authenticate(username, password):
return None
groups = list(map(lambda g: g.decode("utf-8"), self.groups(username)))
return User(username, groups)
def authenticate(self, username, password):
......@@ -12,7 +12,9 @@ from functools import wraps
import config
from shared import db, date_filter, datetime_filter, ldap_manager, security_manager
from utils import is_past, mail_manager, url_manager
from models.database import ProtocolType, Protocol, DefaultTOP, TOP, Document, Todo, Decision, MeetingReminder, Error
from views.forms import LoginForm
from views.tables import ProtocolsTable
app = Flask(__name__)
......@@ -65,10 +67,24 @@ app.jinja_env.globals.update(current_user=current_user)
# blueprints here
def index():
return render_template("index.html")
def list_protocols():
is_logged_in = check_login()
user = current_user()
protocols = [
protocol for protocol in Protocol.query.all()
if (not is_logged_in and protocol.protocoltype.is_public)
or (is_logged_in and (
protocol.protocoltype.public_group in user.groups
or protocol.protocoltype.private_group in user.groups))]
protocols_table = ProtocolsTable(protocols)
return render_template("protocol-list.html", protocols=protocols, protocols_table=protocols_table)
@app.route("/login", methods=["GET", "POST"])
def login():
if "auth" in session:
......@@ -27,6 +27,7 @@
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="{{url_for("index")}}">Zuhause</a></li>
<li><a href="{{url_for("list_protocols")}}">Protokolle</a></li>
{# todo: add more links #}
<ul class="nav navbar-nav navbar-right">
......@@ -3,5 +3,7 @@
{% block title %}Login{% endblock %}
{% block content %}
<div class="container">
{% endblock %}
......@@ -107,3 +107,24 @@ to not render a label for the CRSFTokenField -->
<button type="submit" class="{{ btn_class }}">{{ action_text }} </button>
{%- endmacro %}
{% macro render_table(table) -%}
<table class="table table-striped">
{% for header in table.headers() %}
{% endfor %}
{% for row in table.rows() %}
{% for entry in row %}
{% endfor %}
{% endfor %}
{%- endmacro %}
{% extends "layout.html" %}
{% from "macros.html" import render_table %}
{% block title %}Protokolle{% endblock %}
{% block content %}
<div class="container">
{% endblock %}
# coding: utf-8
from flask import Markup, url_for, request
from models.database import Protocol, ProtocolType, DefaultTOP, TOP, Todo, Decision
from shared import date_filter
class Table:
def __init__(self, title, values, newlink=None):
self.title = title
self.values = values
self.newlink = newlink
self.newtext = "New"
def rows(self):
return [row for row in [self.row(value) for value in self.values] if row is not None]
def link(target, text, confirm=None):
confirmation = ""
if confirm:
confirmation = " onclick=\"return confirm('{}');\"".format(confirm)
return Markup("<a href=\"{}\"{}>{}</a>".format(target, confirmation, text))
def mail(target):
return Markup("<a href=\"mailto:{}\">{}</a>".format(target, target))
def bool(value):
return "Yes" if value else "No"
def concat(values):
return ", ".join(values)
#if len(values) <= 1:
# return "".join(values)
# return "{} and {}".format(", ".join(values[:-1]), values[-1])
class SingleValueTable:
def __init__(self, title, value, newlink=None):
self.title = title
self.value = value
self.newlink = newlink if newlink else None
self.newtext = "Edit"
def rows(self):
return [self.row()]
class ProtocolsTable(Table):
def __init__(self, protocols):
super().__init__("Protokolle", protocols, newlink=None)
def headers(self):
return ["ID", "Sitzung", "Datum"]
def row(self, protocol):
return ["protocol_view",, str(,,
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