Beispiel #1
0
def invite():
    if request.method == "POST":
        if 'cancel' in request.form:
            return redirect(url_front())

        email_addresses = request.form['email']
        for email_address in email_addresses.splitlines():
            key = generate_key()
            url = config.URL + url_for("usermanager.new", key=key)
            text = invite_mail.format(url=url)

            data.execute(
                "UPDATE User_creation_keys SET email = ? WHERE key = ?",
                email_address, key)

            mail.send(email_address, "Invitation til GRIS", text)
        flash("Invitationer sendt")

        message = mail.invitation_send_adminmail.format(
            email=request.form['email'])
        mail.admin("User Invited", message)

        return redirect(url_for("usermanager.overview"))

    else:
        w = html.WebBuilder()
        w.form()
        w.formtable()
        w.textarea("email", "Emails (1 pr. linje)")
        form = w.create()
        return render_template("form.html", form=form)
Beispiel #2
0
def invite():
    if request.method == "POST":
        if 'cancel' in request.form:
            return redirect(url_front())

        email_addresses = request.form['email']
        for email_address in email_addresses.splitlines():
            key = generate_key()
            url = config.URL + url_for("usermanager.new", key=key)
            text = invite_mail.format(url=url)

            data.execute("UPDATE User_creation_keys SET email = ? WHERE key = ?", email_address, key)

            mail.send(email_address, "Invitation til GRIS", text)
        flash("Invitationer sendt")


        message = mail.invitation_send_adminmail.format(email=request.form['email'])
        mail.admin("User Invited", message)

        return redirect(url_for("usermanager.overview"))

    else:
        w = html.WebBuilder()
        w.form()
        w.formtable()
        w.textarea("email", "Emails (1 pr. linje)")
        form = w.create()
        return render_template("form.html", form=form)
Beispiel #3
0
def create_user(username, raw_password, name="", email="", groups=[]):
    b = data.Bucket()
    b.username = username
    b.password = password.encode(raw_password)
    b.name = name
    b.email = email
    b >= "Users"
    set_user_groups(username, groups)

    message = mail.new_user_adminmail.format(username=b.username, name=b.name, email=b.email)
    mail.admin("User Created", message)
Beispiel #4
0
def create_user(username, raw_password, name="", email="", groups=[]):
    b = data.Bucket()
    b.username = username
    b.password = password.encode(raw_password)
    b.name = name
    b.email = email
    b >= "Users"
    set_user_groups(username, groups)

    message = mail.new_user_adminmail.format(username=b.username,
                                             name=b.name,
                                             email=b.email)
    mail.admin("User Created", message)
Beispiel #5
0
def error(code):
    log.log("An error occured on \"{0}\" reason: {1}".format(request.path, repr(code)), "ERROR 500")
    try:
        username = session['username']
    except:
        username = "******"
    try:
        ip = flask.request.environ["REMOTE_ADDR"]
    except:
        ip = "UNKNOWN IP"

    text = mail.error_adminmail.format(username=username, time=now(), ip=ip, url = request.path, code=repr(code))
    mail.admin("ERROR", text, type="html", mail_admins=True)
    return (render_template("error/500.html"), 500)
Beispiel #6
0
def goodbye():
    print("bye")
    if config.MAIL_ON_EXIT:
        mail.admin("GRIS shutdown", "GRIS has exited at {0}\nThis could either be caused by an error or by a restart.".format(now()))