Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
protokollsystem
proto3
Commits
d6a68cab
Commit
d6a68cab
authored
Apr 28, 2017
by
Robin Sonnabend
Browse files
Show HTML-version of the protocol directly
ref
#94
parent
146d429b
Changes
7
Hide whitespace changes
Inline
Side-by-side
migrations/versions/0686095ee9dd_.py
0 → 100644
View file @
d6a68cab
"""empty message
Revision ID: 0686095ee9dd
Revises: 60a730d37c9a
Create Date: 2017-04-28 22:24:35.628585
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'0686095ee9dd'
down_revision
=
'60a730d37c9a'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
add_column
(
'protocols'
,
sa
.
Column
(
'content_html_private'
,
sa
.
String
(),
nullable
=
True
))
op
.
add_column
(
'protocols'
,
sa
.
Column
(
'content_html_public'
,
sa
.
String
(),
nullable
=
True
))
# ### end Alembic commands ###
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
op
.
drop_column
(
'protocols'
,
'content_html_public'
)
op
.
drop_column
(
'protocols'
,
'content_html_private'
)
# ### end Alembic commands ###
models/database.py
View file @
d6a68cab
...
...
@@ -143,6 +143,8 @@ class Protocol(DatabaseModel):
source
=
db
.
Column
(
db
.
String
)
content_public
=
db
.
Column
(
db
.
String
)
content_private
=
db
.
Column
(
db
.
String
)
content_html_public
=
db
.
Column
(
db
.
String
)
content_html_private
=
db
.
Column
(
db
.
String
)
date
=
db
.
Column
(
db
.
Date
)
start_time
=
db
.
Column
(
db
.
Time
)
end_time
=
db
.
Column
(
db
.
Time
)
...
...
@@ -568,7 +570,7 @@ class Todo(DatabaseModel):
return
self
.
get_first_protocol
()
==
current_protocol
return
len
(
self
.
protocols
)
==
1
def
render_html
(
self
):
def
render_html
(
self
,
current_protocol
=
None
):
parts
=
[
self
.
get_state
(),
"<strong>{}:</strong>"
.
format
(
self
.
who
),
...
...
parser.py
View file @
d6a68cab
...
...
@@ -429,14 +429,25 @@ class Fork(Element):
else
:
return
content_lines
elif
render_type
==
RenderType
.
html
:
title_line
=
"<h{depth}>{content}</h{depth}>"
.
format
(
depth
=
level
+
1
,
content
=
name_line
)
content_parts
=
[]
for
child
in
self
.
children
:
part
=
child
.
render
(
render_type
,
show_private
,
level
=
level
+
1
,
protocol
=
protocol
)
if
len
(
part
.
strip
())
==
0
:
continue
content_parts
.
append
(
"<p>{}</p>"
.
format
(
part
))
content_lines
=
"{}
\n\n
{}"
.
format
(
title_line
,
"
\n
"
.
join
(
content_parts
))
depth
=
level
+
1
+
getattr
(
config
,
"HTML_LEVEL_OFFSET"
,
0
)
content_lines
=
""
if
depth
<
5
:
title_line
=
"<h{depth}>{content}</h{depth}>"
.
format
(
depth
=
depth
,
content
=
name_line
)
content_parts
=
[]
for
child
in
self
.
children
:
part
=
child
.
render
(
render_type
,
show_private
,
level
=
level
+
1
,
protocol
=
protocol
)
if
len
(
part
.
strip
())
==
0
:
continue
content_parts
.
append
(
"<p>{}</p>"
.
format
(
part
))
content_lines
=
"{}
\n\n
{}"
.
format
(
title_line
,
"
\n
"
.
join
(
content_parts
))
else
:
content_parts
=
[]
for
child
in
self
.
children
:
part
=
child
.
render
(
render_type
,
show_private
,
level
=
level
+
1
,
protocol
=
protocol
)
if
len
(
part
.
strip
())
==
0
:
continue
content_parts
.
append
(
"<li>{}</li>"
.
format
(
part
))
content_lines
=
"{}
\n
<ul>
\n
{}
\n
</ul>"
.
format
(
name_line
,
"
\n
"
.
join
(
content_parts
))
if
self
.
test_private
(
self
.
name
)
and
not
show_private
:
return
""
else
:
...
...
server.py
View file @
d6a68cab
...
...
@@ -528,7 +528,10 @@ def show_protocol(protocol):
source_upload_form
=
KnownProtocolSourceUploadForm
()
time_diff
=
protocol
.
date
-
datetime
.
now
().
date
()
large_time_diff
=
not
protocol
.
is_done
()
and
time_diff
.
days
>
0
return
render_template
(
"protocol-show.html"
,
protocol
=
protocol
,
errors_table
=
errors_table
,
documents_table
=
documents_table
,
document_upload_form
=
document_upload_form
,
source_upload_form
=
source_upload_form
,
time_diff
=
time_diff
,
large_time_diff
=
large_time_diff
)
content_html
=
(
protocol
.
content_html_private
if
protocol
.
has_private_view_right
(
user
)
else
protocol
.
content_html_public
)
return
render_template
(
"protocol-show.html"
,
protocol
=
protocol
,
errors_table
=
errors_table
,
documents_table
=
documents_table
,
document_upload_form
=
document_upload_form
,
source_upload_form
=
source_upload_form
,
time_diff
=
time_diff
,
large_time_diff
=
large_time_diff
,
content_html
=
Markup
(
content_html
))
@
app
.
route
(
"/protocol/delete/<int:protocol_id>"
)
@
login_required
...
...
tasks.py
View file @
d6a68cab
...
...
@@ -371,6 +371,10 @@ def parse_protocol_async_inner(protocol, encoded_kwargs):
privacy_states
.
append
(
True
)
protocol
.
content_private
=
content_private
protocol
.
content_public
=
content_public
protocol
.
content_html_private
=
render_template
(
"protocol.html"
,
render_type
=
RenderType
.
html
,
show_private
=
True
,
**
render_kwargs
)
protocol
.
content_html_public
=
render_template
(
"protocol.html"
,
render_type
=
RenderType
.
html
,
show_private
=
False
,
**
render_kwargs
)
for
show_private
in
privacy_states
:
latex_source
=
texenv
.
get_template
(
"protocol.tex"
).
render
(
render_type
=
RenderType
.
latex
,
show_private
=
show_private
,
**
render_kwargs
)
...
...
templates/protocol-show.html
View file @
d6a68cab
...
...
@@ -153,5 +153,11 @@
{% endif %}
</div>
</div>
{% if content_html %}
<div>
<h3>
Protokollinhalt
</h3>
{{content_html|safe}}
</div>
{% endif %}
</div>
{% endblock %}
templates/protocol.html
0 → 100644
View file @
d6a68cab
{% for top in tree.children %}
{% if top|class == "Fork" %}
{{top.render(render_type=render_type, level=0, show_private=show_private, protocol=protocol)|safe}}
{% endif %}
{% endfor %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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