Default bootstrap tables

* adds basic bootstrap classes to BaseTable model
This commit is contained in:
mipel 2021-07-20 14:23:16 +02:00
parent 8c32aaa845
commit d2340ffe0a
5 changed files with 39 additions and 9 deletions

View File

@ -26,9 +26,10 @@ class Intervention(BaseObject):
registration_file_number = models.CharField(max_length=1000, blank=True, null=True) registration_file_number = models.CharField(max_length=1000, blank=True, null=True)
conservation_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+") conservation_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
conservations_file_number = models.CharField(max_length=1000, blank=True, null=True) conservations_file_number = models.CharField(max_length=1000, blank=True, null=True)
process_type = models.CharField(max_length=500, null=True, blank=True) process_type = models.CharField(max_length=500, null=True, blank=True)
law = models.CharField(max_length=500, null=True, blank=True) law = models.CharField(max_length=500, null=True, blank=True)
handler = models.CharField(max_length=500, null=True, blank=True) handler = models.CharField(max_length=500, null=True, blank=True, help_text="Who is responsible for this intervention?")
geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL) geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL)
documents = models.ManyToManyField("konova.Document", blank=True) documents = models.ManyToManyField("konova.Document", blank=True)

View File

@ -25,17 +25,34 @@ class InterventionTable(BaseTable):
orderable=True, orderable=True,
accessor="title", accessor="title",
) )
d = tables.Column( c = tables.Column(
verbose_name=_("Created on"), verbose_name=_("Checked"),
orderable=True,
accessor="recorded_on",
)
r = tables.Column(
verbose_name=_("Registered"),
orderable=True,
accessor="recorded_on",
)
lm = tables.Column(
verbose_name=_("Last edit"),
orderable=True, orderable=True,
accessor="created_on", accessor="created_on",
) )
"""
# ToDo: Decide to keep actions column or to dismiss them
ac = tables.Column( ac = tables.Column(
verbose_name=_("Actions"), verbose_name=_("Actions"),
orderable=False, orderable=False,
empty_values=[], empty_values=[],
attrs={"td": {"class": "action-col"}} attrs={"td": {"class": "action-col"}}
) )
"""
class Meta(BaseTable.Meta):
pass
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)

View File

@ -25,6 +25,11 @@ class BaseTable(tables.tables.Table):
add_new_url = None add_new_url = None
title = None title = None
class Meta:
attrs = {
"class": "table table-hover",
}
def __init__(self, request: HttpRequest = None, filter_set=None, queryset=None, *args, **kwargs): def __init__(self, request: HttpRequest = None, filter_set=None, queryset=None, *args, **kwargs):
self.user = request.user or None self.user = request.user or None
if filter_set is not None: if filter_set is not None:

View File

@ -9,7 +9,7 @@ django-debug-toolbar==3.1.1
django-filter==2.4.0 django-filter==2.4.0
django-fontawesome-5==1.0.18 django-fontawesome-5==1.0.18
django-simple-sso==0.14.1 django-simple-sso==0.14.1
django-tables2==2.3.3 django-tables2==2.3.4
idna==2.10 idna==2.10
importlib-metadata==2.1.1 importlib-metadata==2.1.1
itsdangerous==1.1.0 itsdangerous==1.1.0

View File

@ -20,6 +20,10 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% comment %}
Search input and rpp selector
{% endcomment %}
<div class="row my-1"> <div class="row my-1">
<div class="col-sm-12 col-md"> <div class="col-sm-12 col-md">
<form method="get" action="{{table.filter}}"> <form method="get" action="{{table.filter}}">
@ -49,9 +53,12 @@
</div> </div>
</div> </div>
</div> </div>
&nbsp;
</div> </div>
{% comment %}
Filter section
{% endcomment %}
<div class="row"> <div class="row">
<div class="col-md"> <div class="col-md">
<div class="card"> <div class="card">
@ -72,7 +79,7 @@
</div> </div>
</div> </div>
</div> </div>
{% comment %}
<div class="table-container"> Table section
{% endcomment %}
{% render_table table %} {% render_table table %}
</div>