Commit 1c2c74f7 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Non-reproducible etherpad links

Allow to optionally use non-reproducible random uuids as etherpad links (#45)
parent 9c668487
"""empty message
Revision ID: 8fdd381e6a2a
Revises: cd972745eb09
Create Date: 2017-03-09 03:44:54.631531
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8fdd381e6a2a'
down_revision = 'cd972745eb09'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('protocols', sa.Column('pad_identifier', sa.String(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('protocols', 'pad_identifier')
# ### end Alembic commands ###
"""empty message
Revision ID: cd972745eb09
Revises: 0068d7a0fac0
Create Date: 2017-03-09 03:35:22.809679
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'cd972745eb09'
down_revision = '0068d7a0fac0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('protocoltypes', sa.Column('non_reproducible_pad_links', sa.Boolean(), nullable=True, server_default=sa.sql.expression.literal(False)))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('protocoltypes', 'non_reproducible_pad_links')
# ### end Alembic commands ###
...@@ -4,6 +4,7 @@ from datetime import datetime, time, date, timedelta ...@@ -4,6 +4,7 @@ from datetime import datetime, time, date, timedelta
import math import math
from io import StringIO, BytesIO from io import StringIO, BytesIO
from enum import Enum from enum import Enum
from uuid import uuid4
from shared import db, date_filter, date_filter_short, escape_tex, DATE_KEY, START_TIME_KEY, END_TIME_KEY from shared import db, date_filter, date_filter_short, escape_tex, DATE_KEY, START_TIME_KEY, END_TIME_KEY
from utils import random_string, url_manager, get_etherpad_url, split_terms, check_ip_in_networks from utils import random_string, url_manager, get_etherpad_url, split_terms, check_ip_in_networks
...@@ -57,6 +58,7 @@ class ProtocolType(DatabaseModel): ...@@ -57,6 +58,7 @@ class ProtocolType(DatabaseModel):
public_group = db.Column(db.String) public_group = db.Column(db.String)
private_mail = db.Column(db.String) private_mail = db.Column(db.String)
public_mail = db.Column(db.String) public_mail = db.Column(db.String)
non_reproducible_pad_links = db.Column(db.Boolean)
use_wiki = db.Column(db.Boolean) use_wiki = db.Column(db.Boolean)
wiki_category = db.Column(db.String) wiki_category = db.Column(db.String)
wiki_only_public = db.Column(db.Boolean) wiki_only_public = db.Column(db.Boolean)
...@@ -145,6 +147,7 @@ class Protocol(DatabaseModel): ...@@ -145,6 +147,7 @@ class Protocol(DatabaseModel):
end_time = db.Column(db.Time) end_time = db.Column(db.Time)
done = db.Column(db.Boolean) done = db.Column(db.Boolean)
public = db.Column(db.Boolean) public = db.Column(db.Boolean)
pad_identifier = db.Column(db.String)
tops = relationship("TOP", backref=backref("protocol"), cascade="all, delete-orphan", order_by="TOP.number") tops = relationship("TOP", backref=backref("protocol"), cascade="all, delete-orphan", order_by="TOP.number")
decisions = relationship("Decision", backref=backref("protocol"), cascade="all, delete-orphan", order_by="Decision.id") decisions = relationship("Decision", backref=backref("protocol"), cascade="all, delete-orphan", order_by="Decision.id")
...@@ -222,10 +225,15 @@ class Protocol(DatabaseModel): ...@@ -222,10 +225,15 @@ class Protocol(DatabaseModel):
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): def get_etherpad_link(self):
print(self.pad_identifier)
if self.pad_identifier is not None:
return self.pad_identifier
identifier = self.get_identifier() identifier = self.get_identifier()
if identifier is None: if self.protocoltype.non_reproducible_pad_links:
return "" identifier = str(uuid4())
return get_etherpad_url(self.get_identifier()) self.pad_identifier = identifier
db.session.commit()
return get_etherpad_url(identifier)
def get_datetime(self): def get_datetime(self):
return datetime(self.date.year, self.date.month, self.date.day, self.protocoltype.usual_time.hour, self.protocoltype.usual_time.minute) return datetime(self.date.year, self.date.month, self.date.day, self.protocoltype.usual_time.hour, self.protocoltype.usual_time.minute)
......
...@@ -102,6 +102,7 @@ class ProtocolTypeForm(FlaskForm): ...@@ -102,6 +102,7 @@ class ProtocolTypeForm(FlaskForm):
modify_group = SelectField("Bearbeitungsgruppe", choices=[]) modify_group = SelectField("Bearbeitungsgruppe", choices=[])
private_group = SelectField("Interne Gruppe", choices=[]) private_group = SelectField("Interne Gruppe", choices=[])
public_group = SelectField("Öffentliche Gruppe", choices=[]) public_group = SelectField("Öffentliche Gruppe", choices=[])
non_reproducible_pad_links = BooleanField("nicht nachvollziehbare Etherpad-Links")
private_mail = StringField("Interner Verteiler") private_mail = StringField("Interner Verteiler")
public_mail = StringField("Öffentlicher Verteiler") public_mail = StringField("Öffentlicher Verteiler")
wiki_category = StringField("Wiki-Kategorie") wiki_category = StringField("Wiki-Kategorie")
......
...@@ -153,6 +153,9 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -153,6 +153,9 @@ class ProtocolTypeTable(SingleValueTable):
general_headers = ["Name", "Abkürzung", "Organisation", "Beginn", general_headers = ["Name", "Abkürzung", "Organisation", "Beginn",
"Öffentlich", "Bearbeitungsgruppe", "Interne Gruppe", "Öffentlich", "Bearbeitungsgruppe", "Interne Gruppe",
"Öffentliche Gruppe"] "Öffentliche Gruppe"]
etherpad_headers = ["Nicht-reproduzierbare Etherpadlinks"]
if not config.ETHERPAD_ACTIVE:
etherpad_headers = []
mail_headers = ["Interner Verteiler", "Öffentlicher Verteiler"] mail_headers = ["Interner Verteiler", "Öffentlicher Verteiler"]
if not config.MAIL_ACTIVE: if not config.MAIL_ACTIVE:
mail_headers = [] mail_headers = []
...@@ -167,8 +170,9 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -167,8 +170,9 @@ class ProtocolTypeTable(SingleValueTable):
calendar_headers = [] calendar_headers = []
network_headers = ["Netzwerke einschränken", "Erlaubte Netzwerke"] network_headers = ["Netzwerke einschränken", "Erlaubte Netzwerke"]
action_headers = ["Aktion"] action_headers = ["Aktion"]
return (general_headers + mail_headers + printing_headers return (general_headers + etherpad_headers + mail_headers
+ wiki_headers + calendar_headers + network_headers + action_headers) + printing_headers + wiki_headers + calendar_headers
+ network_headers + action_headers)
def row(self): def row(self):
user = current_user() user = current_user()
...@@ -182,6 +186,11 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -182,6 +186,11 @@ class ProtocolTypeTable(SingleValueTable):
self.value.private_group, self.value.private_group,
self.value.public_group, self.value.public_group,
] ]
etherpad_part = [
Table.bool(self.value.non_reproducible_pad_links)
]
if not config.ETHERPAD_ACTIVE:
ethernet_part = []
mail_part = [ mail_part = [
self.value.private_mail, self.value.private_mail,
self.value.public_mail, self.value.public_mail,
...@@ -208,8 +217,8 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -208,8 +217,8 @@ class ProtocolTypeTable(SingleValueTable):
action_part = [Table.link(url_for("delete_type", protocoltype_id=self.value.id), "Löschen", confirm="Bist du dir sicher, dass du den Protokolltype {} löschen möchtest?".format(self.value.name))] action_part = [Table.link(url_for("delete_type", protocoltype_id=self.value.id), "Löschen", confirm="Bist du dir sicher, dass du den Protokolltype {} löschen möchtest?".format(self.value.name))]
if not self.value.has_admin_right(user): if not self.value.has_admin_right(user):
action_part = [""] action_part = [""]
return (general_part + mail_part + printing_part + wiki_part + return (general_part + etherpad_part + mail_part + printing_part
calendar_part + network_part + action_part) + wiki_part + calendar_part + network_part + action_part)
class DefaultTOPsTable(Table): class DefaultTOPsTable(Table):
def __init__(self, tops, protocoltype=None): def __init__(self, tops, protocoltype=None):
......
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