Commit 36367408 authored by Enrico Zini's avatar Enrico Zini
Browse files

Hide emeritus processes 30 days when waiting for a reply, 5 days after emeritus intent

parent 6909d8ac
...@@ -5,7 +5,6 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -5,7 +5,6 @@ from django.utils.translation import ugettext_lazy as _
from django.utils.timezone import utc, now from django.utils.timezone import utc, now
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
from django.utils.timezone import now
from django.urls import reverse from django.urls import reverse
from django.contrib.auth.models import BaseUserManager, PermissionsMixin from django.contrib.auth.models import BaseUserManager, PermissionsMixin
from django.forms.models import model_to_dict from django.forms.models import model_to_dict
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-12 18:22
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('process', '0004_merge_20170810_1547'),
]
operations = [
migrations.AddField(
model_name='process',
name='started',
field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='process started'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-12 18:22
from __future__ import unicode_literals
from django.db import migrations
from django.utils.timezone import now
def add_process_started(apps, schema_editor):
# We can't import the Person model directly as it may be a newer
# version than this migration expects. We use the historical version.
Process = apps.get_model('process', 'Process')
for process in Process.objects.all():
try:
process.started = process.log.order_by("logdate")[0].logdate
except IndexError:
process.started = now()
process.save()
class Migration(migrations.Migration):
dependencies = [
('process', '0005_process_started'),
]
operations = [
migrations.RunPython(add_process_started),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-08-12 18:25
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('process', '0006_auto_20170812_1822'),
]
operations = [
migrations.AlterField(
model_name='process',
name='started',
field=models.DateTimeField(auto_now_add=True, verbose_name='process started'),
),
]
...@@ -211,6 +211,7 @@ class ProcessManager(models.Manager): ...@@ -211,6 +211,7 @@ class ProcessManager(models.Manager):
class Process(models.Model): class Process(models.Model):
person = models.ForeignKey(bmodels.Person, related_name="+") person = models.ForeignKey(bmodels.Person, related_name="+")
applying_for = models.CharField("target status", max_length=20, null=False, choices=[x[1:3] for x in const.ALL_STATUS]) applying_for = models.CharField("target status", max_length=20, null=False, choices=[x[1:3] for x in const.ALL_STATUS])
started = models.DateTimeField(auto_now_add=True, verbose_name='process started')
frozen_by = models.ForeignKey(bmodels.Person, related_name="+", blank=True, null=True, help_text=_("Person that froze this process for review, or NULL if it is still being worked on")) frozen_by = models.ForeignKey(bmodels.Person, related_name="+", blank=True, null=True, help_text=_("Person that froze this process for review, or NULL if it is still being worked on"))
frozen_time = models.DateTimeField(null=True, blank=True, help_text=_("Date the process was frozen for review, or NULL if it is still being worked on")) frozen_time = models.DateTimeField(null=True, blank=True, help_text=_("Date the process was frozen for review, or NULL if it is still being worked on"))
approved_by = models.ForeignKey(bmodels.Person, related_name="+", blank=True, null=True, help_text=_("Person that reviewed this process and considered it complete, or NULL if not yet reviewed")) approved_by = models.ForeignKey(bmodels.Person, related_name="+", blank=True, null=True, help_text=_("Person that reviewed this process and considered it complete, or NULL if not yet reviewed"))
......
...@@ -28,24 +28,42 @@ class AMMain(VisitorTemplateView): ...@@ -28,24 +28,42 @@ class AMMain(VisitorTemplateView):
should not. should not.
""" """
if process.frozen_by_id is not None or process.approved_by_id is not None: return True if process.frozen_by_id is not None or process.approved_by_id is not None: return True
for_ga = process.applying_for in (const.STATUS_DC_GA, const.STATUS_DM_GA)
if process.applying_for == const.STATUS_EMERITUS_DD:
needs_am_report = False inactive_threshold = now() - datetime.timedelta(days=30)
for req in process.requirements.all(): confirmed_threshold = now() - datetime.timedelta(days=5)
if req.type == "intent": intent = process.requirements.get(type="intent")
if not req.approved_by_id: return False status = intent.compute_status()
# Hide all processes with a statement of intent approved less if status["satisfied"]:
# than 4 days ago # if intent is satisfied, the person requested emeritus, show
if not for_ga and req.approved_time + datetime.timedelta(days=4) > now(): return False # it after 5 days it's been satisfied
elif req.type == "sc_dmup": #if not for_ga and req.approved_time + datetime.timedelta(days=4) > now(): return False
if not req.approved_by_id: return False if intent.statement.uploaded_time > confirmed_threshold:
elif req.type == "advocate": return False
if not req.approved_by_id: return False else:
elif req.type == "am_ok": # if intent is not satisfied, MIA pinged and we wait a
needs_am_report = req.approved_by_id is None # month before showing the process
if process.started > inactive_threshold:
if needs_am_report and process.current_am_assignment: return False
return False else:
for_ga = process.applying_for in (const.STATUS_DC_GA, const.STATUS_DM_GA)
needs_am_report = False
for req in process.requirements.all():
if req.type == "intent":
if not req.approved_by_id: return False
# Hide all processes with a statement of intent approved less
# than 4 days ago
if not for_ga and req.approved_time + datetime.timedelta(days=4) > now(): return False
elif req.type == "sc_dmup":
if not req.approved_by_id: return False
elif req.type == "advocate":
if not req.approved_by_id: return False
elif req.type == "am_ok":
needs_am_report = req.approved_by_id is None
if needs_am_report and process.current_am_assignment:
return False
return True return True
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment