Skip to content
Snippets Groups Projects
Unverified Commit cef811fc authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Add default protocol recurrence

If a meeting has a regular interval (e.g. weekly or biweekly), setting
the protocoltype recurrence interval simplifies generating regular
protocols.
If recurrence is set and no [sitzung;…]-tag is given in the protocol, a
new protocol will be created on date+recurrence days on protocol upload,
provided this date is still in the future.
parent 20fb0bcc
No related branches found
No related tags found
No related merge requests found
"""empty message
Revision ID: da846db78ff9
Revises: 7834767242e8
Create Date: 2022-10-29 19:24:42.934124
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'da846db78ff9'
down_revision = '7834767242e8'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('protocoltypes', sa.Column('recurrence', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('protocoltypes', 'recurrence')
# ### end Alembic commands ###
...@@ -78,6 +78,7 @@ class ProtocolType(DatabaseModel): ...@@ -78,6 +78,7 @@ class ProtocolType(DatabaseModel):
restrict_networks = db.Column(db.Boolean) restrict_networks = db.Column(db.Boolean)
allowed_networks = db.Column(db.Text) allowed_networks = db.Column(db.Text)
latex_template = db.Column(db.Text) latex_template = db.Column(db.Text)
recurrence = db.Column(db.Integer)
protocols = relationship( protocols = relationship(
"Protocol", backref=backref("protocoltype"), "Protocol", backref=backref("protocoltype"),
......
...@@ -4,7 +4,7 @@ import os ...@@ -4,7 +4,7 @@ import os
import subprocess import subprocess
import shutil import shutil
import tempfile import tempfile
from datetime import datetime from datetime import datetime, timedelta
import time import time
import traceback import traceback
from copy import copy from copy import copy
...@@ -500,6 +500,11 @@ def parse_protocol_async_inner(protocol, ignore_old_date=False): ...@@ -500,6 +500,11 @@ def parse_protocol_async_inner(protocol, ignore_old_date=False):
if not protocol.protocoltype.get_protocols_on_date(new_protocol_date): if not protocol.protocoltype.get_protocols_on_date(new_protocol_date):
Protocol.create_new_protocol( Protocol.create_new_protocol(
protocol.protocoltype, new_protocol_date, new_protocol_time) protocol.protocoltype, new_protocol_date, new_protocol_time)
if not protocol_tags and protocol.protocoltype.recurrence:
new_protocol_date = protocol.date + timedelta(
days=protocol.protocoltype.recurrence)
if new_protocol_date > datetime.now().date():
Protocol.create_new_protocol(protocol.protocoltype, new_protocol_date)
# TOPs # TOPs
old_tops = list(protocol.tops) old_tops = list(protocol.tops)
......
...@@ -174,6 +174,7 @@ class ProtocolTypeForm(FlaskForm): ...@@ -174,6 +174,7 @@ class ProtocolTypeForm(FlaskForm):
wiki_only_public = BooleanField("Wiki ist öffentlich") wiki_only_public = BooleanField("Wiki ist öffentlich")
printer = SelectField("Drucker", choices=[]) printer = SelectField("Drucker", choices=[])
calendar = SelectField("Kalender", choices=[]) calendar = SelectField("Kalender", choices=[])
recurrence = IntegerField("Turnus (in Tagen)", validators=[Optional()])
restrict_networks = BooleanField("Netzwerke einschränken") restrict_networks = BooleanField("Netzwerke einschränken")
allowed_networks = IPNetworkField("Erlaubte Netzwerke") allowed_networks = IPNetworkField("Erlaubte Netzwerke")
latex_template = SelectField("LaTeX Vorlage", choices=[]) latex_template = SelectField("LaTeX Vorlage", choices=[])
......
...@@ -237,6 +237,7 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -237,6 +237,7 @@ class ProtocolTypeTable(SingleValueTable):
calendar_headers = ["Kalender"] calendar_headers = ["Kalender"]
if not config.CALENDAR_ACTIVE: if not config.CALENDAR_ACTIVE:
calendar_headers = [] calendar_headers = []
recurrence_headers = ["Turnus"]
network_headers = ["Netzwerke einschränken", "Erlaubte Netzwerke"] network_headers = ["Netzwerke einschränken", "Erlaubte Netzwerke"]
action_headers = ["Aktion"] action_headers = ["Aktion"]
feed_headers = [] feed_headers = []
...@@ -249,8 +250,8 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -249,8 +250,8 @@ class ProtocolTypeTable(SingleValueTable):
return ( return (
general_headers + etherpad_headers + mail_headers general_headers + etherpad_headers + mail_headers
+ printing_headers + wiki_headers + calendar_headers + printing_headers + wiki_headers + calendar_headers
+ network_headers + latex_template_headers + feed_headers + recurrence_headers + network_headers + latex_template_headers
+ action_headers) + feed_headers + action_headers)
def row(self): def row(self):
user = current_user() user = current_user()
...@@ -297,6 +298,7 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -297,6 +298,7 @@ class ProtocolTypeTable(SingleValueTable):
if self.value.calendar is not None else ""] if self.value.calendar is not None else ""]
if not config.CALENDAR_ACTIVE: if not config.CALENDAR_ACTIVE:
calendar_part = [] calendar_part = []
recurrence_part = [f"{self.value.recurrence} Tage" if self.value.recurrence is not None else ""]
network_part = [Table.bool(self.value.restrict_networks)] network_part = [Table.bool(self.value.restrict_networks)]
if self.value.allowed_networks is not None: if self.value.allowed_networks is not None:
network_part.append( network_part.append(
...@@ -344,8 +346,8 @@ class ProtocolTypeTable(SingleValueTable): ...@@ -344,8 +346,8 @@ class ProtocolTypeTable(SingleValueTable):
action_part = [""] action_part = [""]
return ( return (
general_part + etherpad_part + mail_part + printing_part general_part + etherpad_part + mail_part + printing_part
+ wiki_part + calendar_part + network_part + latex_template_part + wiki_part + calendar_part + recurrence_part + network_part
+ feed_part + action_part) + latex_template_part + feed_part + action_part)
class DefaultTOPsTable(Table): class DefaultTOPsTable(Table):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment