Add an end of vacation field, related to #218

master
kaiyou 7 years ago
parent fb42797ab7
commit 011e1fa52d

@ -2,7 +2,7 @@ from mailu import app, db, dkim, login_manager
from sqlalchemy.ext import declarative
from passlib import context, hash
from datetime import datetime
from datetime import datetime, date
from email.mime import text
@ -194,6 +194,8 @@ class User(Base, Email):
reply_enabled = db.Column(db.Boolean(), nullable=False, default=False)
reply_subject = db.Column(db.String(255), nullable=True, default=None)
reply_body = db.Column(db.Text(), nullable=True, default=None)
reply_enddate = db.Column(db.Date, nullable=False,
default=date(2999, 12, 31))
# Settings
displayed_name = db.Column(db.String(160), nullable=False, default="")

@ -101,6 +101,7 @@ class UserReplyForm(flask_wtf.FlaskForm):
reply_subject = fields.StringField(_('Reply subject'))
reply_body = fields.StringField(_('Reply body'),
widget=widgets.TextArea())
reply_enddate = fields.html5.DateField(_('End of vacation'))
submit = fields.SubmitField(_('Update'))

@ -13,12 +13,14 @@
<form class="form" method="post" role="form">
{{ form.hidden_tag() }}
{{ macros.form_field(form.reply_enabled,
onchange="if(this.checked){$('#reply_subject,#reply_body').removeAttr('readonly')}
else{$('#reply_subject,#reply_body').attr('readonly', '')}") }}
onchange="if(this.checked){$('#reply_subject,#reply_body,#reply_enddate').removeAttr('readonly')}
else{$('#reply_subject,#reply_body,#reply_enddate').attr('readonly', '')}") }}
{{ macros.form_field(form.reply_subject,
**{("rw" if user.reply_enabled else "readonly"): ""}) }}
{{ macros.form_field(form.reply_body, rows=10,
**{("rw" if user.reply_enabled else "readonly"): ""}) }}
{{ macros.form_field(form.reply_enddate,
**{("rw" if user.reply_enabled else "readonly"): ""}) }}
{{ macros.form_field(form.submit) }}
</form>
{% endcall %}

@ -0,0 +1,23 @@
""" Add an enddate for the vacation mode
Revision ID: 77aa22ad72e2
Revises: 9400a032eb1a
Create Date: 2017-11-10 15:10:33.477592
"""
# revision identifiers, used by Alembic.
revision = '77aa22ad72e2'
down_revision = '9400a032eb1a'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('user', sa.Column('reply_enddate', sa.Date(), nullable=False,
server_default="2999-12-31"))
def downgrade():
op.drop_column('user', 'reply_enddate')
Loading…
Cancel
Save