<!DOCTYPE html>
{% from "pyfarm/macros.html" import render_field %}
<html>
    <head>
        {% if finished %}
            <meta http-equiv="refresh" content="{{redirect_seconds}};/">
        {% endif %}

        <title>PyFarm - Setup</title>
        <link href="{{ url_for('static', filename='css/layout.css') }}" rel="stylesheet">
        <link href="{{ url_for('static', filename='css/headings.css') }}" rel="stylesheet">
        <link href="{{ url_for('static', filename='css/setup.css') }}" rel="stylesheet">
    </head>
    <body>
        <h3>PyFarm Setup</h3>
        <div class="subtext">
            {% if error %}
                There was a problem while attempting to perform your
                request: {{error}}

            {% elif finished %}
                The setup has been completed!  Redirecting to the
                <a href="/">index</a> in {{redirect_seconds}} seconds.

            {% elif not admin_role or not admin_users %}
                <p>
                    Hello and welcome to PyFarm's initial setup!  Before you
                    start using PyFarm you'll need to create an Administrator
                    account.
                </p>

                <form method="POST" action="/setup/" class="form-horizontal">
                    <fieldset>
                        {{ render_field(form.username) }}
                        {{ render_field(form.email) }}
                        {{ render_field(form.password) }}

                        <div class="controls">
                            <input type="submit" class="btn btn-primary btn-large" value="Submit">
                            <a href="/setup/" class="btn btn-large">Cancel</a>
                        </div>
                    </fieldset>
                </form>

                <p>
                    <b>Security Note:</b>
                    The account you are creating will have full control over
                    PyFarm.  It is recommended you use this account for user
                    administration and create other roles for the various parts
                    of PyFarm.
                </p>


            {% elif admin_users %}
                Looks like everything is ready to go!  The database has already
                been setup and you have some existing administrators:
                <ul>
                    {% for user in admin_users %}
                        <li>{{user.username}} ({{user.email or "No email provided"}})</li>
                    {% endfor %}
                </ul>
            {% endif %}
        </div>
    </body>
</html>