Commit 2c58a800 authored by hypsug0's avatar hypsug0
Browse files

feat: add study to session tables

parent e126179f
......@@ -900,176 +900,6 @@ class CaveTable(tables.Table):
)
class SessionTable(tables.Table):
ACTIONS = """
<div class="btn-group btn-group-primary btn-group-xs">
<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a data-toggle="modal"
data-target=".bs-session-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
<li><a href="{% url 'sights:session_detail' record.pk %}" title="Fiche détaillée"><i class="fa fa-fw fa-info-circle"></i> Fiche
détaillée</a></li>
<li><a href="{% url 'sights:session_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-edit"></i> Modifier</a>
</li>
<li><a href="{% url 'sights:sighting_create' record.pk %}" Title="Ajouter une observation"><i
class="fi-eye"></i> Ajouter une observation</a></li>
<li role="separator" class="divider"></li>
<li style="color:red;"><a href="{% url 'sights:session_delete' record.pk %}" title="Supprimer"><i
class="fa fa-fw fa-trash"></i> Supprimer</a></li>
</ul>
</div>
<div class="modal fade bs-session-history-modal-md-{{ record.pk }}" tabindex="-1" role="dialog"
aria-labelledby="history">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
</div>
<div class="modal-body">
<p>Donnée créée le {{ record.timestamp_create }} par {{ record.created_by }}
{% if record.timestamp_update %}
et mise à jour le {{ record.timestamp_update }}
{% endif %}
par {{ record.updated_by }}
</p>
</div>
</div>
</div>
</div>
"""
NBTAX = """
{% ifequal 0 record.observations.all.count %}
-
{% else %}
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
data-target=".bs-session-sp-modal-md-{{ record.pk }}">
{{ record.observations.count }}
</button>
<div class="modal fade bs-session-sp-modal-md-{{ record.pk }}" tabindex="-1" role="dialog"
aria-labelledby="comment">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="exampleModalLabel">Taxons observés</h4>
</div>
<div class="modal-body">
<table class="table table-striped">
<tr>
<th>nom français</th>
<th>nom scientifique</th>
<th>codesp</th>
<th>effectif</th>
</tr>
{% for d in record.observations.all %}
<tr{% if d.codesp.sp_true %} class="success"{% endif %}>
<td>{{ d.codesp.common_name_fr }}</td>
<td>{{ d.codesp.sci_name }}</td>
<td>{{ d.codesp.codesp }}</td>
<td>{{ d.total_count }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
</div>
{% endifequal %}
"""
OBSERVERS = """
{% if record.other_observer.all.count > 0 %}
<a data-toggle="modal"
data-target=".bs-session-otherobs-modal-md-{{ record.pk }}"> {{ record.main_observer }} <span
class="badge">{{ record.other_observer.all.count }}</span></a>
<div class="modal fade bs-session-otherobs-modal-md-{{ record.pk }}" tabindex="-1" role="dialog"
aria-labelledby="otherobs">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="exampleModalLabel">Autres observateurs</h4>
</div>
<div class="modal-body">
{% for o in record.other_observer.all %}
<b>{{ o.get_full_name }}</b> ({{ o.username }})<br/>
{% endfor %}
</div>
</div>
</div>
</div>
{% else %}
{{ record.main_observer }}
{% endif %}
"""
COMMENT = """
{% if record.comment %}
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
data-target=".bs-session-comment-modal-md-{{ record.pk }}">
<i class="fa fa-comment" aria-hidden="true"></i>
</button>
<div class="modal fade bs-session-comment-modal-md-{{ record.pk }}" tabindex="-1" role="dialog"
aria-labelledby="comment">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
</div>
<div class="modal-body">
<p>{{ record.comment|safe }}
</p>
</div>
</div>
</div>
</div>
{% endif %}
"""
# id = tables.Column(accessor='id_session', verbose_name='id')
name = tables.Column(verbose_name="Nom")
nbtax = tables.TemplateColumn(NBTAX, verbose_name="Nb de taxons")
observer = tables.TemplateColumn(OBSERVERS, verbose_name="Observateur(s)")
comment = tables.TemplateColumn(COMMENT, verbose_name="Commentaire", orderable=False)
date_start = tables.Column(verbose_name="Date début")
date_end = tables.Column(verbose_name="Date fin")
time_start = tables.Column(verbose_name="Heure début")
time_end = tables.Column(verbose_name="Heure fin")
actions = tables.TemplateColumn(ACTIONS, verbose_name="Actions", orderable=False)
name = tables.LinkColumn("sights:session_detail", args=[A("id_session")], accessor="name")
place = tables.LinkColumn(
"sights:place_detail", args=[A("place.id_place")], accessor="place.name"
)
class Meta:
model = Session
template = "table_bootstrap.html"
attrs = table_class
fields = (
"actions",
"name",
"place",
"place.municipality",
"contact.descr",
"date_start",
"time_start",
"date_end",
"time_end",
"observer",
"nbtax",
"comment",
)
class PlaceSessionTable(tables.Table):
ACTIONS = """
<div class="btn-group btn-group-xs">
......@@ -1216,6 +1046,7 @@ class PlaceSessionTable(tables.Table):
observer = tables.TemplateColumn(OBSERVERS, verbose_name="Observateur(s)")
comment = tables.TemplateColumn(COMMENT, verbose_name="Commentaire", orderable=False)
date_start = tables.Column(verbose_name="Date début")
study = tables.Column(verbose_name="Projet")
date_end = tables.Column(verbose_name="Date fin")
time_start = tables.Column(verbose_name="Heure début")
time_end = tables.Column(verbose_name="Heure fin")
......@@ -1229,7 +1060,7 @@ class PlaceSessionTable(tables.Table):
"actions",
"name",
"contact.descr",
"date_start",
"study." "date_start",
"time_start",
"date_end",
"time_end",
......@@ -1239,6 +1070,16 @@ class PlaceSessionTable(tables.Table):
)
class SessionTable(PlaceSessionTable):
place = tables.LinkColumn(
"sights:place_detail", args=[A("place.id_place")], accessor="place.name"
)
class Meta:
model = Session
fields = PlaceSessionTable.Meta.fields + ("place",)
class SessionSightingTable(tables.Table):
ACTIONS = """
<div class="btn-group btn-group-xs">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment