{% load cvtags %}

{% if total_grants or user.is_authenticated %}
<h2 class="col-xs-12">Grant{{total_grants|pluralize}}</h2>
{% if internal_grants %}
<h3 class="col-xs-12">Internal</h3>
<ul class="cv-entry">
{% for grant in internal_grants %}
<li class="row">
<span class="cv-entry-date col-xs-2 col-sm-1">{% if grant.start_date and grant.end_date%}{{grant|year_range}}{% endif %}</span>
<span class="cv-entry-text col-xs-9 col-sm-10">{{grant.title}}. {% if grant.agency %}{{grant.agency}}{% endif %}{% if grant.division %}, {{grant.division}}{% endif %} ({{grant.amount|monetize}}). {% if grant.role %}<em>{{grant.role}}</em>. {% endif %}{% if grant.get_pi %}{{grant.get_pi|print_authors}}, Principal Investigator{{grant.get_pi.count|pluralize}}.{% endif %}
        {% if user.is_authenticated %}
			<a class="ml-4 article-edit cv-edit" href="{% url 'cv:cv_edit' model_name='grant' pk=grant.pk %}"><i class="far fa-edit"></i></a>
		{% endif %}
</span>
</li>
{% endfor %}
</ul>
{% endif %}

{% if external_grants %}
<h3 class="col-xs-12">External</h3>
<ul class="cv-entry">
{% for grant in external_grants %}
<li class="row">
<span class="cv-entry-date col-xs-2 col-sm-1">{{grant|year_range}}</span>
<span class="cv-entry-text col-xs-9 col-sm-10">{{grant.title}}. {% if grant.division %}{{grant.division}},{% endif %}{% if grant.agency %}{{grant.agency}}{% endif %} ({{grant.amount|monetize}}). {% if grant.role %}<em>{{grant.role}}</em>. {% endif %}{% if grant.get_pi %}{{pi|print_authors}}, Principal Investigator{{grant.get_pi.count|pluralize}}.{% endif %}
        {% if user.is_authenticated %}
			<a class="ml-4 article-edit cv-edit" href="{% url 'cv:cv_edit' model_name='grant' pk=grant.pk %}"><i class="far fa-edit"></i></a>
		{% endif %}
</span>
</li>
{% endfor %}
</ul>
{% endif %}

{% if user.is_authenticated %}
<ul class="cv-entry">
<li class="row">
	<a class="col-12 col-sm-12 grant-add cv-add" alt="Add new grant" href="{% url 'cv:cv_add' model_name='grant' %}"><i class="far fa-plus-square"></i> Add new grant</a>	
</li>
</ul>
{% endif %}

{% endif %}
