Announcement to all users, fixes #16

master
Pierre Jaury 8 years ago
parent 8c32971ec4
commit c3b9756000

@ -119,3 +119,11 @@ class FetchForm(flask_wtf.FlaskForm):
username = fields.StringField(_('Username'))
password = fields.StringField(_('Password'))
submit = fields.SubmitField(_('Submit'))
class AnnouncementForm(flask_wtf.FlaskForm):
announcement_subject = fields.StringField(_('Announcement subject'),
[validators.DataRequired()])
announcement_body = fields.StringField(_('Announcement body'),
[validators.DataRequired()], widget=widgets.TextArea())
submit = fields.SubmitField(_('Send'))

@ -0,0 +1,18 @@
{% extends "base.html" %}
{% block title %}
{% trans %}Public announcement{% endtrans %}
{% endblock %}
{% block subtitle %}
{% trans %}from{% endtrans %} {{ from_address }}
{% endblock %}
{% block box_content %}
<form class="form" method="post" role="form">
{{ form.hidden_tag() }}
{{ macros.form_field(form.announcement_subject) }}
{{ macros.form_field(form.announcement_body, rows=10) }}
{{ macros.form_field(form.submit) }}
</form>
{% endblock %}

@ -40,6 +40,11 @@
<i class="fa fa-dashboard"></i> <span>{% trans %}Services status{% endtrans %}</span>
</a>
</li>
<li>
<a href="{{ url_for('.announcement') }}">
<i class="fa fa-bullhorn"></i> <span>{% trans %}Announcement{% endtrans %}</span>
</a>
</li>
<li>
<a href="{{ url_for('.admin_list') }}">
<i class="fa fa-user"></i> <span>{% trans %}Administrators{% endtrans %}</span>

@ -1,8 +1,11 @@
from mailu import dockercli
from mailu import dockercli, app as flask_app
from mailu.admin import app, db, models, forms, access
import flask
import flask_login
import smtplib
from email.mime import text
@app.route('/', methods=["GET"])
@ -39,3 +42,25 @@ def services():
except Exception as error:
return flask.render_template('docker-error.html', error=error)
return flask.render_template('services.html', containers=containers)
@app.route('/announcement', methods=['GET', 'POST'])
@access.global_admin
def announcement():
from_address = '{}@{}'.format(
flask_app.config['POSTMASTER'], flask_app.config['DOMAIN'])
form = forms.AnnouncementForm()
if form.validate_on_submit():
with smtplib.SMTP('smtp') as smtp:
for recipient in [user.email for user in models.User.query.all()]:
msg = text.MIMEText(form.announcement_body.data)
msg['Subject'] = form.announcement_subject.data
msg['From'] = from_address
msg['To'] = recipient
smtp.sendmail(from_address, [recipient], msg.as_string())
# Force-empty the form
form.announcement_subject.data = ''
form.announcement_body.data = ''
flask.flash('Your announcement was sent', 'success')
return flask.render_template('announcement.html', form=form,
from_address=from_address)

