{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}

{% block title %}Change Rower {% endblock %}

{% block main %}
<h1>User Settings for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>

<p><a href="http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/">Need help? Click to read the tutorial</a></p>

<ul class="main-content">
  <li class="grid_2">
    <h2>Account Information</h2>
    <p>
      {% if rower.user == user %}
      <a href="/password_change/">Password Change</a>
      {% else %}
      &nbsp;
      {% endif %}
    </p>
    <p>
      Login <em>{{ rower.user }}</em>
      </p>
    {% if userform.errors %}
    <p style="color: red;">
      Please correct the error{{ form.errors|pluralize }} below.
    </p>
    {% endif %}
    {% if accountform.errors %}
    <p style="color: red;">

    </p>
    {% endif %}
    <form enctype="multipart/form-data" action="" method="post">
      <table>
        {{ userform.as_table }}
        {{ accountform.as_table }}
        <tr>
          <th>&nbsp;</th><td></td>
        </tr>
        <tr>
          <th>Plan</th><td>{{ rower.paidplan.name }}</td>
        </tr>
        {% if rower.rowerplan != 'basic' %}
        <tr>
          <th>
            {% if rower.paymenttype != 'recurring' %}
            Plan Expiry
            {% else %}
            Next Payment Due
            {% endif %}
          </th><td>{{ rower.planexpires }}</td>
        </tr>
        {% endif %}
      </table>
      {% csrf_token %}
      {% if rower.rowerplan != 'coach' and rower.user == user %}
      <p>
        <a href="/rowers/paidplans/">Upgrade</a>
      </p>
      {% else %}
      <p>
        &nbsp;
      </p>
      {% endif %}
      {% if rower.rowerplan != 'basic' and rower.user == user %}
      <p>
        <a href="/rowers/me/cancelsubscriptions/">Cancel Subscription</a>
      </p>
      {% endif %}
      <input type="submit" value="Save">
    </form>
  </li>
  {% if rower.user == user %}
  <li class="grid_2">
    <h2>GDPR - Data Protection</h2>
    <p>
      <a href="/rowers/exportallworkouts/">Download your data</a>
    </p>
    <p>
      <a href="/rowers/me/deactivate/">Deactivate Account</a>
    </p>
    <p>
      <a class="button red small" href="/rowers/me/delete/">Delete Account</a>
    </p>
  </li>
  <li class="grid_2">
    {% if grants %}
    <h2>Applications</h2>
    <table width="100%">
      <thead>
        <tr>
          <th>Application</th>
          <th>Scope</th>
          <th>Revoke</th>
        </tr>
      </thead>
      <tbody>
        {% for grant in grants %}
        <tr>
          <td>{{ grant.application }}</td>
          <td>{{ grant.scope }}</td>
          <td>
            <a href="/rowers/me/revokeapp/{{ grant.application.id }}/">Revoke</a>
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
    {% endif %}
  </li>
</ul>
{% endif %}



{% endblock %}

{% block sidebar %}
{% include 'menu_profile.html' %}
{% endblock %}
