From c629787630dd37a222aa77113af7d9f5db5cab74 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 5 Sep 2018 15:31:35 +1200 Subject: [PATCH] rrs: show warnings for missing current release/milestone If there is no release or milestone covering the current date, show an error message at the top of the recipes list page to alert the user that they can't view current data (since this is a common cause of not being able to see that which may not be immediately apparent). Additionally, show a warning within rrs_upgrade_history when this happens. Signed-off-by: Paul Eggleton --- rrs/tools/rrs_upgrade_history.py | 15 ++++++++++++--- rrs/views.py | 10 ++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/rrs/tools/rrs_upgrade_history.py b/rrs/tools/rrs_upgrade_history.py index 7b0568c..f39e5c6 100755 --- a/rrs/tools/rrs_upgrade_history.py +++ b/rrs/tools/rrs_upgrade_history.py @@ -10,12 +10,11 @@ # # Licensed under the MIT license, see COPYING.MIT for details -from datetime import datetime, timedelta - import sys import os.path import optparse import logging +from datetime import date, datetime, timedelta sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__)))) from common import common_setup, get_logger @@ -87,7 +86,7 @@ def run_internal(maintplanlayerbranch, commit, commitdate, options, logger, bitb Upgrade history handler. """ def upgrade_history(options, logger): - from rrs.models import MaintenancePlan, RecipeUpgrade + from rrs.models import MaintenancePlan, RecipeUpgrade, Release, Milestone if options.plan: maintplans = MaintenancePlan.objects.filter(id=int(options.plan)) @@ -107,6 +106,16 @@ def upgrade_history(options, logger): sys.exit(1) try: for maintplan in maintplans: + # Check releases and milestones + current = date.today() + current_release = Release.get_by_date(maintplan, current) + if current_release: + current_milestone = Milestone.get_by_release_and_date(current_release, current) + if not current_milestone: + logger.warning('%s: there is no milestone defined in the latest release (%s) that covers the current date, so up-to-date data will not be visible in the web interface.' % (maintplan, current_release)) + else: + logger.warning('%s: there is no release defined that covers the current date, so up-to-date data will not be visible in the web interface.' % maintplan) + for maintplanbranch in maintplan.maintenanceplanlayerbranch_set.all(): layerbranch = maintplanbranch.layerbranch if options.fullreload and not options.dry_run: diff --git a/rrs/views.py b/rrs/views.py index 03fe474..70e80b9 100644 --- a/rrs/views.py +++ b/rrs/views.py @@ -9,6 +9,7 @@ from django.shortcuts import get_object_or_404 from django.views.generic import TemplateView, ListView, DetailView, RedirectView from django.core.urlresolvers import resolve, reverse, reverse_lazy from django.db import connection +from django.contrib import messages from layerindex.models import Recipe, StaticBuildDep, Patch from rrs.models import Release, Milestone, Maintainer, RecipeMaintainerHistory, \ @@ -542,6 +543,15 @@ class RecipeListView(ListView): context['milestone_name'] = self.milestone_name context['all_milestones'] = Milestone.get_by_release_name(maintplan, self.release_name) + current = date.today() + current_release = Release.get_by_date(maintplan, current) + if current_release: + current_milestone = Milestone.get_by_release_and_date(current_release, current) + if not current_milestone: + messages.error(self.request, 'There is no milestone defined in the latest release (%s) that covers the current date, so data shown here is not up-to-date. The administrator will need to create a milestone in order to fix this.' % current_release) + else: + messages.error(self.request, 'There is no release defined that covers the current date, so data shown here is not up-to-date. The administrator will need to create a release (and corresponding milestones) in order to fix this.') + context['recipes_percentage'] = self.milestone_statistics['percentage'] context['recipes_all_upgraded'] = self.milestone_statistics['all_upgraded'] context['recipes_all_not_upgraded'] = self.milestone_statistics['all_not_upgraded']