{% extends "cosinnus/wagtail/wagtailadmin/custom_admin_base.html" %}
{% load gravatar static compress i18n cosinnus_tags %}

{% block titletag %}{% trans "Import Projects and Groups or Users" %}{% endblock %}

{% block branding_welcome %}{% trans "Import Projects and Groups" %}{% endblock %}

{% block sections %}
	<section>
		<br/><br/>
	    <form action="." method="post" enctype="multipart/form-data">
    		{% csrf_token %}
			<input id="csv_delimiter" type="hidden" name="trigger_new_import" value="1"/>
    		<button type="submit" class="button-longrunning">{% trans "Clear results and start a new import!" %}</button>
    	</form>
    	
    	<hr/>
    	
	    <h2>{% trans "CSV Import Results" %}</h2>
	    
	    <p>{% trans "The import has finished. Here are the results:" %}</p>
	    
	    <div style="width:100%; max-height: 500px; white-space: nowrap; overflow-x: auto; overflow-y: auto;">
	    	{% if import_results.read_errors %}
		    	<h3>{% trans "Read errors:" %} {{ import_results.read_errors }} </h3>
		    	<p>{% trans "These rows in your CSV file had errors or an incorrect number of columns and were IGNORED:" %} {{ import_results.read_errors }}</p>
		    	{% if import_results.bad_rows %}
		    	<p>
		    		{% for bad_row in import_results.bad_rows %}
		    			{{ bad_row }} <br/>
		    		{% endfor %}
		    	</p>
		    	{% endif %}
		    {% endif %}
	    
		    {% if import_results.successes %}
		    	<h3>{% trans "Saved items:" %} {{ import_results.saved_groups }} / {{ import_results.total_groups }}</h3>
		    	<p>
		    		{% for msg in import_results.successes %}
		    			{{ msg|safe|urlize|url_target_blank }}<br/>
		    		{% endfor %}
		    	</p>
		    {% endif %}
		    {% if import_results.attentions %}
		    	<h3>{% trans "Important messages:" %}</h3>
		    	<p>
		    		{% for msg in import_results.attentions %}
		    			{{ msg|safe|urlize|url_target_blank }}<br/>
		    		{% endfor %}
		    	</p>
		    {% endif %}
		    {% if import_results.errors %}
		    	<h3>{% trans "Errors:" %}</h3>
		    	<p>
		    		{% for msg in import_results.errors %}
		    			{{ msg|safe|urlize|url_target_blank }}<br/>
		    		{% endfor %}
		    	</p>
		    {% endif %}
		    {% if import_results.infos %}
		    	<h3>{% trans "Info messages:" %}</h3>
		    	<p>
		    		{% for msg in import_results.infos %}
		    			{{ msg|safe|urlize|url_target_blank }}<br/>
		    		{% endfor %}
		    	</p>
		    {% endif %}
	    </div>
	    
	    
	</section>
{% endblock %}