You've already forked Mailu
mirror of
https://github.com/Mailu/Mailu.git
synced 2025-07-15 01:24:34 +02:00
Change the spam threshold to an integer, related to #103
This commit is contained in:
@ -152,7 +152,7 @@ class User(Base, Email):
|
||||
# Settings
|
||||
displayed_name = db.Column(db.String(160), nullable=False, default="")
|
||||
spam_enabled = db.Column(db.Boolean(), nullable=False, default=True)
|
||||
spam_threshold = db.Column(db.Numeric(), nullable=False, default=80.0)
|
||||
spam_threshold = db.Column(db.Integer(), nullable=False, default=80.0)
|
||||
|
||||
# Flask-login attributes
|
||||
is_authenticated = True
|
||||
|
@ -14,7 +14,7 @@ User settings
|
||||
{{ macros.form_field(form.displayed_name) }}
|
||||
{{ macros.form_field(form.spam_enabled) }}
|
||||
{{ macros.form_field(form.spam_threshold, step=1, max=100,
|
||||
prepend='<span class="input-group-addon"><span id="threshold">'+(form.spam_threshold.data).__int__().__str__()+'</span> / 100</span>',
|
||||
prepend='<span class="input-group-addon"><span id="threshold">'+form.spam_threshold.data.__str__()+'</span> / 100</span>',
|
||||
oninput='$("#threshold").text(this.value);') }}
|
||||
{{ macros.form_field(form.submit) }}
|
||||
</form>
|
||||
|
35
admin/migrations/versions/12e9a4f6ed73_.py
Normal file
35
admin/migrations/versions/12e9a4f6ed73_.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""Set the spam threshold as an integer
|
||||
|
||||
Revision ID: 12e9a4f6ed73
|
||||
Revises: 27ae2f102682
|
||||
Create Date: 2016-11-08 20:22:54.169833
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '12e9a4f6ed73'
|
||||
down_revision = '27ae2f102682'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from mailu.admin import models
|
||||
from mailu import db
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Make sure that every value is already an Integer
|
||||
for user in models.User.query.all():
|
||||
user.spam_threshold = int(user.spam_threshold)
|
||||
db.session.commit()
|
||||
# Migrate the table
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column(
|
||||
'spam_threshold', existing_type=db.Numeric(), type_=db.Integer())
|
||||
|
||||
|
||||
def downgrade():
|
||||
# Migrate the table
|
||||
with op.batch_alter_table('user') as batch:
|
||||
batch.alter_column(
|
||||
'spam_threshold', existing_type=db.Integer(), type_=db.Numeric())
|
Reference in New Issue
Block a user