tables.py 88 KB
Newer Older
1
import django_tables2 as tables
2
from django.utils.translation import ugettext_lazy as _
3
from django_tables2.utils import A
4

fred.perso's avatar
fred.perso committed
5 6
from sights.models import Place, PlaceManagement, Bridge, Build, Cave, Device, Session, Sighting, Tree, TreeGite, \
    CountDetail
7

8

9
class PlaceTable(tables.Table):
10
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
11 12 13 14 15 16 17 18
            <div class="btn-group 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-place-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
19 20
                            class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                    <li><a href="{% url 'sights:place_detail' record.pk %}" title="Fiche détaillée"><i class="fa fa-fw fa-info-circle"></i> Fiche
fred.perso's avatar
fred.perso committed
21
                        détaillée</a></li>
fred.perso's avatar
fred.perso committed
22
                    <li><a href="{% url 'sights:place_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
23 24 25 26 27
                    </li>
                    <li><a href="{% url 'sights:session_create' record.pk %}" Title="Ajouter une session"><i
                            class="fi-calendar"></i> Ajouter une session</a></li>
                    <li role="separator" class="divider"></li>
                    <li style="color:red;"><a href="{% url 'sights:place_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
28
                            class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
29 30 31 32 33 34 35 36 37
                </ul>
            </div>
            <div class="modal fade bs-place-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>
fred.perso's avatar
fred.perso committed
38
                            <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
                        </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>
            '''
    COMMENT = '''
        {% if record.comment %}
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-place-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
56
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
57 58 59 60 61 62 63 64
        </button>
        <div class="modal fade bs-place-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>
fred.perso's avatar
fred.perso committed
65
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
66 67 68 69 70 71 72 73 74 75
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}
    '''
fred.perso's avatar
fred.perso committed
76 77
    MAPLOCATION ='''
    {% if record.geom %}
fred.perso's avatar
fred.perso committed
78
        <button class="btn btn-primary btn-xs map-navigation" data-zoom="15" data-position="{{ record.geom.y}}-{{ record.geom.x}}"><i class="fa fa-map-marker"></i></button>
fred.perso's avatar
fred.perso committed
79 80
    {% endif %}
    '''
81
    # id = tables.Column(accessor='id_place', verbose_name='id')
fred.perso's avatar
fred.perso committed
82
    nbsession = tables.Column(accessor='session_set.all.count',
83
                              verbose_name="Sessions", orderable=False)
fred.perso's avatar
fred.perso committed
84
    name = tables.LinkColumn('sights:place_detail', args=[
85
        A('id_place')], accessor='name')
fred.perso's avatar
fred.perso committed
86
    maplocation = tables.TemplateColumn(MAPLOCATION, verbose_name="Carte", orderable=False)
87 88
    actions = tables.TemplateColumn(
        ACTIONS, verbose_name="Actions", orderable=False)
89
    type = tables.Column(accessor='type.descr', verbose_name="Type de gîte")
fred.perso's avatar
fred.perso committed
90 91
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)
92

93 94
    class Meta:
        model = Place
fred.perso's avatar
fred.perso committed
95 96
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
fred.perso's avatar
fred.perso committed
97
        fields = ('actions','maplocation','name', 'is_hidden', 'municipality', 'type', 'altitude', 'created_by',
98
                  'nbsession', 'comment')
99

fred.perso's avatar
fred.perso committed
100

101 102
class PlaceManagementTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
103 104 105 106 107 108 109 110
        <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-mgmt-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
111 112
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:management_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
113 114 115 116 117
                </li>
                <li><a href="{% url 'sights:management_create' record.pk %}" Title="Ajouter une observation"><i
                        class="fi-eye"></i> Ajouter une action</a></li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:management_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
118
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
119 120 121 122 123 124 125 126 127
            </ul>
        </div>
        <div class="modal fade bs-mgmt-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>
fred.perso's avatar
fred.perso committed
128
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
129 130 131 132 133 134 135 136 137 138 139 140
                    </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>
141 142
        '''
    COMMENT = '''
fred.perso's avatar
fred.perso committed
143 144 145
        {% if record.comment %}
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-mgmt-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
146
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
147 148 149 150 151 152 153 154
        </button>
        <div class="modal fade bs-mgmt-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>
fred.perso's avatar
fred.perso committed
155
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
156 157 158 159 160 161 162 163 164 165
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}
    '''
166 167 168 169 170 171 172
    actions = tables.TemplateColumn(
        ACTIONS, verbose_name="Actions", orderable=False)
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)

    class Meta:
        model = PlaceManagement
fred.perso's avatar
fred.perso committed
173 174
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
175 176 177
        fields = ('actions', 'date', 'action', 'referent', 'file', 'comment')


178 179
class BridgeTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
180 181 182 183 184 185 186 187
            <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-bridge-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
188 189
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:bridge_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
190 191 192
                </li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:bridge_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
193
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
194 195 196 197 198 199 200 201 202
            </ul>
        </div>
        <div class="modal fade bs-bridge-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>
fred.perso's avatar
fred.perso committed
203
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
204 205 206 207 208 209 210 211 212 213 214 215 216
                    </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>
        '''
217 218
    COMMENT = '''
        {% if record.comment %}
fred.perso's avatar
fred.perso committed
219 220
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-bridge-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
221
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
222 223 224 225 226 227 228 229
        </button>
        <div class="modal fade bs-bridge-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>
fred.perso's avatar
fred.perso committed
230
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
231 232 233 234 235 236 237 238
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
239 240 241
        {% endif %}
    '''
    actions = tables.TemplateColumn(
242
        ACTIONS, verbose_name="Actions", orderable=False)
243 244 245 246 247
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)

    class Meta:
        model = Bridge
fred.perso's avatar
fred.perso committed
248 249
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
250 251
        fields = ('actions', 'visit_date', 'interest', 'renovated', 'renovated_date',
                  'joint', 'rift', 'expansion', 'drain', 'cornice', 'volume', 'comment')
252

fred.perso's avatar
fred.perso committed
253

fred.perso's avatar
fred.perso committed
254
class TreeTable(tables.Table):
255
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
256 257 258 259 260 261 262 263
            <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-tree-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
264 265
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:tree_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
266 267 268
                </li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:tree_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
269
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
270 271 272 273 274 275 276 277 278
            </ul>
        </div>
        <div class="modal fade bs-tree-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>
fred.perso's avatar
fred.perso committed
279
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
280 281 282 283 284 285 286 287 288 289 290 291 292
                    </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>
        '''
293 294
    COMMENT = '''
        {% if record.comment %}
fred.perso's avatar
fred.perso committed
295 296
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-tree-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
297
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
298 299 300 301 302 303 304 305
        </button>
        <div class="modal fade bs-tree-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>
fred.perso's avatar
fred.perso committed
306
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
307 308 309 310 311 312 313 314
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
315 316
        {% endif %}
    '''
317
    NBTAX = '''
fred.perso's avatar
fred.perso committed
318
            {% ifequal 0 record.bat_specie.all.count %}
319
            -
fred.perso's avatar
fred.perso committed
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
            {% else %}       
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-tree-sp-modal-md-{{ record.pk }}">
            {{ record.bat_specie.all.count }}
            </button>
            <div class="modal fade bs-tree-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.bat_specie.all %}
                            <tr{% if d.sp_true %} class="success"{% endif %}>
                                <td>{{ d.common_name_fr }}</td>
                                <td>{{ d.sci_name }}</td>
                                <td>{{ d.codesp }}</td>
                                <td>{{ d.total_count }}</td>
                            </tr>
                        {% endfor %}
                        </table>
                        </div>
                    </div>
                </div>
355
            </div>
fred.perso's avatar
fred.perso committed
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
            {% endifequal %}
        '''
    GITEORIGIN = '''
            {% ifequal 0 record.gite_origin.all.count %}
            -
            {% else %}       
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-gitorigin-modal-md-{{ record.pk }}">
            {{ record.gite_origin.all.count }}
            </button>
            <div class="modal fade bs-gitorigin-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">Origine des gîtes</h4>
                        </div>
                        <div class="modal-body">
                        <ul>
                        {% for d in record.gite_origin.all %}
                            <li>{{ d.descr }}</li>
                        {% endfor %}
                        </ul>
                        </div>
                    </div>
                </div>
            </div>
            {% endifequal %}
        '''
    GITETYPE = '''
            {% ifequal 0 record.gite_type.all.count %}
            -
            {% else %}       
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-gittype-modal-md-{{ record.pk }}">
            {{ record.gite_type.all.count }}
            </button>
            <div class="modal fade bs-gittype-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">Types de gîtes</h4>
                        </div>
                        <div class="modal-body">
                        <ul>
                        {% for d in record.gite_type.all %}
                            <li>{{ d.descr }}</li>
                        {% endfor %}
                        </ul>
                        </div>
                    </div>
                </div>
            </div>
            {% endifequal %}
        '''
    GITELOC = '''
            {% ifequal 0 record.gite_localisation.all.count %}
            -
            {% else %}       
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-gitloc-modal-md-{{ record.pk }}">
            {{ record.gite_localisation.all.count }}
            </button>
            <div class="modal fade bs-gitloc-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">Localisation des gîtes</h4>
                        </div>
                        <div class="modal-body">
                        <ul>
                        {% for d in record.gite_localisation.all %}
                            <li>{{ d.descr }}</li>
                        {% endfor %}
                        </ul>
                        </div>
                    </div>
                </div>
            </div>
            {% endifequal %}
444
        '''
445
    actions = tables.TemplateColumn(
446
        ACTIONS, verbose_name="Actions", orderable=False)
447 448
    nbtax = tables.TemplateColumn(
        NBTAX, verbose_name="Nb de taxons")
fred.perso's avatar
fred.perso committed
449 450 451
    gitetype = tables.TemplateColumn(GITETYPE, verbose_name="type gites")
    giteorigin = tables.TemplateColumn(GITEORIGIN, verbose_name="origine gites")
    giteloc = tables.TemplateColumn(GITELOC, verbose_name="Loc. gites")
452 453 454 455
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)

    class Meta:
fred.perso's avatar
fred.perso committed
456
        model = Tree
fred.perso's avatar
fred.perso committed
457 458
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
fred.perso's avatar
fred.perso committed
459
        fields = (
460
            'actions', 'visit_date', 'context', 'forest_stands', 'situation', 'circumstance', 'tree_specie', 'health',
fred.perso's avatar
fred.perso committed
461 462
            'tree_diameter', 'standing', 'protected', 'nbtax', 'gitetype', 'giteorigin',
            'giteloc', 'comment')
463 464


fred.perso's avatar
fred.perso committed
465 466
class TreeGiteTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
467 468 469 470 471 472 473 474
            <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-treegite-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
475 476
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:treegite_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
477 478 479
                </li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:treegite_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
480
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
481 482 483 484 485 486 487 488 489
            </ul>
        </div>
        <div class="modal fade bs-treegite-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>
fred.perso's avatar
fred.perso committed
490
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
491 492 493 494 495 496 497 498 499 500 501 502 503
                    </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>
        '''
fred.perso's avatar
fred.perso committed
504 505
    COMMENT = '''
        {% if record.comment %}
fred.perso's avatar
fred.perso committed
506 507
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-treegite-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
508
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
509 510 511 512 513 514 515 516
        </button>
        <div class="modal fade bs-treegite-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>
fred.perso's avatar
fred.perso committed
517
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
518 519 520 521 522 523 524 525
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
fred.perso's avatar
fred.perso committed
526 527 528
        {% endif %}
    '''
    NBTAX = '''
fred.perso's avatar
fred.perso committed
529
            {% ifequal 0 record.bat_specie.all.count %}
fred.perso's avatar
fred.perso committed
530
            -
fred.perso's avatar
fred.perso committed
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
            {% else %}       
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-treegite-sp-modal-md-{{ record.pk }}">
            {{ record.bat_specie.all.count }}
            </button>
            <div class="modal fade bs-treegite-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.bat_specie_set.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>
fred.perso's avatar
fred.perso committed
566
            </div>
fred.perso's avatar
fred.perso committed
567
            {% endifequal %}
fred.perso's avatar
fred.perso committed
568 569
        '''
    actions = tables.TemplateColumn(
570
        ACTIONS, verbose_name="Actions", orderable=False)
fred.perso's avatar
fred.perso committed
571 572 573 574 575 576 577
    nbtax = tables.TemplateColumn(
        NBTAX, verbose_name="Nb de taxons")
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)

    class Meta:
        model = TreeGite
fred.perso's avatar
fred.perso committed
578 579
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
fred.perso's avatar
fred.perso committed
580
        fields = (
581
            'actions', 'nbtax', 'gite_type', 'gite_origin', 'gite_localisation', 'gite_high', 'gite_tree_diameter',
582
            'gite_access_orientation', 'gite_access_size', 'comment')
fred.perso's avatar
fred.perso committed
583 584


585 586
class BuildTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
587 588 589 590 591 592 593 594
            <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-build-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
595 596
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:build_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
597 598 599
                </li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:build_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
600
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
601 602 603 604 605 606 607 608 609
            </ul>
        </div>
        <div class="modal fade bs-build-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>
fred.perso's avatar
fred.perso committed
610
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
611 612 613 614 615 616 617 618 619 620 621 622
                    </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>
623
        '''
fred.perso's avatar
fred.perso committed
624 625 626 627
    COMMENT = '''
        {% if record.comment %}
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-build-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
628
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
629 630 631 632 633 634 635 636
        </button>
        <div class="modal fade bs-build-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>
fred.perso's avatar
fred.perso committed
637
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
638 639 640 641 642 643 644 645 646 647
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}
    '''
648
    actions = tables.TemplateColumn(
649
        ACTIONS, verbose_name="Actions", orderable=False)
650 651 652 653 654
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)

    class Meta:
        model = Build
fred.perso's avatar
fred.perso committed
655 656
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
657 658 659 660 661 662 663
        fields = ('actions', 'visit_date', 'cavity_front', 'attic', 'attic_access',
                  'bell_tower', 'bell_tower_screen', 'bell_tower_access',
                  'cover', 'ext_light', 'access_light', 'cellar', 'cellar_access', 'comment')


class CaveTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
664 665 666 667 668 669 670 671
            <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-cave-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
672 673
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:cave_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
674 675 676
                </li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:cave_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
677
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
678 679 680 681 682 683 684 685 686
            </ul>
        </div>
        <div class="modal fade bs-cave-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>
fred.perso's avatar
fred.perso committed
687
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
688 689 690 691 692 693 694 695 696 697 698 699
                    </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>
700
        '''
fred.perso's avatar
fred.perso committed
701 702 703 704
    COMMENT = '''
        {% if record.comment %}
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-cave-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
705
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
706 707 708 709 710 711 712 713
        </button>
        <div class="modal fade bs-cave-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>
fred.perso's avatar
fred.perso committed
714
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
715 716 717 718 719 720 721 722 723 724
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}
    '''
fred.perso's avatar
fred.perso committed
725 726
    WALK_DURATION = '''
            {{ record.access_walk_duration|time:"H:i" }}'''
727
    actions = tables.TemplateColumn(
728
        ACTIONS, verbose_name="Actions", orderable=False)
729 730
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)
fred.perso's avatar
fred.perso committed
731 732
    access_walk_duration = tables.TemplateColumn(
        WALK_DURATION, verbose_name='Durée de marche', orderable=False)
733 734 735

    class Meta:
        model = Cave
fred.perso's avatar
fred.perso committed
736 737
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
738 739
        fields = ('actions', 'visit_date', 'interest', 'length', 'altdiff',
                  'n_entry', 'equipment', 'access_walk_duration', 'comment')
740 741


742
class SessionTable(tables.Table):
743
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
744 745 746 747 748 749 750 751
        <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
fred.perso's avatar
fred.perso committed
752 753
                        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
fred.perso's avatar
fred.perso committed
754
                    détaillée</a></li>
fred.perso's avatar
fred.perso committed
755
                <li><a href="{% url 'sights:session_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
756 757 758 759 760
                </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
fred.perso's avatar
fred.perso committed
761
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
762 763 764 765 766 767 768 769 770
            </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>
fred.perso's avatar
fred.perso committed
771
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
772 773 774 775 776 777 778 779 780 781 782 783 784
                    </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>
        '''
785
    NBTAX = '''
786
            {% ifequal 0 record.sighting_set.all.count %}
787
            -
fred.perso's avatar
fred.perso committed
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
            {% else %}       
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-session-sp-modal-md-{{ record.pk }}">
            {{ record.sighting_set.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.sighting_set.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>
822
                </div>
fred.perso's avatar
fred.perso committed
823
            </div>
824
            {% endifequal %}
fred.perso's avatar
fred.perso committed
825
        '''
826 827
    OBSERVERS = '''
        {% if record.other_observer.all.count > 0 %}
fred.perso's avatar
fred.perso committed
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
            <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>
848
            </div>
fred.perso's avatar
fred.perso committed
849 850
        {% else %}
            {{ record.main_observer }}
851 852
        {% endif %}
        '''
853 854
    COMMENT = '''
        {% if record.comment %}
fred.perso's avatar
fred.perso committed
855 856
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-session-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
857
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
858 859 860 861 862 863 864 865
        </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>
fred.perso's avatar
fred.perso committed
866
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
867 868 869 870 871 872 873 874
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
875 876
        {% endif %}
    '''
fred.perso's avatar
fred.perso committed
877
    # id = tables.Column(accessor='id_session', verbose_name='id')
878
    name = tables.Column(verbose_name='Nom')
879 880
    nbtax = tables.TemplateColumn(
        NBTAX, verbose_name="Nb de taxons")
881 882
    observer = tables.TemplateColumn(
        OBSERVERS, verbose_name="Observateur(s)")
883 884
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)
885 886 887 888
    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")
889
    actions = tables.TemplateColumn(
890
        ACTIONS, verbose_name="Actions", orderable=False)
fred.perso's avatar
fred.perso committed
891
    name = tables.LinkColumn('sights:session_detail', args=[
892
        A('id_session')], accessor='name')
fred.perso's avatar
fred.perso committed
893
    place = tables.LinkColumn('sights:place_detail', args=[
894
        A('place.id_place')], accessor='place.name')
895 896 897

    class Meta:
        model = Session
fred.perso's avatar
fred.perso committed
898 899
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
900
        fields = ('actions', 'name', 'place', 'place.municipality', 'contact.descr', 'date_start', 'time_start',
901
                  'date_end', 'time_end', 'observer', 'nbtax', 'comment')
902

903

fred.perso's avatar
fred.perso committed
904
class PlaceSessionTable(tables.Table):
905
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
906
        <div class="btn-group btn-group-xs">
fred.perso's avatar
fred.perso committed
907
            <button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
fred.perso's avatar
fred.perso committed
908 909 910 911 912 913
                    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
fred.perso's avatar
fred.perso committed
914 915
                        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
fred.perso's avatar
fred.perso committed
916
                    détaillée</a></li>
fred.perso's avatar
fred.perso committed
917
                <li><a href="{% url 'sights:session_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
918 919 920 921 922
                </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
fred.perso's avatar
fred.perso committed
923
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
924 925 926 927 928 929 930 931 932
            </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>
fred.perso's avatar
fred.perso committed
933
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
934 935 936 937 938 939 940 941 942 943 944 945
                    </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>
946 947
        '''
    NBTAX = '''
948 949
            {% ifequal 0 record.sighting_set.all.count %}
            -
fred.perso's avatar
fred.perso committed
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966
            {% else %}       
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-session-sp-modal-md-{{ record.pk }}">
            {{ record.sighting_set.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>
fred.perso's avatar
fred.perso committed
967

fred.perso's avatar
fred.perso committed
968 969
                            <th>nom français</th>
                            <th>nom scientifique</th>
fred.perso's avatar
fred.perso committed
970
                            <th>codesp</th>
fred.perso's avatar
fred.perso committed
971 972 973
                            <th>effectif</th>
                        </tr>
                        {% for d in record.sighting_set.all %}
fred.perso's avatar
fred.perso committed
974
                            <tr{% if d.codesp.sp_true %} class="success"{% endif %}>
fred.perso's avatar
fred.perso committed
975 976
                                <td>{{ d.codesp.common_name_fr }}</td>
                                <td>{{ d.codesp.sci_name }}</td>
fred.perso's avatar
fred.perso committed
977
                                <td>{{ d.codesp.codesp }}</td>
fred.perso's avatar
fred.perso committed
978
                                <td>{{ d.total_count }}</td>
fred.perso's avatar
fred.perso committed
979 980 981 982 983
                            </tr>
                        {% endfor %}
                        </table>
                        </div>
                    </div>
984
                </div>
fred.perso's avatar
fred.perso committed
985
            </div>
986
            {% endifequal %}
987
        '''
988
    OBSERVERS = '''
fred.perso's avatar
fred.perso committed
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
            {% 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 %}
            '''
1015 1016
    COMMENT = '''
        {% if record.comment %}
fred.perso's avatar
fred.perso committed
1017 1018
        <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                data-target=".bs-session-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
1019
            <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
1020 1021 1022 1023 1024 1025 1026 1027
        </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>
fred.perso's avatar
fred.perso committed
1028
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
1029 1030 1031 1032 1033 1034 1035 1036
                    </div>
                    <div class="modal-body">
                        <p>{{ record.comment|safe }}
                        </p>
                    </div>
                </div>
            </div>
        </div>
1037 1038
        {% endif %}
    '''
fred.perso's avatar
fred.perso committed
1039
    # id = tables.Column(accessor='id_session', verbose_name='id')
fred.perso's avatar
fred.perso committed
1040
    name = tables.LinkColumn('sights:session_detail', args=[
1041
        A('id_session')], accessor='name', verbose_name='Nom')
1042 1043
    nbtax = tables.TemplateColumn(
        NBTAX, verbose_name="Nb de taxons", orderable=False)
1044 1045
    observer = tables.TemplateColumn(
        OBSERVERS, verbose_name="Observateur(s)")
1046 1047 1048 1049 1050 1051 1052
    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(
1053
        ACTIONS, verbose_name="Actions", orderable=False)
1054 1055 1056

    class Meta:
        model = Session
fred.perso's avatar
fred.perso committed
1057 1058
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
1059
        fields = ('actions', 'name', 'contact.descr', 'date_start', 'time_start',
1060
                  'date_end', 'time_end', 'observer', 'nbtax', 'comment')
1061 1062


1063
class SessionSightingTable(tables.Table):
1064
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
1065 1066 1067 1068 1069 1070 1071 1072
        <div class="btn-group 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-sighting-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
1073 1074
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:sighting_detail' record.pk %}" title="Fiche détaillée"><i class="fa fa-fw fa-info-circle"></i> Fiche
fred.perso's avatar
fred.perso committed
1075
                    détaillée</a></li>
fred.perso's avatar
fred.perso committed
1076
                <li><a href="{% url 'sights:sighting_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
1077 1078 1079 1080 1081
                </li>
                <li><a href="{% url 'sights:countdetail_create' record.pk %}" Title="Ajouter une observation détaillée"><i
                        class="fi-eye"></i> Ajouter une observation</a></li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:sighting_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
1082
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
1083 1084 1085 1086 1087 1088 1089 1090 1091
            </ul>
        </div>
        <div class="modal fade bs-sighting-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>
fred.perso's avatar
fred.perso committed
1092
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
                    </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>
1105
        '''
1106
    COMMENT = '''
fred.perso's avatar
fred.perso committed
1107 1108 1109
         {% if record.comment %}
         <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                 data-target=".bs-sighting-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
1110
             <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
1111 1112 1113 1114 1115 1116 1117 1118
         </button>
         <div class="modal fade bs-sighting-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>
fred.perso's avatar
fred.perso committed
1119
                         <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
                     </div>
                     <div class="modal-body">
                         <p>{{ record.comment|safe }}
                         </p>
                     </div>
                 </div>
             </div>
         </div>
         {% endif %}
     '''
fred.perso's avatar
fred.perso committed
1130
    # id = tables.Column(accessor='id_sighting', verbose_name='id')
fred.perso's avatar
fred.perso committed
1131
    common_name_fr = tables.LinkColumn('sights:sighting_detail', args=[
1132 1133 1134
        A('id_sighting')], accessor='codesp.common_name_fr', verbose_name='Taxon')
    # common_name_fr = tables.Column(
    #     accessor='codesp.common_name_fr', verbose_name='Taxon')
1135 1136
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)
1137
    sp_true = tables.BooleanColumn(accessor='codesp.sp_true', verbose_name=_('Espèce vraie'))
1138
    actions = tables.TemplateColumn(
1139
        ACTIONS, verbose_name="Actions", orderable=False)
1140

1141
    class Meta:
fred.perso's avatar
fred.perso committed
1142
        model = Sighting
fred.perso's avatar
fred.perso committed
1143 1144
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
1145
        fields = ('actions', 'common_name_fr', 'sp_true', 'total_count', 'breed_colo', 'created_by', 'comment')
1146

fred.perso's avatar
fred.perso committed
1147 1148 1149

class SessionDeviceTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
1150 1151 1152 1153 1154 1155 1156 1157
        <div class="btn-group 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-device-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
1158 1159
                        class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                <li><a href="{% url 'sights:device_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
fred.perso's avatar
fred.perso committed
1160 1161 1162
                </li>
                <li role="separator" class="divider"></li>
                <li style="color:red;"><a href="{% url 'sights:device_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
1163
                        class="fa fa-fw fa-trash"></i> Supprimer</a></li>
fred.perso's avatar
fred.perso committed
1164 1165 1166 1167 1168 1169 1170 1171 1172
            </ul>
        </div>
        <div class="modal fade bs-device-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>
fred.perso's avatar
fred.perso committed
1173
                        <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
fred.perso's avatar
fred.perso committed
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185
                    </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>
fred.perso's avatar
fred.perso committed
1186 1187
        '''
    COMMENT = '''
fred.perso's avatar
fred.perso committed
1188 1189 1190
         {% if record.comment %}
         <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                 data-target=".bs-device-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
1191
             <i class="fa fa-comment" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
1192 1193 1194 1195 1196 1197 1198 1199
         </button>
         <div class="modal fade bs-device-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>
fred.perso's avatar
fred.perso committed
1200
                         <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
fred.perso's avatar
fred.perso committed
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
                     </div>
                     <div class="modal-body">
                         <p>{{ record.comment|safe }}
                         </p>
                     </div>
                 </div>
             </div>
         </div>
         {% endif %}
     '''
fred.perso's avatar
fred.perso committed
1211
    PHOTO_FILE = '''
1212
         {% if record.photo_file %}
fred.perso's avatar
fred.perso committed
1213 1214
         <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                 data-target=".bs-device-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
1215
             <i class="fa fa-fw fa-camera" aria-hidden="true"></i>
fred.perso's avatar
fred.perso committed
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
         </button>
         <div class="modal fade bs-device-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">Photo du dispositif</h4>
                     </div>
                     <div class="modal-body">
1227
                        <img src="{{ record.photo_file.url }}" width="100%"></img>
fred.perso's avatar
fred.perso committed
1228 1229 1230 1231 1232 1233
                     </div>
                 </div>
             </div>
         </div>
         {% endif %}
     '''
fred.perso's avatar
fred.perso committed
1234
    # id = tables.Column(accessor='id_device', verbose_name='id')
fred.perso's avatar
fred.perso committed
1235 1236 1237 1238 1239
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)
    photo = tables.TemplateColumn(
        PHOTO_FILE, verbose_name="Photo", orderable=False)
    actions = tables.TemplateColumn(
1240
        ACTIONS, verbose_name="Actions", orderable=False)
fred.perso's avatar
fred.perso committed
1241 1242

    class Meta:
fred.perso's avatar
fred.perso committed
1243
        model = Device
fred.perso's avatar
fred.perso committed
1244 1245
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
1246
        fields = ('actions', 'ref', 'type', 'height', 'width', 'photo', 'comment')
1247

fred.perso's avatar
fred.perso committed
1248

1249 1250
class SightingTable(tables.Table):
    ACTIONS = '''
1251 1252 1253 1254 1255 1256 1257 1258
                <div class="btn-group 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-sighting-history-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
1259 1260
                                class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                        <li><a href="{% url 'sights:sighting_detail' record.pk %}" title="Fiche détaillée"><i class="fa fa-fw fa-info-circle"></i> Fiche
1261
                            détaillée</a></li>
fred.perso's avatar
fred.perso committed
1262
                        <li><a href="{% url 'sights:sighting_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
1263 1264 1265 1266 1267
                        </li>
                        <li><a href="{% url 'sights:countdetail_create' record.pk %}" Title="Ajouter une observation détaillée"><i
                                class="fi-calendar"></i> Ajouter une observation détaillée</a></li>
                        <li role="separator" class="divider"></li>
                        <li style="color:red;"><a href="{% url 'sights:sighting_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
1268
                                class="fa fa-fw fa-trash"></i> Supprimer</a></li>
1269 1270 1271 1272 1273 1274 1275 1276 1277
                    </ul>
                </div>
                <div class="modal fade bs-sighting-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>
fred.perso's avatar
fred.perso committed
1278
                                <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
                            </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>
                '''
1292 1293
    COMMENT = '''
            {% if record.comment %}
1294 1295
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-sighting-comment-modal-md-{{ record.pk }}">
fred.perso's avatar
fred.perso committed
1296
                <i class="fa fa-comment" aria-hidden="true"></i>
1297 1298 1299 1300 1301 1302 1303 1304
            </button>
            <div class="modal fade bs-sighting-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>
fred.perso's avatar
fred.perso committed
1305
                            <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
1306 1307 1308 1309 1310 1311 1312 1313
                        </div>
                        <div class="modal-body">
                            <p>{{ record.comment|safe }}
                            </p>
                        </div>
                    </div>
                </div>
            </div>
1314 1315
            {% endif %}
        '''
1316 1317
    PLACETYPE = '''
        {% if record.session.place.type %}
1318 1319
        <a data-toggle="popover" title="Description" data-content="{{ record.session.place.type.descr }}">{{ record.session.place.type.code }}</a>
        {% endif %}      
1320 1321
    '''
    METHOD = '''
1322 1323
        {% if record.session.contact %}
        <a data-toggle="SightingSessionMethodToggle{{ record.pk }}">{{ record.session.contact.code }}</a>
1324
            <div class="dropdown-pane" id="SightingSessionMethodToggle{{ record.pk }}" data-dropdown>
1325
                {{ record.record.session.contact.descr }}
1326 1327 1328
            </div>
        {% endif %}
    '''
fred.perso's avatar
fred.perso committed
1329 1330 1331
    id = tables.Column(accessor='id_sighting', attrs={
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
fred.perso's avatar
fred.perso committed
1332
    common_name_fr = tables.LinkColumn('sights:sighting_detail', args=[A('id_sighting')],
1333
                                       accessor='codesp.common_name_fr', verbose_name='Espèce')
fred.perso's avatar
fred.perso committed
1334 1335 1336
    sci_name = tables.Column(accessor='codesp.sci_name', verbose_name='Nom scientifique', attrs={
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
1337
    sp_true = tables.BooleanColumn(accessor='codesp.sp_true', verbose_name=_('Espèce vraie'))
1338
    comment = tables.TemplateColumn(
fred.perso's avatar
fred.perso committed
1339
        COMMENT, verbose_name="Commentaire", orderable=False, exclude_from_export=True)
fred.perso's avatar
fred.perso committed
1340
    place = tables.LinkColumn('sights:place_detail', args=[
1341
        A('session.place.id_place')], accessor='session.place.name')
1342
    actions = tables.TemplateColumn(
1343
        ACTIONS, verbose_name="Actions", orderable=False, exclude_from_export=True)
1344
    placetype = tables.TemplateColumn(
fred.perso's avatar
fred.perso committed
1345
        PLACETYPE, accessor='session.place.type.descr', verbose_name='Type de localité', exclude_from_export=True)
1346 1347
    session = tables.LinkColumn('sights:session_detail', args=[
        A('session.id_session')], accessor='session.name')
1348
    study = tables.Column(accessor='session.study', verbose_name=_('Etude'), exclude_from_export=True)    
fred.perso's avatar
fred.perso committed
1349 1350 1351 1352 1353
    municipality = tables.Column(accessor='session.place.municipality',verbose_name=_('Commune'), exclude_from_export=True)
    export_x = tables.Column(accessor='session.place.geom.x', verbose_name='X', attrs={
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
    export_y = tables.Column(accessor='session.place.geom.y', verbose_name='Y', attrs={
1354 1355
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
fred.perso's avatar
fred.perso committed
1356 1357 1358 1359 1360 1361 1362 1363 1364 1365
    export_municipality = tables.Column(accessor='session.place.municipality.name', verbose_name=_('commune'), attrs={
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
    export_territory = tables.Column(accessor='session.place.territory', verbose_name=_('territoire'), attrs={
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
    export_comment = tables.Column(accessor='comment', verbose_name=_('commentaire'), attrs={
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
    export_placetype = tables.Column(accessor='session.place.type.descr', verbose_name=_('type_localite'), attrs={
1366 1367
        'th': {'style': 'display: none;'}, 'td': {'style': 'display:none;'}
    })
1368 1369

    class Meta:
fred.perso's avatar
fred.perso committed
1370
        # export_name = 'sightings'
1371
        model = Sighting
fred.perso's avatar
fred.perso committed
1372 1373
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
fred.perso's avatar
fred.perso committed
1374
        # exclude_column = ('actions', 'session.place.municipality', 'comment')
1375
        fields = (
1376
            'id','actions', 'common_name_fr', 'sci_name','sp_true', 'total_count', 'breed_colo', 'session', 'study', 'session.date_start',
fred.perso's avatar
fred.perso committed
1377
            'period', 'session.contact.descr', 'place', 'placetype', 'municipality','export_placetype', 'export_municipality', 'export_territory', 'export_x', 'export_y',
1378
            'observer.name_pretty', 'comment', 'export_comment')
1379 1380 1381 1382


class SightingExportTable(tables.Table):
    id = tables.Column(accessor='id_sighting', verbose_name='id')
1383
    common_name_fr = tables.Column(accessor='codesp.common_name_fr', verbose_name='Espèce')
1384 1385
    sp_true = tables.Column(accessor='codesp.sp_true',
                            verbose_name='Espèce vraie')
1386 1387
    x = tables.Column(accessor='session.place.geom.x', verbose_name='X')
    y = tables.Column(accessor='session.place.geom.y', verbose_name='Y')
1388
    place = tables.Column(accessor='session.place.name', verbose_name='Localité')
1389 1390
    placetype = tables.Column(
        accessor='session.place.type.descr', verbose_name='Type de localité')
1391

1392
    class Meta:
1393
        export_name = 'sightings.ext'
1394
        model = Sighting
fred.perso's avatar
fred.perso committed
1395 1396
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
1397
        fields = ('common_name_fr', 'sp_true', 'total_count', 'breed_colo', 'session',
1398
                  'place', 'placetype', 'session.place.municipality',
fred.perso's avatar
fred.perso committed
1399
                  'created_by', 'comment', 'geom', 'x', 'y')
1400

fred.perso's avatar
fred.perso committed
1401

1402 1403
class CountDetailBiomTable(tables.Table):
    ACTIONS = '''
1404 1405 1406 1407 1408 1409 1410 1411
            <div class="btn-group 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-cdbiom-modal-md-{{ record.pk }}" title="Historique de la donnée"><i
fred.perso's avatar
fred.perso committed
1412 1413
                            class="fa fa-fw fa-history"></i> Historique de la donnée</a></li>
                    <li><a href="{% url 'sights:countdetail_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
1414 1415 1416
                    </li>
                    <li role="separator" class="divider"></li>
                    <li style="color:red;"><a href="{% url 'sights:countdetail_delete' record.pk %}" title="Supprimer"><i
fred.perso's avatar
fred.perso committed
1417
                            class="fa fa-fw fa-trash"></i> Supprimer</a></li>
1418 1419 1420 1421 1422 1423 1424 1425 1426
                </ul>
            </div>
            <div class="modal fade bs-cdbiom-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>
fred.perso's avatar
fred.perso committed
1427
                            <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-history"></i> Historique</h4>
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439
                        </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>
1440 1441
            '''
    COMMENT = '''
fred.perso's avatar
fred.perso committed
1442 1443 1444 1445
            {% if record.comment %}
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-cdbiom-comment-modal-md-{{ record.pk }}">
                <i class="fa fa-comment" aria-hidden="true"></i>
1446 1447 1448 1449 1450 1451 1452 1453
             </button>
             <div class="modal fade bs-cdbiom-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>
fred.perso's avatar
fred.perso committed
1454
                             <h4 class="modal-title" id="exampleModalLabel"><i class="fa fa-fw fa-comment"></i>Commentaire</h4>
1455 1456 1457 1458 1459 1460 1461 1462 1463 1464
                         </div>
                         <div class="modal-body">
                             <p>{{ record.comment|safe }}
                             </p>
                         </div>
                     </div>
                 </div>
             </div>
             {% endif %}
         '''
1465 1466
    TIME = '''
            {{ record.time|time:"H:i" }}'''
1467
    actions = tables.TemplateColumn(
1468
        ACTIONS, verbose_name="Actions", orderable=False)
1469 1470
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)
1471 1472
    time = tables.TemplateColumn(
        TIME, verbose_name=_('Heure'), orderable=False)
1473

fred.perso's avatar
fred.perso committed
1474 1475
    class Meta:
        model = CountDetail
fred.perso's avatar
fred.perso committed
1476 1477
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
fred.perso's avatar
fred.perso committed
1478
        fields = (
fred.perso's avatar
fred.perso committed
1479 1480
            'actions', 'method.descr', 'sex', 'age', 'time', 'device', 'manipulator', 'validator', 'transmitter', 'ab',
            'd5',
1481 1482 1483 1484
            'd3', 'pouce', 'queue', 'tibia', 'pied', 'cm3', 'tragus', 'poids', 'testicule.short_descr',
            'epididyme.short_descr', 'tuniq_vag.short_descr', 'gland_taille.short_descr', 'gland_coul.short_descr',
            'mamelle.short_descr', 'gestation.short_descr', 'epiphyse.short_descr', 'chinspot.short_descr',
            'usure_dent.short_descr', 'comment')
fred.perso's avatar
fred.perso committed
1485 1486


1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558
class CountDetailTelemetryTable(tables.Table):
    ACTIONS = '''
            <div class="btn-group 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-cdother-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:countdetail_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
                    </li>
                    <li role="separator" class="divider"></li>
                    <li style="color:red;"><a href="{% url 'sights:countdetail_delete' record.pk %}" title="Supprimer"><i
                            class="fa fa-fw fa-trash"></i> Supprimer</a></li>
                </ul>
            </div>
            <div class="modal fade bs-cdother-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>
            '''
    COMMENT = '''
            {% if record.comment %}
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-cdother-comment-modal-md-{{ record.pk }}">
                <i class="fa fa-comment" aria-hidden="true"></i>
             </button>
             <div class="modal fade bs-cdother-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 %}
         '''
    actions = tables.TemplateColumn(
        ACTIONS, verbose_name="Actions", orderable=False)
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)

    class Meta:
        model = CountDetail
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
fred.perso's avatar
fred.perso committed
1559
        fields = ('actions', 'time', 'method', 'transmitter', 'comment')
fred.perso's avatar
fred.perso committed
1560 1561


fred.perso's avatar
fred.perso committed
1562 1563
class CountDetailOtherTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
            <div class="btn-group 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-cdother-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:countdetail_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
                    </li>
                    <li role="separator" class="divider"></li>
                    <li style="color:red;"><a href="{% url 'sights:countdetail_delete' record.pk %}" title="Supprimer"><i
                            class="fa fa-fw fa-trash"></i> Supprimer</a></li>
                </ul>
            </div>
            <div class="modal fade bs-cdother-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>
fred.perso's avatar
fred.perso committed
1600 1601 1602
            '''
    COMMENT = '''
            {% if record.comment %}
fred.perso's avatar
fred.perso committed
1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal"
                    data-target=".bs-cdother-comment-modal-md-{{ record.pk }}">
                <i class="fa fa-comment" aria-hidden="true"></i>
             </button>
             <div class="modal fade bs-cdother-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 %}
         '''
fred.perso's avatar
fred.perso committed
1625
    actions = tables.TemplateColumn(
1626
        ACTIONS, verbose_name="Actions", orderable=False)
fred.perso's avatar
fred.perso committed
1627 1628 1629 1630 1631
    comment = tables.TemplateColumn(
        COMMENT, verbose_name="Commentaire", orderable=False)

    class Meta:
        model = CountDetail
fred.perso's avatar
fred.perso committed
1632 1633
        template = 'table_bootstrap.html'
        attrs = {'class': 'table table-striped table-condensed'}
fred.perso's avatar
fred.perso committed
1634
        fields = ('actions', 'time', 'method', 'sex', 'age', 'count', 'unit', 'precision', 'transmitter', 'comment')
fred.perso's avatar
fred.perso committed
1635 1636 1637 1638


class CountDetailAcousticTable(tables.Table):
    ACTIONS = '''
fred.perso's avatar
fred.perso committed
1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674
            <div class="btn-group 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-cdacous-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:countdetail_update' record.pk %}" title="Modifier"><i class="fa fa-fw fa-pencil-square-o"></i> Modifier</a>
                    </li>
                    <li role="separator" class="divider"></li>
                    <li style="color:red;"><a href="{% url 'sights:countdetail_delete' record.pk %}" title="Supprimer"><i
                            class="fa fa-fw fa-trash"></i> Supprimer</a></li>
                </ul>
            </div>
            &l