@ -7,17 +7,16 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: stefan.auditor@erdfisch.de\n"
"POT-Creation-Date: 2016-11-09 19:59+0100\n"
"POT-Creation-Date: 2016-11-10 10:47+0100\n"
"PO-Revision-Date: 2016-11-09 21:43+0100\n"
"Last-Translator: Stefan Auditor <stefan.auditor@erdfisch.de>\n"
"Language: de\n"
"Language-Team: Mailu German Team <stefan.auditor@erdfisch.de>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.3.4\n"
"X-Generator: Poedit 1.8.11\n"
"Last-Translator: Stefan Auditor <stefan.auditor@erdfisch.de>\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: de\n"
#: mailu/admin/forms.py:32
msgid "Invalid email address."
@ -173,6 +172,26 @@ msgstr "TLS aktivieren"
msgid "Username"
msgstr "Benutzername"
#: mailu/admin/forms.py:125
msgid "Announcement subject"
msgstr ""
#: mailu/admin/forms.py:127
msgid "Announcement body"
msgstr ""
#: mailu/admin/forms.py:129
msgid "Send"
msgstr ""
#: mailu/admin/templates/announcement.html:4
msgid "Public announcement"
msgstr ""
#: mailu/admin/templates/announcement.html:8
msgid "from"
msgstr ""
#: mailu/admin/templates/confirm.html:4
msgid "Confirm action"
msgstr "Aktion bestätigen"
@ -188,7 +207,9 @@ msgstr "Docker Fehler"
#: mailu/admin/templates/docker-error.html:12
msgid "An error occurred while talking to the Docker server."
msgstr "Während der Kommunikation mit dem Docker Server ist ein Fehler ist aufgetreten."
msgstr ""
"Während der Kommunikation mit dem Docker Server ist ein Fehler ist "
"aufgetreten."
#: mailu/admin/templates/login.html:6
msgid "Your account"
@ -257,14 +278,18 @@ msgid "Administration"
msgstr "Administration"
#: mailu/admin/templates/sidebar.html:45
msgid "Announcement"
msgstr ""
#: mailu/admin/templates/sidebar.html:50
msgid "Administrators"
msgstr "Administratoren"
#: mailu/admin/templates/sidebar.html:52
#: mailu/admin/templates/sidebar.html:57
msgid "Mail domains"
msgstr "E-Mail-Domains"
#: mailu/admin/templates/sidebar.html:59
#: mailu/admin/templates/sidebar.html:64
msgid "Help"
msgstr "Hilfe"
@ -440,3 +465,4 @@ msgstr "Manager Liste"
#: mailu/admin/templates/manager/list.html:12
msgid "Add manager"
msgstr "Manager hinzufügen"

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2016-10-29 13:37+0200\n"
"POT-Creation-Date: 2016-11-10 10:47+0100\n"
"PO-Revision-Date: 2016-10-02 15:02+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
@ -172,6 +172,26 @@ msgstr ""
msgid "Username"
msgstr ""
#: mailu/admin/forms.py:125
msgid "Announcement subject"
msgstr ""
#: mailu/admin/forms.py:127
msgid "Announcement body"
msgstr ""
#: mailu/admin/forms.py:129
msgid "Send"
msgstr ""
#: mailu/admin/templates/announcement.html:4
msgid "Public announcement"
msgstr ""
#: mailu/admin/templates/announcement.html:8
msgid "from"
msgstr ""
#: mailu/admin/templates/confirm.html:4
msgid "Confirm action"
msgstr ""
@ -256,14 +276,18 @@ msgid "Administration"
msgstr ""
#: mailu/admin/templates/sidebar.html:45
msgid "Announcement"
msgstr ""
#: mailu/admin/templates/sidebar.html:50
msgid "Administrators"
msgstr ""
#: mailu/admin/templates/sidebar.html:52
#: mailu/admin/templates/sidebar.html:57
msgid "Mail domains"
msgstr ""
#: mailu/admin/templates/sidebar.html:59
#: mailu/admin/templates/sidebar.html:64
msgid "Help"
msgstr ""

@ -1,11 +1,18 @@
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: POEditor.com\n"
"Project-Id-Version: Mailu\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2016-11-10 10:47+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n"
"Language-Team: fr <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n > 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.3.4\n"
#: mailu/admin/forms.py:32
msgid "Invalid email address."
@ -161,11 +168,32 @@ msgstr "Activer TLS"
msgid "Username"
msgstr "Nom d'utilisateur"
#: mailu/admin/forms.py:125
msgid "Announcement subject"
msgstr ""
#: mailu/admin/forms.py:127
msgid "Announcement body"
msgstr ""
#: mailu/admin/forms.py:129
msgid "Send"
msgstr ""
#: mailu/admin/templates/announcement.html:4
msgid "Public announcement"
msgstr ""
#: mailu/admin/templates/announcement.html:8
msgid "from"
msgstr ""
#: mailu/admin/templates/confirm.html:4
msgid "Confirm action"
msgstr "Confirmer"
#: mailu/admin/templates/confirm.html:12
#, python-format
msgid "You are about to %(action)s. Please confirm your action."
msgstr "Vous allez %(action)s. Merci de confirmer votre action."
@ -244,14 +272,18 @@ msgid "Administration"
msgstr "Administration"
#: mailu/admin/templates/sidebar.html:45
msgid "Announcement"
msgstr ""
#: mailu/admin/templates/sidebar.html:50
msgid "Administrators"
msgstr "Administrateurs"
#: mailu/admin/templates/sidebar.html:52
#: mailu/admin/templates/sidebar.html:57
msgid "Mail domains"
msgstr "Domaines"
#: mailu/admin/templates/sidebar.html:59
#: mailu/admin/templates/sidebar.html:64
msgid "Help"
msgstr "Aide"

Loading…
Cancel
Save