{% extends 'base.html' %}

{% block title %}RIGS Profile {{object.pk}}{% endblock %}

{% block content %}
<div class="col-md-10 col-md-offset-1">
	
	<div class="col-sm-12">
	
	<div class="col-sm-6">
		<h3>{{object.name}}</h3>
	</div>
	{% if object.pk == user.pk %}
	<div class="col-sm-6 text-right">
	    <div class="btn-group btn-page">
	        <a href="{% url 'profile_update_self' %}" class="btn btn-default">
				Edit Profile <span class="glyphicon glyphicon-pencil"></span>
			</a>
			<a href="{% url 'password_change' %}" class="btn btn-default">
				Change Password <span class="glyphicon glyphicon-lock"></span>
			</a>
	    </div>
	</div>
	{% endif %}
	<div class="col-sm-8	">
		<dl class="dl-horizontal">
			<dt>First Name</dt>
			<dd>{{object.first_name}}</dd>

			<dt>Last Name</dt>
			<dd>{{object.last_name}}</dd>

			<dt>Email</dt>
			<dd>{{object.email}}</dd>

			<dt>Last Login</dt>
			<dd>{{object.last_login}}</dd>

			<dt>Date Joined</dt>
			<dd>{{object.date_joined}}</dd>

			<dt>Initials</dt>
			<dd>{{object.initials}}</dd>

			<dt>Phone</dt>
			<dd>{{object.phone}}</dd>
		</dl>
		{% if object.pk == user.pk %}
		
		<div class="pull-right">
			<a href="{% url 'reset_api_key' %}" class="btn">
				{% if user.api_key %}Reset API Key{% else %}Generate API Key{% endif %}
				<span class="glyphicon glyphicon-repeat"></span>
			</a>
		</div>
	
		<h4>Personal iCal Details</h4>

		<dl class="dl-horizontal">
			<dt>API Key</dt>
			<dd>
				{% if user.api_key %}
					{{user.api_key}}
				{% else %}
					No API Key Generated
				{% endif %}
			</dd>

			<dt>Calendar URL</dt>
			<dd>
				{% if user.api_key %}
					<pre>http{{ request.is_secure|yesno:"s,"}}://{{ request.get_host }}{% url 'ics_calendar' api_pk=user.pk api_key=user.api_key %}</pre>
				{% else %}
					<pre>No API Key Generated</pre>
				{% endif %}
			</dd>
		</dl>

		{% endif %}
	</div>
	
	<div class="col-sm-3">
		<div class="center-block">
			<img src="{{object.profile_picture}}" class="img-responsive img-rounded" />
	</div>

</div>
{% endblock %}