{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% load crispy_forms_tags %}
{% load socialaccount %}

{% block title %}User: {{ object.username }}{% endblock %}

{% block content %}
<div class="container">
<h2>Profile</h2>
<div class="row">
  <div class="col-md-6">
    <img src="{{ user.image.profile.url }}" alt="Profile image"/>
    <p>{{ user.username }}</p>
    <p>{{ user.name }}</p>
    <p>{{ user.email }}</p>
    <p>Last login {{ user.last_login}}</p>
    {% if blurb.description %}
      <p>Description: {{ blurb.description }}</p>
    {% endif %}
    {% if blurb.skills %}
      <p>Skills: {{ blurb.skills }}</p>
    {% endif %}

    {% if membership %}
      <h3>Membership status</h3>
      <p>Member since {{membership.date}}</p>
      <p>Membership Status: {{ membership.get_status }}</p>
      <p>Last Payment: {{membership.date}}</p>
      <p>Amount: &pound;{{membership.payment}}</p>
    {% else %}
      You are not currently a member consider signing up.
    {% endif %}
  </div>
  <div class="col-md-6">
    {% if membership.get_status %}
      <div id="membercard" class="registered">
        <div class="date">Joined {{membership.date}}</div>
        <div class="container">
          <div class="middle">
            <p>MHS{{ user.id|stringformat:"05d" }}</p><p>{{user.name}}{{user.last_name}}</p>
          </div>
          <a href="{% url 'cancel_membership' %}">Cancel Membership</a>
        </div>
      </div>
    {% else %}
      <div>
        <h2>Sign up below</h2>
        <form method="POST" action="{% url 'join_hackspace' %}" class="contact_us_form">
          {% csrf_token %}
          {{ membership_form|crispy }}
          <button class="btn btn-primary" type="submit" name="action">{% trans "Send" %}</button>
        </form>
      </div>
    {% endif %}
  </div>
</div>

  <div class="row">
    <div class="col-sm-12">

      <h2>{{ object.username }}</h2>
      {% if object.name %}
        <p>{{ object.name }}</p>
      {% endif %}
    </div>
  </div>

{% if object == request.user %}
<!-- Action buttons -->
<div class="row">

  <div class="col-sm-12">
    <p>
    <a class="btn btn-primary" href="{% url 'users:update' %}" role="button">My Info</a>
    <a class="btn btn-primary" href="{% url 'users:access_cards' %}" role="button">My Rfid Cards</a>
    <a class="btn btn-primary" href="{% url 'account_email' %}" role="button">E-Mail</a>
    </p>
    <!-- Your Stuff: Custom user template urls -->
  </div>
</div>

<div class="row">
  <div class="col-sm-12">
    <p>
      <a class="btn btn-primary" href="{% provider_login_url "google" process="connect" %}">Link your Google account</a>
    </p>
  </div>
</div>
<div class="row">
  <div class="col-sm-12">
    <p>
    <a class="btn btn-primary" href="{% provider_login_url "github" process="connect" %}">Link your Github account</a>
    </p>
  </div>
</div>
<!-- End Action buttons -->
{% endif %}


</div>
{% endblock content %}

