コード例 #1
0
def contact():
    form = AnonymousContactForm()

    if form.validate_on_submit():
        from_mail = form.email.data
        subject = "[Kontakt] {}".format(form.subject.data)
        message = "Name: {0}\n\n{1}".format(form.name.data, form.message.data)
        dormitory = dormitory_from_name(form.dormitory.data)
        support_mail = dormitory.datasource.support_mail

        if send_mail(from_mail, support_mail, subject, message):
            flash(gettext("Nachricht wurde versandt."), "success")
        else:
            flash(gettext("Es gab einen Fehler beim Versenden der Nachricht."),
                  'error')
        return redirect(url_for(".index"))
    elif form.is_submitted():
        flash_formerrors(form)
    elif current_user.is_authenticated:
        flash(
            gettext("Sicher, dass Du das anonyme Formular "
                    "benutzen möchtest? Dies ist nur erforderlich, wenn Du "
                    "Administratoren eines anderen Wohnheims "
                    "kontaktieren willst."), 'info')

    return render_template('anonymous_contact.html', form=form)
コード例 #2
0
ファイル: generic.py プロジェクト: gwTumm/sipa
def contact():
    form = AnonymousContactForm()

    if form.validate_on_submit():
        from_mail = form.email.data
        subject = "[Kontakt] {}".format(form.subject.data)
        message = "Name: {0}\n\n{1}".format(form.name.data, form.message.data)
        dormitory = dormitory_from_name(form.dormitory.data)
        support_mail = dormitory.datasource.support_mail

        if send_mail(from_mail, support_mail, subject, message):
            flash(gettext("Nachricht wurde versandt."), "success")
        else:
            flash(gettext("Es gab einen Fehler beim Versenden der Nachricht."),
                  'error')
        return redirect(url_for(".index"))
    elif form.is_submitted():
        flash_formerrors(form)
    elif current_user.is_authenticated:
        flash(gettext("Sicher, dass Du das anonyme Formular "
                      "benutzen möchtest? Dies ist nur erforderlich, wenn Du "
                      "Administratoren eines anderen Wohnheims "
                      "kontaktieren willst."), 'info')

    return render_template('anonymous_contact.html', form=form)
コード例 #3
0
ファイル: usersuite.py プロジェクト: MarauderXtreme/sipa
def usersuite_change_mac():
    """As user, change the MAC address of your device.
    """
    form = ChangeMACForm()
    userinfo = current_user.get_information()

    if form.validate_on_submit():
        password = form.password.data
        mac = form.mac.data

        try:
            current_user.re_authenticate(password)

        except PasswordInvalid:
            flash(gettext("Passwort war inkorrekt!"), "error")
        else:
            current_user.change_mac_address(userinfo['mac']['value'], mac)
            logger.info('Successfully changed MAC address',
                        extra={'data': {'mac': mac}})

            flash(gettext("MAC-Adresse wurde geändert!"), 'success')

            from_mail = "{}@{}".format(current_user.uid,
                                       current_datasource().mail_server)
            support_mail = current_datasource().support_mail

            subject = ("[Usersuite] {} hat seine/ihre MAC-Adresse "
                       "geändert".format(current_user.uid))
            message = (
                "Nutzer {name} ({uid}) hat seine/ihre MAC-Adresse geändert."
                "\nAlte MAC: {old_mac}\nNeue MAC: {new_mac}".format(
                    name=current_user.name,
                    uid=current_user.uid,
                    old_mac=userinfo['mac']['value'],
                    new_mac=mac
                )
            )

            if not send_mail(from_mail, support_mail, subject, message):
                logger.error("Mac notification mail could not be sent")

            return redirect(url_for('.usersuite'))
    elif form.is_submitted():
        flash_formerrors(form)

    form.mac.default = userinfo['mac']['value']

    return render_template('usersuite/change_mac.html', form=form)
コード例 #4
0
ファイル: generic.py プロジェクト: MarauderXtreme/sipa
def contact():
    form = AnonymousContactForm()

    if form.validate_on_submit():
        from_mail = form.email.data
        subject = "[Kontakt] {}".format(form.subject.data)
        message = form.message.data
        dormitory = dormitory_from_name(form.dormitory.data)
        support_mail = dormitory.datasource.support_mail

        if send_mail(from_mail, support_mail, subject, message):
            flash(gettext("Nachricht wurde versandt."), "success")
        else:
            flash(gettext("Es gab einen Fehler beim Versenden der Nachricht."),
                  'error')
        return redirect(url_for(".index"))
    elif form.is_submitted():
        flash_formerrors(form)

    return render_template('anonymous_contact.html', form=form)
コード例 #5
0
ファイル: usersuite.py プロジェクト: gwTumm/sipa
def usersuite_contact():
    """Contact form for logged in users.
    Currently sends an e-mail to the support mailing list as
    '[Usersuite] Category: Subject' with userid and message.
    """
    form = ContactForm()

    support_mail = current_datasource().support_mail
    from_mail = "{}@{}".format(current_user.uid,
                               current_datasource().mail_server)

    if form.validate_on_submit():
        types = {
            'stoerung': "Störung",
            'finanzen': "Finanzen",
            'eigene-technik': "Eigene Technik"
        }

        cat = types.get(form.type.data, "Allgemein")

        subject = "[Usersuite] {0}: {1}".format(cat, form.subject.data)

        message_text = "Nutzerlogin: {0}\n\n{1}".format(current_user.uid,
                                                        form.message.data)

        if send_mail(from_mail, support_mail, subject, message_text):
            flash(gettext("Nachricht wurde versandt."), "success")
        else:
            flash(gettext("Es gab einen Fehler beim Versenden der Nachricht. "
                          "Bitte schicke uns direkt eine E-Mail an {}".format(
                              support_mail)),
                  'error')
        return redirect(url_for(".usersuite"))
    elif form.is_submitted():
        flash_formerrors(form)

    form.email.default = from_mail

    return render_template("usersuite/contact.html", form=form)
コード例 #6
0
def usersuite_contact():
    """Contact form for logged in users.
    Currently sends an e-mail to the support mailing list as
    '[Usersuite] Category: Subject' with userid and message.
    """
    form = ContactForm()

    support_mail = current_datasource().support_mail
    from_mail = "{}@{}".format(current_user.uid,
                               current_datasource().mail_server)

    if form.validate_on_submit():
        types = {
            'stoerung': "Störung",
            'finanzen': "Finanzen",
            'eigene-technik': "Eigene Technik"
        }

        cat = types.get(form.type.data, "Allgemein")

        subject = "[Usersuite] {0}: {1}".format(cat, form.subject.data)

        message_text = "Nutzerlogin: {0}\n\n".format(current_user.uid) \
                       + form.message.data

        if send_mail(from_mail, support_mail, subject, message_text):
            flash(gettext("Nachricht wurde versandt."), "success")
        else:
            flash(
                gettext("Es gab einen Fehler beim Versenden der Nachricht. "
                        "Bitte schicke uns direkt eine E-Mail an {}".format(
                            support_mail)), 'error')
        return redirect(url_for(".usersuite"))
    elif form.is_submitted():
        flash_formerrors(form)

    form.email.default = from_mail

    return render_template("usersuite/contact.html", form=form)