Support adding comments to records

master
Pierre Jaury 8 years ago
parent 370a2fae4d
commit 8fb2e58661

@ -11,23 +11,27 @@ class LoginForm(Form):
class DomainCreateForm(Form): class DomainCreateForm(Form):
name = fields.StringField('Domain name', [validators.DataRequired()]) name = fields.StringField('Domain name', [validators.DataRequired()])
comment = fields.StringField('Comment')
submit = fields.SubmitField('Create') submit = fields.SubmitField('Create')
class DomainEditForm(Form): class DomainEditForm(Form):
max_users = fields.IntegerField('Maximum mailbox count') max_users = fields.IntegerField('Maximum mailbox count')
max_aliases = fields.IntegerField('Maximum aliases count') max_aliases = fields.IntegerField('Maximum aliases count')
comment = fields.StringField('Comment')
submit = fields.SubmitField('Save') submit = fields.SubmitField('Save')
class UserCreateForm(Form): class UserCreateForm(Form):
localpart = fields.StringField('E-mail', [validators.DataRequired()]) localpart = fields.StringField('E-mail', [validators.DataRequired()])
pw = fields.PasswordField('Password', [validators.DataRequired()]) pw = fields.PasswordField('Password', [validators.DataRequired()])
comment = fields.StringField('Comment')
submit = fields.SubmitField('Create') submit = fields.SubmitField('Create')
class UserEditForm(Form): class UserEditForm(Form):
quota_bytes = fields.IntegerField('Quota') quota_bytes = fields.IntegerField('Quota')
comment = fields.StringField('Comment')
submit = fields.SubmitField('Create') submit = fields.SubmitField('Create')
@ -58,9 +62,11 @@ class UserReplyForm(Form):
class AliasCreateForm(Form): class AliasCreateForm(Form):
localpart = fields.StringField('Alias', [validators.DataRequired()]) localpart = fields.StringField('Alias', [validators.DataRequired()])
destination = fields.StringField('Destination', widget=widgets.TextArea()) destination = fields.StringField('Destination', widget=widgets.TextArea())
comment = fields.StringField('Comment')
submit = fields.SubmitField('Create') submit = fields.SubmitField('Create')
class AliasEditForm(Form): class AliasEditForm(Form):
destination = fields.StringField('Destination', widget=widgets.TextArea()) destination = fields.StringField('Destination', widget=widgets.TextArea())
comment = fields.StringField('Comment')
submit = fields.SubmitField('Create') submit = fields.SubmitField('Create')

@ -25,6 +25,7 @@ class Base(db.Model):
created_at = db.Column(db.Date, nullable=False, default=datetime.now) created_at = db.Column(db.Date, nullable=False, default=datetime.now)
updated_at = db.Column(db.Date, nullable=True, onupdate=datetime.now) updated_at = db.Column(db.Date, nullable=True, onupdate=datetime.now)
comment = db.Column(db.String(255), nullable=True)
class Domain(Base): class Domain(Base):

@ -19,6 +19,7 @@ Alias list
<th>Actions</th> <th>Actions</th>
<th>Address</th> <th>Address</th>
<th>Destination</th> <th>Destination</th>
<th>Comment</th>
<th>Created</th> <th>Created</th>
<th>Last edit</th> <th>Last edit</th>
</tr> </tr>
@ -30,6 +31,7 @@ Alias list
</td> </td>
<td>{{ alias }}</td> <td>{{ alias }}</td>
<td>{{ alias.destination or '-' }}</td> <td>{{ alias.destination or '-' }}</td>
<td>{{ alias.comment or '' }}</td>
<td>{{ alias.created_at }}</td> <td>{{ alias.created_at }}</td>
<td>{{ alias.updated_at or '' }}</td> <td>{{ alias.updated_at or '' }}</td>
</tr> </tr>

@ -18,6 +18,7 @@ Domain list
<th>Domain name</th> <th>Domain name</th>
<th>Mailbox count</th> <th>Mailbox count</th>
<th>Alias count</th> <th>Alias count</th>
<th>Comemnt</th>
<th>Created</th> <th>Created</th>
<th>Last edit</th> <th>Last edit</th>
</tr> </tr>
@ -33,6 +34,7 @@ Domain list
<td>{{ domain.name }}</td> <td>{{ domain.name }}</td>
<td>{{ domain.users | count }} / {{ domain.max_users or '∞' }}</td> <td>{{ domain.users | count }} / {{ domain.max_users or '∞' }}</td>
<td>{{ domain.aliases | count }} / {{ domain.max_aliases or '∞' }}</td> <td>{{ domain.aliases | count }} / {{ domain.max_aliases or '∞' }}</td>
<td>{{ domain.comment or '' }}</td>
<td>{{ domain.created_at }}</td> <td>{{ domain.created_at }}</td>
<td>{{ domain.updated_at or '' }}</td> <td>{{ domain.updated_at or '' }}</td>
</tr> </tr>

