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

Render plaintext protocol version

parent 1f17afaa
"""empty message
Revision ID: 310d9ab321b8
Revises: 0131d5776f8d
Create Date: 2017-02-25 17:26:34.663460
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '310d9ab321b8'
down_revision = '0131d5776f8d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('protocols', sa.Column('plain_text_private', sa.String(), nullable=True))
op.add_column('protocols', sa.Column('plain_text_public', sa.String(), nullable=True))
op.drop_column('todos', 'is_id_fixed')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('todos', sa.Column('is_id_fixed', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.drop_column('protocols', 'plain_text_public')
op.drop_column('protocols', 'plain_text_private')
# ### end Alembic commands ###
"""empty message
Revision ID: 495509e8f49a
Revises: 310d9ab321b8
Create Date: 2017-02-25 17:34:03.830014
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '495509e8f49a'
down_revision = '310d9ab321b8'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('protocols', sa.Column('content_private', sa.String(), nullable=True))
op.add_column('protocols', sa.Column('content_public', sa.String(), nullable=True))
op.drop_column('protocols', 'plain_text_private')
op.drop_column('protocols', 'plain_text_public')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('protocols', sa.Column('plain_text_public', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('protocols', sa.Column('plain_text_private', sa.VARCHAR(), autoincrement=False, nullable=True))
op.drop_column('protocols', 'content_public')
op.drop_column('protocols', 'content_private')
# ### end Alembic commands ###
......@@ -93,7 +93,9 @@ class Protocol(db.Model):
__tablename__ = "protocols"
id = db.Column(db.Integer, primary_key=True)
protocoltype_id = db.Column(db.Integer, db.ForeignKey("protocoltypes.id"))
source = db.Column(db.String, nullable=True)
source = db.Column(db.String)
content_public = db.Column(db.String)
content_private = db.Column(db.String)
date = db.Column(db.Date)
start_time = db.Column(db.Time)
end_time = db.Column(db.Time)
......@@ -107,10 +109,12 @@ class Protocol(db.Model):
documents = relationship("Document", backref=backref("protocol"), cascade="all, delete-orphan", order_by="Document.is_compiled")
errors = relationship("Error", backref=backref("protocol"), cascade="all, delete-orphan", order_by="Error.id")
def __init__(self, protocoltype_id, date, source=None, start_time=None, end_time=None, author=None, participants=None, location=None, done=False):
def __init__(self, protocoltype_id, date, source=None, content_public=None, content_private=None, start_time=None, end_time=None, author=None, participants=None, location=None, done=False):
self.protocoltype_id = protocoltype_id
self.date = date
self.source = source
self.content_private = content_private
self.content_public = content_public
self.start_time = start_time
self.end_time = end_time
self.author = author
......
......@@ -160,7 +160,7 @@ class Text:
return escape_tex(self.text)
elif render_type == RenderType.wikitext:
return self.text
elif render_Type == RenderType.plaintext:
elif render_type == RenderType.plaintext:
return self.text
else:
raise _not_implemented(self, render_type)
......@@ -195,6 +195,8 @@ class Tag:
elif self.name == "todo":
return self.todo.render_latex(current_protocol=protocol)
return r"\textbf{{{}:}} {}".format(escape_tex(self.name.capitalize()), escape_tex(self.values[0]))
elif render_type == RenderType.plaintext:
return "{}: {}".format(self.name.capitalize(), self.values[0])
else:
raise _not_implemented(self, render_type)
......@@ -331,7 +333,7 @@ class Fork(Element):
title_line = "{} {}".format("#" * (level + 1), name_line)
content_parts = []
for child in self.children:
part = child.render(render_Type, show_private, level=level+1, protocol=protocol)
part = child.render(render_type, show_private, level=level+1, protocol=protocol)
if len(part.strip()) == 0:
continue
content_parts.append(part)
......
......@@ -14,7 +14,7 @@ from datetime import datetime
import math
import config
from shared import db, date_filter, datetime_filter, date_filter_long, time_filter, ldap_manager, security_manager, current_user, check_login, login_required, group_required
from shared import db, date_filter, datetime_filter, date_filter_long, time_filter, ldap_manager, security_manager, current_user, check_login, login_required, group_required, class_filter
from utils import is_past, mail_manager, url_manager, get_first_unused_int, set_etherpad_text, get_etherpad_text
from models.database import ProtocolType, Protocol, DefaultTOP, TOP, Document, Todo, Decision, MeetingReminder, Error
from views.forms import LoginForm, ProtocolTypeForm, DefaultTopForm, MeetingReminderForm, NewProtocolForm, DocumentUploadForm, KnownProtocolSourceUploadForm, NewProtocolSourceUploadForm, ProtocolForm, TopForm, SearchForm
......@@ -45,6 +45,7 @@ app.jinja_env.filters["datetimify"] = datetime_filter
app.jinja_env.filters["timify"] = time_filter
app.jinja_env.filters["datify_long"] = date_filter_long
app.jinja_env.filters["url_complete"] = url_manager.complete
app.jinja_env.filters["class"] = class_filter
app.jinja_env.tests["auth_valid"] = security_manager.check_user
import tasks
......
......@@ -190,15 +190,23 @@ def parse_protocol_async(protocol_id, encoded_kwargs):
db.session.add(top)
db.session.commit()
private_states = [False]
latex_source_private = texenv.get_template("protocol.tex").render(protocol=protocol, tree=tree, show_private=True, render_type=RenderType.latex)
latex_source_public = texenv.get_template("protocol.tex").render(protocol=protocol, tree=tree, show_private=False, render_type=RenderType.latex)
compile(latex_source_public, protocol, show_private=False)
if latex_source_private != latex_source_public:
compile(latex_source_private, protocol, show_private=True)
# TODO compare something that may actually be equal
render_kwargs = {
"protocol": protocol,
"tree": tree
}
privacy_states = [False]
content_private = render_template("protocol.txt", render_type=RenderType.plaintext, show_private=True, **render_kwargs)
content_public = render_template("protocol.txt", render_type=RenderType.plaintext, show_private=False, **render_kwargs)
if content_private != content_public:
print("different")
privacy_states.append(True)
protocol.content_private = content_private
protocol.content_public = content_public
for show_private in privacy_states:
latex_source = texenv.get_template("protocol.tex").render(render_type=RenderType.latex, show_private=show_private, **render_kwargs)
compile(latex_source, protocol, show_private=show_private)
# TODO render and push wiki
protocol.done = True
db.session.commit()
......
......@@ -55,9 +55,13 @@
{% if protocol.is_done() %}
<h3>Beschlüsse</h3>
<ul>
{% for decision in protocol.decisions %}
<li>{{decision.content}}</li>
{% endfor %}
{% if protocol.decisions|length > 0 %}
{% for decision in protocol.decisions %}
<li>{{decision.content}}</li>
{% endfor %}
{% else %}
<li>Keine Beschlüsse</li>
{% endif %}
</ul>
{% endif %}
</div>
......
{% for top in tree.children %}
{% if top|class == "Fork" %}
{{top.render(render_type=render_type, level=0, show_private=show_private, protocol=protocol)}}
{% endif %}
{% endfor %}
......@@ -68,5 +68,5 @@ class SearchForm(FlaskForm):
def __init__(self, protocoltypes, **kwargs):
super().__init__(**kwargs)
choices = [(protocoltype.id, protocoltype.short_name) for protocoltype in protocoltypes]
choices.insert(0, (-1, ""))
choices.insert(0, (-1, "Alle"))
self.protocoltype.choices = choices
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