Commit 54b1574d authored by Robin Sonnabend's avatar Robin Sonnabend

Make metadata internal optionally

/close #80
parent 60452dce
"""empty message
Revision ID: 4651698510d7
Revises: a06cc03bdef4
Create Date: 2017-03-22 21:42:04.880972
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4651698510d7'
down_revision = 'a06cc03bdef4'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('defaultmetas', sa.Column('internal', sa.Boolean(), nullable=True))
op.add_column('metas', sa.Column('internal', sa.Boolean(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('metas', 'internal')
op.drop_column('defaultmetas', 'internal')
# ### end Alembic commands ###
......@@ -203,7 +203,7 @@ class Protocol(DatabaseModel):
for default_meta in self.protocoltype.metas:
if default_meta.key in remarks:
value = remarks[default_meta.key].value.strip()
meta = Meta(protocol_id=self.id, name=default_meta.name, value=value)
meta = Meta(protocol_id=self.id, name=default_meta.name, value=value, internal=default_meta.internal)
db.session.add(meta)
db.session.commit()
......@@ -657,6 +657,7 @@ class DefaultMeta(DatabaseModel):
protocoltype_id = db.Column(db.Integer, db.ForeignKey("protocoltypes.id"))
key = db.Column(db.String)
name = db.Column(db.String)
internal = db.Column(db.Boolean)
def get_parent(self):
return self.protocoltype
......@@ -668,6 +669,7 @@ class Meta(DatabaseModel):
protocol_id = db.Column(db.Integer, db.ForeignKey("protocols.id"))
name = db.Column(db.String)
value = db.Column(db.String)
internal = db.Column(db.Boolean)
def get_parent(self):
return self.protocol
......
......@@ -505,7 +505,7 @@ def send_protocol_async(protocol_id, show_private):
protocol = Protocol.query.filter_by(id=protocol_id).first()
to_addr = protocol.protocoltype.private_mail if show_private else protocol.protocoltype.public_mail
subject = "{}{}-Protokoll vom {}".format("Internes " if show_private else "", protocol.protocoltype.short_name, date_filter(protocol.date))
mail_content = render_template("protocol-mail.txt", protocol=protocol)
mail_content = render_template("protocol-mail.txt", protocol=protocol, show_private=show_private)
appendix = [(document.name, document.as_file_like())
for document in protocol.documents
if show_private or not document.is_private
......
......@@ -5,7 +5,9 @@ Datum: {{protocol.date|datify_long}}
Zeit: von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}}
{% endif %}
{% for meta in protocol.metas %}
{% if not meta.internal or show_private %}
{{meta.name}}: {{meta.value}}
{% endif %}
{% endfor %}
Die Tagesordnung ist:
......
......@@ -65,7 +65,9 @@
{% endif %}
{% if has_public_view_right %}
{% for meta in protocol.metas %}
<p><strong>{{meta.name}}:</strong> {{meta.value}}</p>
{% if not meta.internal or has_private_view_right %}
<p><strong>{{meta.name}}:</strong> {{meta.value}}</p>
{% endif %}
{% endfor %}
{% endif %}
{% else %}
......
......@@ -27,7 +27,9 @@
{\bf Datum:} & \VAR{protocol.date|datify_long|escape_tex}\\
\ENV{endif}
\ENV{for meta in protocol.metas}
{\bf \VAR{meta.name|escape_tex}:} & \VAR{meta.value|escape_tex}\\
\ENV{if not meta.internal or show_private}
{\bf \VAR{meta.name|escape_tex}:} & \VAR{meta.value|escape_tex}\\
\ENV{endif}
\ENV{endfor}
\end{tabular}
\normalsize
......
......@@ -7,7 +7,9 @@
| zeit = von <var>protocol.start_time|timify</var> bis <var>protocol.end_time|timify</var>
<env> endif </env>
<env> for meta in protocol.metas </env>
<env> if not meta.internal or not protocol.protocoltype.wiki_only_public </env>
| <var>meta.name|lower</var> = <var>meta.value</var>
<env> endif </env>
<env> endfor </env>
}}
......
......@@ -243,10 +243,12 @@ class TodoMailForm(FlaskForm):
class MetaForm(FlaskForm):
name = StringField("Name", validators=[InputRequired("Bitte gib den Namen der Metadaten an.")])
value = StringField("Wert")
internal = BooleanField("Intern")
class DefaultMetaForm(FlaskForm):
key = StringField("Key", validators=[InputRequired("Bitte gib den Protokoll-Syntax-Schlüssel der Metadaten an.")])
name = StringField("Name", validators=[InputRequired("Bitte gib den Namen der Metadaten an.")])
internal = BooleanField("Intern")
class DecisionCategoryForm(FlaskForm):
name = StringField("Name", validators=[InputRequired("Bitte gib den Namen der Kategorie an.")])
......
......@@ -474,13 +474,14 @@ class DefaultMetasTable(Table):
)
def headers(self):
return ["Name", "Key", ""]
return ["Name", "Key", "Intern", ""]
def row(self, meta):
user = current_user()
general_part = [
meta.name,
meta.key,
Table.bool(meta.internal)
]
links = [
Table.link(url_for("edit_defaultmeta", defaultmeta_id=meta.id), "Ändern"),
......@@ -491,7 +492,6 @@ class DefaultMetasTable(Table):
class DecisionCategoriesTable(Table):
def __init__(self, categories, protocoltype):
print(categories)
super().__init__(
"Beschlusskategorien",
categories,
......
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