Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Projects
Groups
Snippets
Sign up now
Login
Sign in
Toggle navigation
Menu
Open sidebar
protokollsystem
proto3
Commits
a50a8a01
Commit
a50a8a01
authored
Jun 06, 2018
by
Robin Sonnabend
Browse files
Add (public) ical appointment calendar
parent
679538f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
a50a8a01
...
...
@@ -1809,17 +1809,9 @@ def feed_appointments_atom(protocoltype):
mimetype
=
"application/atom+xml"
)
@
app
.
route
(
"/feed/appointments/ical/<int:protocoltype_id>"
)
@
db_lookup
(
ProtocolType
)
def
feed_appointments_ical
(
protocoltype
):
if
not
protocoltype
.
has_public_anonymous_view_right
():
abort
(
403
)
protocols
=
[
protocol
for
protocol
in
protocoltype
.
protocols
if
not
protocol
.
is_done
()
]
def
make_calendar_from_protocols
(
protocols
,
summary
):
calendar
=
icalendar
.
Calendar
()
calendar
[
"summary"
]
=
protocoltype
.
short_name
calendar
[
"summary"
]
=
summary
calendar
[
"prodid"
]
=
"Protokollsystem 3"
calendar
[
"version"
]
=
"2.0"
for
protocol
in
protocols
:
...
...
@@ -1830,7 +1822,7 @@ def feed_appointments_ical(protocoltype):
event
[
"dtstamp"
]
=
to_datetime
(
start
)
event
[
"dtstart"
]
=
to_datetime
(
start
)
event
[
"dtend"
]
=
to_datetime
(
start
+
timedelta
(
hours
=
3
))
event
[
"summary"
]
=
protocoltype
.
short_name
event
[
"summary"
]
=
protocol
.
protocoltype
.
short_name
event
[
"description"
]
=
"
\n
"
.
join
(
top
.
name
for
top
in
protocol
.
get_tops
())
calendar
.
add_component
(
event
)
...
...
@@ -1842,6 +1834,34 @@ def feed_appointments_ical(protocoltype):
return
Response
(
content
.
encode
(
"utf-8"
),
mimetype
=
"text/calendar"
)
@
app
.
route
(
"/feed/appointments/ical/<int:protocoltype_id>"
)
@
db_lookup
(
ProtocolType
)
def
feed_appointments_ical
(
protocoltype
):
if
not
protocoltype
.
has_public_anonymous_view_right
():
abort
(
403
)
protocols
=
[
protocol
for
protocol
in
protocoltype
.
protocols
if
not
protocol
.
is_done
()
]
return
make_calendar_from_protocols
(
protocols
,
protocoltype
.
short_name
)
@
app
.
route
(
"/feed/appointments/ical/"
)
def
feed_all_appointments_ical
():
user
=
current_user
()
types
=
[
protocoltype
for
protocoltype
in
ProtocolType
.
query
.
all
()
if
(
protocoltype
.
has_private_view_right
(
user
)
or
protocoltype
.
has_public_view_right
(
user
)
or
protocoltype
.
is_public
)]
protocols
=
[
protocol
for
protocoltype
in
types
for
protocol
in
protocoltype
.
protocols
]
return
make_calendar_from_protocols
(
protocols
,
"Sitzungskalender"
)
@
app
.
route
(
"/like/new"
)
@
login_required
@
protect_csrf
...
...
templates/index.html
View file @
a50a8a01
...
...
@@ -11,6 +11,9 @@
{% if check_login() %}
<a
href=
"{{url_for("
new_protocol
")}}"
>
Neu
</a>
{% endif %}
<a
href=
"{{url_for("
feed_all_appointments_ical
")}}"
>
<img
src=
"{{url_for("
static
",
filename=
"images/feed-icon.svg"
)}}"
width=
"18px"
></img>
</a>
</h3>
<ul>
{% if open_protocols|length > 0 %}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment