{% extends "base.html" %}

{% load crispy_forms_tags %}
{% load handletags %}

{% block content %}
<div class="row">
	<div class="col-sm-12">
		<div class="panel panel-default">
			<div class="panel-heading">Whois Database Objects</div>
			<div class="panel-body">
				{% if mnts %}
				<p>
				You can create new database objects <a href="{% url "whoisdb:createObjectOverview" %}">here</a>.
				{% if hasDelegations %}
				See <a href="?delegated=1">also delegated objects</a>.
				{% endif %}
				</p>

				</p>
				Create <a href="{% url "whoisdb:maintainer-create" %}">new Maintainer</a>, create <a href="{% url "whoisdb:contact-create" %}">new Contact</a>, <a href="{% url "rrequests:dashboard" %}">request resources</a>{% if netblocks %}, create <a href="{% url "whoisdb:inetnum-create" %}">Subnet</a>{% endif %}{% if asblocks %}, create <a href="{% url "whoisdb:asnumber-create" %}">AS</a>, create <a href="{% url "whoisdb:asblock-create" %}">ASblock</a>{% endif %}{% if netblocks and asblocks %}, create <a href="{% url "whoisdb:asandsubnet-wizard" %}">AS / Subnet pair</a>{% endif %}
				</p>
				<!--
				<h3>Create Database Objects</h3>
				<ul>
					<li><a href="{% url "whoisdb:maintainer-create" %}">Create new Maintainer</a></li>
					<li><a href="{% url "whoisdb:contact-create" %}">Create new Role/Person</a></li>
					<li><a href="{% url "rrequests:dashboard" %}">Request resources</a></li>
					{% if netblocks %}
					<li><a href="{% url "whoisdb:inetnum-create" %}">Create Subnet</a></li>
					{% endif %}
					{% if asblocks %}
					<li><a href="{% url "whoisdb:asnumber-create" %}">Create AS</a></li>
					<li><a href="{% url "whoisdb:asblock-create" %}">Create ASblock</a></li>
					{% endif %}
				</ul>

				<h3>Your Database Objects</h3>
				-->
				<table class="table">
					<thead>
							<tr>
								<th>Handle</th>
								<th>Type</th>
								<th>Name</th>
								<th>Resource</th>
								<th>Maintained</th>
								<th>Contact</th>
								<th>Actions</th>
							</tr>
						</thead>
						<tbody>
							{% for mnt in mnts %}
								{% include "whoisdb/handle_table_row.html" with obj=mnt objType="Maintainer" prefix="maintainer" %}
							{% endfor %}
							{% for contact in contacts %}
								{% include "whoisdb/handle_table_row.html" with obj=contact objType="Contact / Role" prefix="contact" %}
							{% endfor %}
							{% for asblock in asblocks %}
								{% include "whoisdb/handle_table_row.html" with obj=asblock objType="AS Block" prefix="asblock" %}
							{% endfor %}
							{% for asnumber in asnumbers %}
								{% include "whoisdb/handle_table_row.html" with obj=asnumber objType="AS Number" prefix="asnumber" %}
							{% endfor %}
							{% for netblock in netblocks %}
								{% include "whoisdb/handle_table_row.html" with obj=netblock objType="IP Netblock" prefix="inetnum" %}
							{% endfor %}
						</tbody>
					</table>

					{% else %}
					You don't have a maintainer! Start by creating a Maintainer and a Person Object!

				<form action="{% url "whoisdb:dashboard" %}" method="post">
					{% csrf_token %}
					<h3>Maintainer Object</h3>
					<small>This object will be used to identify resources you are allowed
					to edit via your maintainer</small>
					{{ mntForm | crispy }}

					<h3>Person Object</h3>
					<small>This object will be used to identify yourself as a person to other people, used for your maintainer object</small>
					{{ contactForm | crispy }}

					<button type="submit" class="btn btn-primary">Create</button>
				</form>
				{% endif %}
			</div>
		</div>
	</div>
</div>
{% endblock %}