|
1 | | -# Copyright The IETF Trust 2009-2020, All Rights Reserved |
| 1 | +# Copyright The IETF Trust 2009-2022, All Rights Reserved |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 | # |
4 | 4 | # Some parts Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
@@ -307,6 +307,32 @@ def cached_redirect(cache_key, url): |
307 | 307 |
|
308 | 308 | return cached_redirect(cache_key, urlreverse('ietf.doc.views_search.search') + search_args) |
309 | 309 |
|
| 310 | +def ad_dashboard_group_type(doc): |
| 311 | + # Return group type for document for dashboard. |
| 312 | + # If doc is not defined return list of all possible |
| 313 | + # group types |
| 314 | + if not doc: |
| 315 | + return ('I-D', 'RFC', 'Conflict Review', 'Status Change', 'Charter') |
| 316 | + if doc.type.slug=='draft': |
| 317 | + if doc.get_state_slug('draft') == 'rfc': |
| 318 | + return 'RFC' |
| 319 | + elif doc.get_state_slug('draft') == 'active' and doc.get_state_slug('draft-iesg') and doc.get_state('draft-iesg').name =='RFC Ed Queue': |
| 320 | + return 'RFC' |
| 321 | + elif doc.get_state_slug('draft') == 'active' and doc.get_state_slug('draft-iesg') and doc.get_state('draft-iesg').name in ('Dead', 'I-D Exists', 'AD is watching'): |
| 322 | + return None |
| 323 | + elif doc.get_state('draft').name in ('Expired', 'Replaced'): |
| 324 | + return None |
| 325 | + else: |
| 326 | + return 'I-D' |
| 327 | + elif doc.type.slug=='conflrev': |
| 328 | + return 'Conflict Review' |
| 329 | + elif doc.type.slug=='statchg': |
| 330 | + return 'Status Change' |
| 331 | + elif doc.type.slug=='charter': |
| 332 | + return "Charter" |
| 333 | + else: |
| 334 | + return "Document" |
| 335 | + |
310 | 336 | def ad_dashboard_group(doc): |
311 | 337 |
|
312 | 338 | if doc.type.slug=='draft': |
@@ -338,6 +364,12 @@ def ad_dashboard_group(doc): |
338 | 364 | else: |
339 | 365 | return "Document" |
340 | 366 |
|
| 367 | +def shorten_group_name(name): |
| 368 | + for s in [' Internet-Draft', ' Conflict Review', ' Status Change', ' (Internal Steering Group/IAB Review) Charter', 'Charter']: |
| 369 | + if name.endswith(s): |
| 370 | + name = name[:-len(s)] |
| 371 | + return name |
| 372 | + |
341 | 373 | def ad_dashboard_sort_key(doc): |
342 | 374 |
|
343 | 375 | if doc.type.slug=='draft' and doc.get_state_slug('draft') == 'rfc': |
@@ -393,6 +425,107 @@ def ad_dashboard_sort_key(doc): |
393 | 425 |
|
394 | 426 | return "3%s" % seed |
395 | 427 |
|
| 428 | +def ad_workload(request): |
| 429 | + ads = [] |
| 430 | + responsible = Document.objects.values_list('ad', flat=True).distinct() |
| 431 | + for p in Person.objects.filter( |
| 432 | + Q( |
| 433 | + role__name__in=("pre-ad", "ad"), |
| 434 | + role__group__type="area", |
| 435 | + role__group__state="active" |
| 436 | + ) |
| 437 | + | Q(pk__in=responsible) |
| 438 | + ).distinct(): |
| 439 | + if p in get_active_ads(): |
| 440 | + ads.append(p) |
| 441 | + |
| 442 | + doctypes = list(DocTypeName.objects.filter(used=True).exclude(slug='draft').values_list("pk", flat=True)) |
| 443 | + |
| 444 | + group_types = ad_dashboard_group_type(None) |
| 445 | + |
| 446 | + groups = {} |
| 447 | + group_names = {} |
| 448 | + for g in group_types: |
| 449 | + groups[g] = {} |
| 450 | + group_names[g] = [] |
| 451 | + |
| 452 | + # Prefill groups in preferred sort order |
| 453 | + id = 0 |
| 454 | + for g in [ |
| 455 | + 'Publication Requested Internet-Draft', |
| 456 | + 'Waiting for Writeup Internet-Draft', |
| 457 | + 'AD Evaluation Internet-Draft', |
| 458 | + 'In Last Call Internet-Draft', |
| 459 | + 'IESG Evaluation - Defer Internet-Draft', |
| 460 | + 'IESG Evaluation Internet-Draft', |
| 461 | + 'Waiting for AD Go-Ahead Internet-Draft', |
| 462 | + 'Approved-announcement to be sent Internet-Draft', |
| 463 | + 'Approved-announcement sent Internet-Draft']: |
| 464 | + groups['I-D'][g] = id |
| 465 | + group_names['I-D'].append(g) |
| 466 | + id += 1; |
| 467 | + id = 0 |
| 468 | + for g in ['RFC Ed Queue Internet-Draft', 'RFC']: |
| 469 | + groups['RFC'][g] = id |
| 470 | + group_names['RFC'].append(g) |
| 471 | + id += 1; |
| 472 | + id = 0 |
| 473 | + for g in ['AD Review Conflict Review', |
| 474 | + 'Needs Shepherd Conflict Review', |
| 475 | + 'IESG Evaluation Conflict Review', |
| 476 | + 'Approved Conflict Review', |
| 477 | + 'Withdrawn Conflict Review']: |
| 478 | + groups['Conflict Review'][g] = id |
| 479 | + group_names['Conflict Review'].append(g) |
| 480 | + id += 1; |
| 481 | + id = 0 |
| 482 | + for g in [ 'Start Chartering/Rechartering (Internal Steering Group/IAB Review) Charter', |
| 483 | + 'Replaced Charter', |
| 484 | + 'Approved Charter', |
| 485 | + 'Not currently under review Charter']: |
| 486 | + groups['Charter'][g] = id |
| 487 | + group_names['Charter'].append(g) |
| 488 | + id += 1; |
| 489 | + |
| 490 | + for ad in ads: |
| 491 | + form = SearchForm({'by':'ad','ad': ad.id, |
| 492 | + 'rfcs':'on', 'activedrafts':'on', |
| 493 | + 'olddrafts':'on', |
| 494 | + 'doctypes': doctypes}) |
| 495 | + data = retrieve_search_results(form) |
| 496 | + ad.dashboard = urlreverse("ietf.doc.views_search.docs_for_ad", kwargs=dict(name=ad.full_name_as_key())) |
| 497 | + counts = {} |
| 498 | + for g in group_types: |
| 499 | + counts[g] = [] |
| 500 | + for doc in data: |
| 501 | + group_type = ad_dashboard_group_type(doc) |
| 502 | + if group_type and group_type in groups: # Right now, anything with group_type "Document", such as a bofreq is not handled. |
| 503 | + group = ad_dashboard_group(doc) |
| 504 | + if group not in groups[group_type]: |
| 505 | + groups[group_type][group] = len(groups[group_type]) |
| 506 | + group_names[group_type].append(group) |
| 507 | + if len(counts[group_type]) < len(groups[group_type]): |
| 508 | + counts[group_type].extend([0] * (len(groups[group_type]) - len(counts[group_type]))) |
| 509 | + counts[group_type][groups[group_type][group]] += 1 |
| 510 | + ad.counts = counts |
| 511 | + for ad in ads: |
| 512 | + for group_type in group_types: |
| 513 | + if len(ad.counts[group_type]) < len(groups[group_type]): |
| 514 | + ad.counts[group_type].extend([0] * (len(groups[group_type]) - len(ad.counts[group_type]))) |
| 515 | + # Shorten the names of groups |
| 516 | + for gt in group_types: |
| 517 | + for idx,g in enumerate(group_names[gt]): |
| 518 | + group_names[gt][idx] = shorten_group_name(g) |
| 519 | + |
| 520 | + workload = [] |
| 521 | + for gt in group_types: |
| 522 | + workload.append(dict(group_type=gt,group_names=group_names[gt],counts=[(ad, [(group_names[gt][index],ad.counts[gt][index]) for index in range(len(group_names[gt]))]) for ad in ads])) |
| 523 | + |
| 524 | + return render(request, 'doc/ad_list.html', { |
| 525 | + 'workload': workload |
| 526 | + }) |
| 527 | + |
| 528 | + |
396 | 529 | def docs_for_ad(request, name): |
397 | 530 | ad = None |
398 | 531 | responsible = Document.objects.values_list('ad', flat=True).distinct() |
@@ -454,7 +587,6 @@ def docs_for_ad(request, name): |
454 | 587 | return render(request, 'doc/drafts_for_ad.html', { |
455 | 588 | 'form':form, 'docs':results, 'meta':meta, 'ad_name': ad.plain_name(), 'blocked_docs': blocked_docs |
456 | 589 | }) |
457 | | - |
458 | 590 | def drafts_in_last_call(request): |
459 | 591 | lc_state = State.objects.get(type="draft-iesg", slug="lc").pk |
460 | 592 | form = SearchForm({'by':'state','state': lc_state, 'rfcs':'on', 'activedrafts':'on'}) |
|
0 commit comments