@ -22,6 +22,7 @@ User list
<th>Forward</th> <th>Forward</th>
<th>Reply</th> <th>Reply</th>
<th>Quota</th> <th>Quota</th>
<th>Comment</th>
<th>Created</th> <th>Created</th>
<th>Last edit</th> <th>Last edit</th>
</tr> </tr>
@ -41,6 +42,7 @@ User list
<td>{% if user.forward %}<span class="label label-info">enabled</span>{% endif %}</td> <td>{% if user.forward %}<span class="label label-info">enabled</span>{% endif %}</td>
<td>{% if user.reply_subject %}<span class="label label-info">enabled</span>{% endif %}</td> <td>{% if user.reply_subject %}<span class="label label-info">enabled</span>{% endif %}</td>
<td>{{ user.quota_bytes | filesizeformat }}</td> <td>{{ user.quota_bytes | filesizeformat }}</td>
<td>{{ user.comment or '' }}</td>
<td>{{ user.created_at }}</td> <td>{{ user.created_at }}</td>
<td>{{ user.updated_at or '' }}</td> <td>{{ user.updated_at or '' }}</td>
</tr> </tr>

@ -26,10 +26,9 @@ def alias_create(domain_name):
flask.flash('Address %s is already used' % address, 'error') flask.flash('Address %s is already used' % address, 'error')
break break
else: else:
alias = models.Alias( alias = models.Alias(localpart=form.localpart.data, domain=domain)
localpart=form.localpart.data, domain=domain, alias.destination = form.destination.data
destination=form.destination.data alias.comment = form.comment.data
)
db.session.add(alias) db.session.add(alias)
db.session.commit() db.session.commit()
flask.flash('Alias %s created' % alias) flask.flash('Alias %s created' % alias)
@ -46,6 +45,7 @@ def alias_edit(alias):
form = forms.AliasEditForm() form = forms.AliasEditForm()
if form.validate_on_submit(): if form.validate_on_submit():
alias.destination = form.destination.data alias.destination = form.destination.data
alias.comment = form.comment.data
db.session.add(alias) db.session.add(alias)
db.session.commit() db.session.commit()
flask.flash('Alias %s updated' % alias) flask.flash('Alias %s updated' % alias)

@ -21,6 +21,7 @@ def domain_create():
flask.flash('Domain %s is already used' % form.name.data, 'error') flask.flash('Domain %s is already used' % form.name.data, 'error')
else: else:
domain = models.Domain(name=form.name.data) domain = models.Domain(name=form.name.data)
domain.comment = form.comment.data
db.session.add(domain) db.session.add(domain)
db.session.commit() db.session.commit()
flask.flash('Domain %s created' % domain) flask.flash('Domain %s created' % domain)
@ -37,6 +38,7 @@ def domain_edit(domain_name):
if form.validate_on_submit(): if form.validate_on_submit():
domain.max_users = form.max_users.data domain.max_users = form.max_users.data
domain.max_aliases = form.max_aliases.data domain.max_aliases = form.max_aliases.data
domain.comment = form.comment.data
db.session.add(domain) db.session.add(domain)
db.session.commit() db.session.commit()
flask.flash('Domain %s saved' % domain) flask.flash('Domain %s saved' % domain)

@ -27,6 +27,7 @@ def user_create(domain_name):
break break
else: else:
user = models.User(localpart=form.localpart.data, domain=domain) user = models.User(localpart=form.localpart.data, domain=domain)
user.comment = form.comment.data
user.set_password(form.pw.data) user.set_password(form.pw.data)
db.session.add(user) db.session.add(user)
db.session.commit() db.session.commit()
@ -44,6 +45,7 @@ def user_edit(user_email):
form = forms.UserEditForm(obj=user) form = forms.UserEditForm(obj=user)
if form.validate_on_submit(): if form.validate_on_submit():
user.quota_bytes = form.quota_bytes.data user.quota_bytes = form.quota_bytes.data
user.comment = form.comment.data
db.session.add(user) db.session.add(user)
db.session.commit() db.session.commit()
flask.flash('User %s updated' % user) flask.flash('User %s updated' % user)

Loading…
Cancel
Save