|
|
@ -1,5 +1,6 @@
|
|
|
|
from mailu import models, utils
|
|
|
|
from mailu import models, utils
|
|
|
|
from mailu.ui import ui, forms, access
|
|
|
|
from mailu.ui import ui, forms, access
|
|
|
|
|
|
|
|
from flask import current_app as app
|
|
|
|
|
|
|
|
|
|
|
|
import flask
|
|
|
|
import flask
|
|
|
|
import flask_login
|
|
|
|
import flask_login
|
|
|
@ -10,6 +11,8 @@ import wtforms
|
|
|
|
@ui.route('/fetch/list/<path:user_email>', methods=['GET'])
|
|
|
|
@ui.route('/fetch/list/<path:user_email>', methods=['GET'])
|
|
|
|
@access.owner(models.User, 'user_email')
|
|
|
|
@access.owner(models.User, 'user_email')
|
|
|
|
def fetch_list(user_email):
|
|
|
|
def fetch_list(user_email):
|
|
|
|
|
|
|
|
if not app.config['FETCHMAIL_ENABLED']:
|
|
|
|
|
|
|
|
flask.abort(404)
|
|
|
|
user_email = user_email or flask_login.current_user.email
|
|
|
|
user_email = user_email or flask_login.current_user.email
|
|
|
|
user = models.User.query.get(user_email) or flask.abort(404)
|
|
|
|
user = models.User.query.get(user_email) or flask.abort(404)
|
|
|
|
return flask.render_template('fetch/list.html', user=user)
|
|
|
|
return flask.render_template('fetch/list.html', user=user)
|
|
|
@ -19,6 +22,8 @@ def fetch_list(user_email):
|
|
|
|
@ui.route('/fetch/create/<path:user_email>', methods=['GET', 'POST'])
|
|
|
|
@ui.route('/fetch/create/<path:user_email>', methods=['GET', 'POST'])
|
|
|
|
@access.owner(models.User, 'user_email')
|
|
|
|
@access.owner(models.User, 'user_email')
|
|
|
|
def fetch_create(user_email):
|
|
|
|
def fetch_create(user_email):
|
|
|
|
|
|
|
|
if not app.config['FETCHMAIL_ENABLED']:
|
|
|
|
|
|
|
|
flask.abort(404)
|
|
|
|
user_email = user_email or flask_login.current_user.email
|
|
|
|
user_email = user_email or flask_login.current_user.email
|
|
|
|
user = models.User.query.get(user_email) or flask.abort(404)
|
|
|
|
user = models.User.query.get(user_email) or flask.abort(404)
|
|
|
|
form = forms.FetchForm()
|
|
|
|
form = forms.FetchForm()
|
|
|
@ -40,6 +45,8 @@ def fetch_create(user_email):
|
|
|
|
@ui.route('/fetch/edit/<fetch_id>', methods=['GET', 'POST'])
|
|
|
|
@ui.route('/fetch/edit/<fetch_id>', methods=['GET', 'POST'])
|
|
|
|
@access.owner(models.Fetch, 'fetch_id')
|
|
|
|
@access.owner(models.Fetch, 'fetch_id')
|
|
|
|
def fetch_edit(fetch_id):
|
|
|
|
def fetch_edit(fetch_id):
|
|
|
|
|
|
|
|
if not app.config['FETCHMAIL_ENABLED']:
|
|
|
|
|
|
|
|
flask.abort(404)
|
|
|
|
fetch = models.Fetch.query.get(fetch_id) or flask.abort(404)
|
|
|
|
fetch = models.Fetch.query.get(fetch_id) or flask.abort(404)
|
|
|
|
form = forms.FetchForm(obj=fetch)
|
|
|
|
form = forms.FetchForm(obj=fetch)
|
|
|
|
utils.formatCSVField(form.folders)
|
|
|
|
utils.formatCSVField(form.folders)
|
|
|
@ -61,6 +68,8 @@ def fetch_edit(fetch_id):
|
|
|
|
@access.confirmation_required("delete a fetched account")
|
|
|
|
@access.confirmation_required("delete a fetched account")
|
|
|
|
@access.owner(models.Fetch, 'fetch_id')
|
|
|
|
@access.owner(models.Fetch, 'fetch_id')
|
|
|
|
def fetch_delete(fetch_id):
|
|
|
|
def fetch_delete(fetch_id):
|
|
|
|
|
|
|
|
if not app.config['FETCHMAIL_ENABLED']:
|
|
|
|
|
|
|
|
flask.abort(404)
|
|
|
|
fetch = models.Fetch.query.get(fetch_id) or flask.abort(404)
|
|
|
|
fetch = models.Fetch.query.get(fetch_id) or flask.abort(404)
|
|
|
|
user = fetch.user
|
|
|
|
user = fetch.user
|
|
|
|
models.db.session.delete(fetch)
|
|
|
|
models.db.session.delete(fetch)
|
|
|
|