Commit abaad686 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Add atom and rss feed for public protocols

ref #173
parent eb14c268
......@@ -6,6 +6,9 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False # do not change
SECRET_KEY = "something random" # change this
SERVER_NAME = "protokolle.example.com"
PREFERRED_URL_SCHEME = "https" # change to http for development
DEBUG = False # do not change
# mailserver (optional)
......
......@@ -248,8 +248,13 @@ class Protocol(DatabaseModel):
self.protocoltype.short_name.lower(),
self.date.strftime("%y-%m-%d"))
def get_title(self):
return "Protokoll: {}, {:%d.%m.%Y}".format(
self.protocoltype.short_name, self.date)
def get_wiki_title(self):
return "Protokoll:{}-{:%Y-%m-%d}".format(self.protocoltype.short_name, self.date)
return "Protokoll:{}-{:%Y-%m-%d}".format(
self.protocoltype.short_name, self.date)
def get_etherpad_link(self):
if self.pad_identifier is None:
......
......@@ -13,12 +13,14 @@ from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.cron import CronTrigger
from apscheduler.triggers.interval import IntervalTrigger
import atexit
import feedgen.feed
from io import StringIO, BytesIO
import os
from datetime import datetime
from datetime import datetime, time
import math
import mimetypes
import subprocess
from dateutil import tz
import config
from shared import db, date_filter, datetime_filter, date_filter_long, date_filter_short, time_filter, time_filter_short, user_manager, security_manager, current_user, check_login, login_required, group_required, class_filter, needs_date_test, todostate_name_filter, code_filter, indent_tab_filter
......@@ -1321,6 +1323,52 @@ def delete_decisioncategory(decisioncategory):
flash("Beschlusskategorie {} gelöscht.".format(name), "alert-success")
return redirect(request.args.get("next") or url_for("show_type", protocoltype_id=type_id))
def create_protocols_feed(protocoltype):
if not protocoltype.has_public_anonymous_view_right():
abort(403)
protocols = [protocol
for protocol in protocoltype.protocols
if protocol.done
]
feed = feedgen.feed.FeedGenerator()
feed.description(protocoltype.name)
feed.generator("Protokollsystem 3",
uri="https://git.fsmpi.rwth-aachen.de/protokollsystem/proto3")
feed.id(url_for("show_type", protocoltype_id=protocoltype.id, _external=True))
feed.link(href=url_for("list_protocols", protocoltype_id=protocoltype.id,
state_open=False, _external=True), rel="alternate")
feed.title(protocoltype.short_name)
for protocol in protocols:
entry = feed.add_entry()
entry.id(url_for("show_protocol",
protocol_id=protocol.id, _external=True))
entry.link(href=url_for("show_protocol", protocol_id=protocol.id,
_external=True), rel="alternate")
document = protocol.get_compiled_document(private=False)
if document is not None:
entry.link(href=url_for("download_document",
document_id=document.id, _external=True), rel="enclosure",
title="Protokoll", type="application/pdf")
entry.title(protocol.get_title())
entry.summary(",\n".join(top.name for top in protocol.get_tops()))
entry.content(protocol.content_public)
aware_date = datetime.combine(protocol.date, protocoltype.usual_time).replace(
tzinfo=tz.tzlocal())
entry.published(aware_date)
return feed
@app.route("/feed/protocols/rss/<int:protocoltype_id>")
@db_lookup(ProtocolType)
def feed_protocols_rss(protocoltype):
return Response(create_protocols_feed(protocoltype).rss_str(),
mimetype="application/rss+xml")
@app.route("/feed/protocols/atom/<int:protocoltype_id>")
@db_lookup(ProtocolType)
def feed_protocols_atom(protocoltype):
return Response(create_protocols_feed(protocoltype).atom_str(),
mimetype="application/atom+xml")
@app.route("/like/new")
@login_required
def new_like():
......
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