admin lot tags #47
|
@ -82,16 +82,11 @@
|
||||||
<ul class="nav flex-column">
|
<ul class="nav flex-column">
|
||||||
{% if user.is_admin %}
|
{% if user.is_admin %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="admin {% if path in 'panel users states_panel edit_user delete_user new_user institution' %}active {% endif %}nav-link fw-bold" data-bs-toggle="collapse" data-bs-target="#ul_admin" aria-expanded="false" aria-controls="ul_admin" href="javascript:void()">
|
<a class="admin {% if path in 'panel users states_panel tag_panel edit_user delete_user new_user institution' %}active {% endif %}nav-link fw-bold" data-bs-toggle="collapse" data-bs-target="#ul_admin" aria-expanded="false" aria-controls="ul_admin" href="javascript:void()">
|
||||||
<i class="bi bi-person-fill-gear icon_sidebar"></i>
|
<i class="bi bi-person-fill-gear icon_sidebar"></i>
|
||||||
{% trans 'Admin' %}
|
{% trans 'Admin' %}
|
||||||
</a>
|
</a>
|
||||||
<ul class="flex-column mb-2 ul_sidebar accordion-collapse {% if path in 'panel institution users edit_user new_user delete_user states_panel' %}expanded{% else %}collapse{% endif %}" id="ul_admin" data-bs-parent="#sidebarMenu">
|
<ul class="flex-column mb-2 ul_sidebar accordion-collapse {% if path in 'panel users tag_panel states_panel' %}expanded{% else %}collapse{% endif %}" id="ul_admin" data-bs-parent="#sidebarMenu">
|
||||||
<a class="admin {% if path in 'panel users tag_panel' %}active {% endif %}nav-link fw-bold" data-bs-toggle="collapse" data-bs-target="#ul_admin" aria-expanded="false" aria-controls="ul_admin" href="javascript:void()">
|
|
||||||
<i class="bi bi-person-fill-gear icon_sidebar"></i>
|
|
||||||
{% trans 'Admin' %}
|
|
||||||
</a>
|
|
||||||
<ul class="flex-column mb-2 ul_sidebar accordion-collapse {% if path in 'panel users tag_panel' %}expanded{% else %}collapse{% endif %}" id="ul_admin" data-bs-parent="#sidebarMenu">
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if path in 'panel institution' %} active2{% endif %}" href="{% url 'admin:panel' %}">
|
<a class="nav-link{% if path in 'panel institution' %} active2{% endif %}" href="{% url 'admin:panel' %}">
|
||||||
{% trans 'Panel' %}
|
{% trans 'Panel' %}
|
||||||
|
@ -105,6 +100,7 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if path == 'states_panel' %} active2{% endif %}" href="{% url 'admin:states_panel' %}">
|
<a class="nav-link{% if path == 'states_panel' %} active2{% endif %}" href="{% url 'admin:states_panel' %}">
|
||||||
{% trans 'States' %}
|
{% trans 'States' %}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if path == 'tag_panel' %} active2{% endif %}" href="{% url 'admin:tag_panel' %}">
|
<a class="nav-link{% if path == 'tag_panel' %} active2{% endif %}" href="{% url 'admin:tag_panel' %}">
|
||||||
|
|
|
@ -139,7 +139,7 @@ class Device:
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_all(cls, institution, offset=0, limit=None):
|
def get_all(cls, institution, offset=0, limit=None):
|
||||||
sql = """
|
sql = """
|
||||||
WITH RankedAnnotations AS (
|
WITH RankedProperties AS (
|
||||||
SELECT
|
SELECT
|
||||||
t1.value,
|
t1.value,
|
||||||
t1.key,
|
t1.key,
|
||||||
|
@ -148,24 +148,22 @@ class Device:
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE
|
CASE
|
||||||
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
||||||
WHEN t1.key = 'hidalgo1' THEN 2
|
WHEN t1.key = 'ereuse24' THEN 2
|
||||||
ELSE 3
|
ELSE 3
|
||||||
END,
|
END,
|
||||||
t1.created DESC
|
t1.created DESC
|
||||||
) AS row_num
|
) AS row_num
|
||||||
FROM evidence_annotation AS t1
|
FROM evidence_systemproperty AS t1
|
||||||
WHERE t1.owner_id = {institution}
|
WHERE t1.owner_id = {institution}
|
||||||
AND t1.type = {type}
|
|
||||||
)
|
)
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
value
|
value
|
||||||
FROM
|
FROM
|
||||||
RankedAnnotations
|
RankedProperties
|
||||||
WHERE
|
WHERE
|
||||||
row_num = 1
|
row_num = 1
|
||||||
""".format(
|
""".format(
|
||||||
institution=institution.id,
|
institution=institution.id,
|
||||||
type=Annotation.Type.SYSTEM,
|
|
||||||
)
|
)
|
||||||
if limit:
|
if limit:
|
||||||
sql += " limit {} offset {}".format(int(limit), int(offset))
|
sql += " limit {} offset {}".format(int(limit), int(offset))
|
||||||
|
@ -185,7 +183,7 @@ class Device:
|
||||||
def get_all_count(cls, institution):
|
def get_all_count(cls, institution):
|
||||||
|
|
||||||
sql = """
|
sql = """
|
||||||
WITH RankedAnnotations AS (
|
WITH RankedProperties AS (
|
||||||
SELECT
|
SELECT
|
||||||
t1.value,
|
t1.value,
|
||||||
t1.key,
|
t1.key,
|
||||||
|
@ -194,24 +192,23 @@ class Device:
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE
|
CASE
|
||||||
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
||||||
WHEN t1.key = 'hidalgo1' THEN 2
|
WHEN t1.key = 'ereuse24' THEN 2
|
||||||
ELSE 3
|
ELSE 3
|
||||||
END,
|
END,
|
||||||
t1.created DESC
|
t1.created DESC
|
||||||
) AS row_num
|
) AS row_num
|
||||||
FROM evidence_annotation AS t1
|
|
||||||
WHERE t1.owner_id = {institution}
|
FROM evidence_systemproperty AS t1
|
||||||
AND t1.type = {type}
|
WHERE t1.owner_id = {institution}
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(DISTINCT value)
|
COUNT(DISTINCT value)
|
||||||
FROM
|
FROM
|
||||||
RankedAnnotations
|
RankedProperties
|
||||||
WHERE
|
WHERE
|
||||||
row_num = 1
|
row_num = 1
|
||||||
""".format(
|
""".format(
|
||||||
institution=institution.id,
|
institution=institution.id
|
||||||
type=Annotation.Type.SYSTEM,
|
|
||||||
)
|
)
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
|
Loading…
Reference in a new issue