MT#56231 repoapi: DateRange for GerritRepoInfo

* supports date filters in admin panel

Change-Id: I4c9580ff2ffa3f50301ff8f8d30bd060a9cae4e7
master
Victor Seva 2 years ago
parent 14a01512a3
commit dec3d012c5

@ -1,4 +1,4 @@
# Copyright (C) 2015-2022 The Sipwise Team - http://sipwise.com
# Copyright (C) 2015-2023 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
from django.contrib import admin
from django_admin_filters import DateRange
from import_export import resources
from import_export.admin import ImportExportModelAdmin
@ -35,10 +36,30 @@ class JenkinsBuildInfoAdmin(ImportExportModelAdmin):
list_filter = ("param_release", "projectname")
class GRIDateRange(DateRange):
FILTER_LABEL = "Modified range"
BUTTON_LABEL = "Select range"
FROM_LABEL = "From"
TO_LABEL = "To"
ALL_LABEL = "All"
CUSTOM_LABEL = "custom range"
DATE_FORMAT = "YYYY-MM-DD HH:mm"
is_null_option = False
day_val = 60 * 60 * 24
month_val = day_val * 30
options = (
("1dp", "last 24 hours", -day_val),
("1mp", "last 30 days", -month_val),
("3mp", "last 3 months", -month_val * 3),
)
@admin.register(models.GerritRepoInfo)
class GerritRepoInfoAdmin(ImportExportModelAdmin):
resource_class = GerritRepoInfoResource
list_filter = ("param_ppa", "projectname")
list_filter = (("modified", GRIDateRange), "projectname", "param_ppa")
class WorkfrontNoteInfoResource(resources.ModelResource):

@ -35,6 +35,7 @@ INSTALLED_APPS = [
"django_celery_results",
"django_extensions",
"django_filters",
"django_admin_filters",
"crispy_forms",
"jsonify",
"import_export",

@ -1,5 +1,6 @@
celery
Django==3.2.18
django-admin-list-filters
django-appconf
django-assets
django-celery-beat

@ -5,7 +5,7 @@ FROM docker.mgm.sipwise.com/sipwise-bullseye:latest
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT 2022-10-11
ENV REFRESHED_AT 2023-03-04
RUN apt-get update && apt-get install --assume-yes python3 python3-dev \
python3-pytest python3-pytest-pep8 \

Loading…
Cancel
Save