better lots group table
This commit is contained in:
parent
81cd13dae4
commit
e974a6744d
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<a href="{% url 'lot:add' %}" type="button" class="btn btn-green-admin">
|
<a href="{% url 'lot:add' %}" type="button" class="btn btn-green-admin mb-3">
|
||||||
<i class="bi bi-plus"></i>
|
<i class="bi bi-plus"></i>
|
||||||
{% trans 'Add new lot' %}
|
{% trans 'Add new lot' %}
|
||||||
</a>
|
</a>
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
<!-- Search and Filter Section -->
|
<!-- Search and Filter Section -->
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<!-- Search Input -->
|
<!-- Search Input -->
|
||||||
<div class="col-md-6">
|
<div class="col-md-6 mb-3">
|
||||||
<form method="get" class="d-flex">
|
<form method="get" class="d-flex">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="q"
|
name="q"
|
||||||
class="form-control me-2"
|
class="form-control me-2"
|
||||||
placeholder="{% trans 'Search lots...' %}"
|
placeholder="{% trans 'Search by name or description...' %}"
|
||||||
value="{{ search_query }}">
|
value="{{ search_query }}">
|
||||||
<button type="submit" class="btn btn-outline-secondary">
|
<button type="submit" class="btn btn-outline-secondary">
|
||||||
<i class="bi bi-search"></i>
|
<i class="bi bi-search"></i>
|
||||||
|
@ -61,9 +61,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Lots list -->
|
||||||
{% render_table table %}
|
{% render_table table %}
|
||||||
<div class="mt-5 d-flex align-items-center justify-content-center">
|
<div class="mt-5 d-flex align-items-center justify-content-center">
|
||||||
{% if table.page and table.paginator.num_pages > 1 %}
|
{% if table.page and table.paginator.num_pages > 1 %}
|
||||||
{% include "django_tables2/pagination.html" %}
|
{% include "django_tables2/pagination.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>{% endblock %}
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% bootstrap_form form %}
|
{% bootstrap_form form %}
|
||||||
<div class="form-actions-no-box">
|
<div class="form-actions-no-box">
|
||||||
<a class="btn btn-grey" href="{% url 'dashboard:unassigned' %}">{% translate "Cancel" %}</a>
|
<a class="btn btn-grey" href="{{ request.META.HTTP_REFERER }}">{% translate "Cancel" %}</a>
|
||||||
|
|
||||||
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
|
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
18
lot/views.py
18
lot/views.py
|
@ -3,6 +3,7 @@ from django.urls import reverse_lazy
|
||||||
from django.shortcuts import get_object_or_404, redirect, Http404
|
from django.shortcuts import get_object_or_404, redirect, Http404
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.views.generic.edit import (
|
from django.views.generic.edit import (
|
||||||
|
@ -180,25 +181,30 @@ class DelToLotView(AddToLotView):
|
||||||
|
|
||||||
|
|
||||||
class LotTable(tables.Table):
|
class LotTable(tables.Table):
|
||||||
name = tables.Column(linkify=("dashboard:lot", {"pk": tables.A("id")}), verbose_name=_("Lot Name"))
|
name = tables.Column(linkify=("dashboard:lot", {"pk": tables.A("id")}), verbose_name=_("Lot Name"), attrs={"td": {"class": "fw-bold"}})
|
||||||
description = tables.Column(verbose_name=_("Description"), default="No description")
|
description = tables.Column(verbose_name=_("Description"), default=_("No description"),attrs={"td": {"class": "text-muted"}} )
|
||||||
closed = tables.Column(verbose_name=_("Status"))
|
closed = tables.Column(verbose_name=_("Status"))
|
||||||
created = tables.DateColumn(format="Y-m-d", verbose_name=_("Created On"))
|
created = tables.DateColumn(format="Y-m-d", verbose_name=_("Created On"))
|
||||||
user = tables.Column(verbose_name=_("Created By"), default="Unknown")
|
user = tables.Column(verbose_name=("Created By"), default=_("Unknown"), attrs={"td": {"class": "text-muted"}} )
|
||||||
actions = tables.TemplateColumn(
|
actions = tables.TemplateColumn(
|
||||||
template_name="lot_actions.html",
|
template_name="lot_actions.html",
|
||||||
verbose_name=_("Actions"),
|
verbose_name=_(""),
|
||||||
orderable=False,
|
|
||||||
attrs={"td": {"class": "text-end"}}
|
attrs={"td": {"class": "text-end"}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def render_closed(self, value):
|
||||||
|
if value:
|
||||||
|
return mark_safe('<span class="badge bg-danger">Closed</span>')
|
||||||
|
return mark_safe('<span class="badge bg-success">Open</span>')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Lot
|
model = Lot
|
||||||
fields = ("name", "description", "closed", "created", "user", "actions")
|
fields = ("closed", "name", "description", "created", "user", "actions")
|
||||||
attrs = {
|
attrs = {
|
||||||
"class": "table table-hover align-middle",
|
"class": "table table-hover align-middle",
|
||||||
"thead": {"class": "table-light"}
|
"thead": {"class": "table-light"}
|
||||||
}
|
}
|
||||||
|
order_by = ("-created",)
|
||||||
|
|
||||||
|
|
||||||
class LotsTagsView(DashboardView, tables.SingleTableView):
|
class LotsTagsView(DashboardView, tables.SingleTableView):
|
||||||
|
|
Loading…
Reference in a new issue