Add circles extension

This commit is contained in:
Yusur 2021-09-04 08:10:28 +02:00
parent a712303ccd
commit ec720743b3
8 changed files with 321 additions and 5 deletions

View file

@ -0,0 +1,57 @@
{% extends "base.html" %}
{% block title %}Circles {{ app_name }}{% endblock %}
{% block content %}
<form method="POST" class="circles-add-form">
<div>
<label>#</label>
<input type="number" name="code" placeholder="00000" required="" maxlength="6" value="{{ pl.code if pl else '' }}" />
</div>
<div>
<label>Display name</label>
<input type="text" name="display_name" placeholder="Display name" required="" value="{{ pl.display_name if pl else '' }}" />
</div>
<div>
<label>First name</label>
<input type="text" name="first_name" placeholder="First name" value="{{ pl.first_name if pl else '' }}" />
</div>
<div>
<label>Last name</label>
<input type="text" name="last_name" placeholder="Last name" value="{{ pl.last_name if pl else '' }}" />
</div>
<div>
<label>Type</label>
<select name="type">
<option disabled=""{% if not pl %} selected=""{% endif %}>(Choose)</option>
{% set typ_list = [
'INTJ', 'INTP', 'INFJ', 'INFP', 'ENTJ', 'ENTP',
'ENFJ', 'ENFP', 'ISTJ', 'ISTP', 'ISFJ', 'ISFP',
'ESTJ', 'ESTP', 'ESFJ', 'ESFP', '1x38B'] %}
{% for typ in typ_list %}
<option value="{{ typ }}"{% if pl and typ == pl.type %} selected=""{% endif %}>{{ typ }}</option>
{% endfor %}
</select>
</div>
<div>
<label>Status</label>
<select name="status">
<option value="-1">Red</option>
<option value="0"{% if pl and 0 == pl.status %} selected=""{% endif %}>Orange</option>
<option value="1"{% if pl and 1 == pl.status %} selected=""{% endif %}>Yellow</option>
<option value="2"{% if pl and 2 == pl.status %} selected=""{% endif %}>Green</option>
</select>
</div>
<div>
<label>Area</label>
<input type="number" name="area" value="{{ pl.area if pl and pl.area else 0 }}">
</div>
<input type="submit" value="Save">
</form>
{% if not pl %}
<p>Looking for mass addition? Try <a href="/circles/csv">CSV adding form</a> instead.</p>
{% endif %}
{% endblock %}

View file

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block title %}Circles {{ app_name }}{% endblock %}
{% block content %}
<form method="POST" enctype="multipart/form-data">
<p>Enter the contacts you want to bulk add, in comma-separated values (CSV) format, one by line.<br />Order matters.</p>
<textarea name="text" style="width:100%;height:20em" placeholder="00000,First,Last,Display,Type"></textarea>
<input type="checkbox" disabled="" id="autoConsent" name="consent" value="y" />
<input type="submit" value="Save" />
</form>
<script>
setTimeout(() => {
let ac = document.getElementById("autoConsent");
ac.disabled = false;
ac.selected = false;
}, 10000)
</script>
{% endblock %}

View file

@ -0,0 +1,60 @@
{% extends "base.html" %}
{% block title %}Circles {{ app_name }}{% endblock %}
{% block content %}
<p>Showing: <strong>{{ cat }}</strong></p>
<div>
<p>Show by:</p>
<p><strong>Type</strong>:
{% set typ_list = [
'INTJ', 'INTP', 'INFJ', 'INFP', 'ENTJ', 'ENTP',
'ENFJ', 'ENFP', 'ISTJ', 'ISTP', 'ISFJ', 'ISFP',
'ESTJ', 'ESTP', 'ESFJ', 'ESFP'] %}
{% for t in typ_list %}
<a href="/circles/{{ t.lower() }}">{{ t }}</a> ·
{% endfor %}
</p>
<p><strong>Status</strong>:
{% set typ_list = ['Green', 'Yellow', 'Orange', 'Red'] %}
{% for t in typ_list %}
<a href="/circles/{{ t.lower() }}">{{ t }}</a> ·
{% endfor %}
</p>
<p><strong>Area</strong>:
{% for t in range(1, 13) %}
<a href="/circles/area-{{ t }}">{{ t }}</a> ·
{% endfor %}
</p>
</div>
{% if count > people.count() %}
<p>Showing <strong>{{ people.count() }}</strong> people of <strong>{{ count }}</strong> total.</p>
{% if count > pageno * 50 %}
<p><a href="?page={{ pageno + 1 }}" rel="nofollow">Next page</a>{% if pageno > 1 %} · <a href="?page={{ pageno - 1 }}" rel="nofollow">Prev page</a>{% endif %}</p>
{% elif pageno > 1 %}
<a href="?page={{ pageno - 1 }}" rel="nofollow">Prev page</a></p>
{% endif %}
{% else %}
<p><strong>{{ count }}</strong> people.</p>
{% endif %}
<ul class="circles-list">
{% for p in people %}
<li class="circles-{{ 'red' if p.status == -1 else 'green' if p.status == 2 else 'yellow' if p.status == 1 else 'orange' }}">{{ p.code }} {{ p.display_name }} {{ p.type }} {% if p.area %}Area {{ p.area }}{% else %}No area{% endif %} (<a href="/circles/edit/{{ p.code }}">edit</a>)</li>
{% endfor %}
</ul>
{% if count > people.count() %}
<p>Showing <strong>{{ people.count() }}</strong> people of <strong>{{ count }}</strong> total.</p>
{% if count > pageno * 50 %}
<p><a href="?page={{ pageno + 1 }}" rel="nofollow">Next page</a>{% if pageno > 1 %} · <a href="?page={{ pageno - 1 }}" rel="nofollow">Prev page</a>{% endif %}</p>
{% elif pageno > 1 %}
<a href="?page={{ pageno - 1 }}" rel="nofollow">Prev page</a></p>
{% endif %}
{% else %}
<p><strong>{{ count }}</strong> people.</p>
{% endif %}
{% endblock %}

View file

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% block title %}Circles {{ app_name }}{% endblock %}
{% block content %}
<h1>Stats</h1>
<ul>
<li>All people: <strong>{{ count }}</strong></li>
<li>People by type:</li>
<ul>
{% for k in typed_count.items() %}
<li>{{ k[0] }}: <strong>{{ k[1] }}</strong></li>
{% endfor %}
</ul>
<li>People by status zone:</li>
<ul>
{% for k in status_count.items() %}
<li>{{ k[0] }}: <strong>{{ k[1] }}</strong></li>
{% endfor %}
</ul>
</ul>
{% endblock %}