Fix all references to mailu.admin

master
kaiyou 7 years ago
parent 9358a76d89
commit fed7665a0a

@ -11,8 +11,6 @@ import docker
from apscheduler.schedulers import background from apscheduler.schedulers import background
from mailu import models
# Create application # Create application
app = flask.Flask(__name__, static_url_path='/admin/app_static') app = flask.Flask(__name__, static_url_path='/admin/app_static')
@ -71,17 +69,11 @@ def get_locale():
# Login configuration # Login configuration
login_manager = flask_login.LoginManager() login_manager = flask_login.LoginManager()
login_manager.init_app(app) login_manager.init_app(app)
login_manager.login_view = "admin.login" login_manager.login_view = ".login"
login_manager.user_loader(models.User.query.get)
@app.context_processor @app.context_processor
def inject_user(): def inject_user():
return dict(current_user=flask_login.current_user) return dict(current_user=flask_login.current_user)
@app.route("/")
def index():
return flask.redirect("/webmail/")
# Import views # Import views
from mailu.views import * from mailu.views import *

@ -1,4 +1,4 @@
from mailu.admin import db, models, forms from mailu import db, models, forms
import flask import flask
import flask_login import flask_login

@ -1,5 +1,4 @@
from mailu.admin import db, dkim from mailu import app, db, dkim, login_manager
from mailu import app
from sqlalchemy.ext import declarative from sqlalchemy.ext import declarative
from passlib import context from passlib import context
@ -236,6 +235,8 @@ class User(Base, Email):
user = cls.query.get(email) user = cls.query.get(email)
return user if (user and user.check_password(password)) else None return user if (user and user.check_password(password)) else None
login_manager.user_loader(User.query.get)
class Alias(Base, Email): class Alias(Base, Email):
""" An alias is an email address that redirects to some destination. """ An alias is an email address that redirects to some destination.

@ -0,0 +1 @@
__all__ = ['admins', 'aliases', 'alternatives', 'base', 'domains', 'fetches', 'managers', 'users', 'relays']

@ -1,4 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
import flask import flask
import flask_login import flask_login

@ -1,4 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
import flask import flask
import wtforms_components import wtforms_components

@ -1,4 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
import flask import flask
import wtforms_components import wtforms_components

@ -1,5 +1,4 @@
from mailu import dockercli, app as flask_app from mailu import dockercli, app, db, models, forms, access
from mailu.admin import app, db, models, forms, access
import flask import flask
import flask_login import flask_login
@ -53,7 +52,7 @@ def services():
@access.global_admin @access.global_admin
def announcement(): def announcement():
from_address = '{}@{}'.format( from_address = '{}@{}'.format(
flask_app.config['POSTMASTER'], flask_app.config['DOMAIN']) app.config['POSTMASTER'], app.config['DOMAIN'])
form = forms.AnnouncementForm() form = forms.AnnouncementForm()
if form.validate_on_submit(): if form.validate_on_submit():
with smtplib.SMTP('smtp') as smtp: with smtplib.SMTP('smtp') as smtp:

@ -1,5 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
from mailu import app as flask_app
import flask import flask
import wtforms_components import wtforms_components
@ -63,7 +62,7 @@ def domain_delete(domain_name):
def domain_details(domain_name): def domain_details(domain_name):
domain = models.Domain.query.get(domain_name) or flask.abort(404) domain = models.Domain.query.get(domain_name) or flask.abort(404)
return flask.render_template('domain/details.html', domain=domain, return flask.render_template('domain/details.html', domain=domain,
config=flask_app.config) config=app.config)
@app.route('/domain/genkeys/<domain_name>', methods=['GET', 'POST']) @app.route('/domain/genkeys/<domain_name>', methods=['GET', 'POST'])

@ -1,4 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
import flask import flask
import flask_login import flask_login

@ -1,4 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
import flask import flask
import flask_login import flask_login

@ -1,5 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
from mailu import app as flask_app
import flask import flask
import wtforms_components import wtforms_components

@ -1,4 +1,4 @@
from mailu.admin import app, db, models, forms, access from mailu import app, db, models, forms, access
import flask import flask
import flask_login import flask_login

@ -1,5 +1,4 @@
from mailu import app, manager, db from mailu import app, manager, db, models
from mailu.admin import models
@manager.command @manager.command

Loading…
Cancel
Save