Merged in [15342] from peter@akayla.com:
Added optional reviewer unavailability reason support. Fixes issue #2146.
- Legacy-Id: 15375
Note: SVN reference [15342] has been migrated to Git commit f4eba7d4df
This commit is contained in:
commit
ed208a5ebb
|
@ -285,7 +285,7 @@ class ReviewerSettingsForm(forms.ModelForm):
|
|||
class AddUnavailablePeriodForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = UnavailablePeriod
|
||||
fields = ['start_date', 'end_date', 'availability']
|
||||
fields = ['start_date', 'end_date', 'availability', 'reason']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AddUnavailablePeriodForm, self).__init__(*args, **kwargs)
|
||||
|
|
|
@ -428,6 +428,7 @@ class ReviewTests(TestCase):
|
|||
'start_date': start_date.isoformat(),
|
||||
'end_date': "",
|
||||
'availability': "unavailable",
|
||||
'reason': "Whimsy",
|
||||
})
|
||||
self.assertEqual(r.status_code, 302)
|
||||
period = UnavailablePeriod.objects.get(person=reviewer, team=review_req.team, start_date=start_date)
|
||||
|
@ -437,6 +438,7 @@ class ReviewTests(TestCase):
|
|||
msg_content = outbox[0].get_payload(decode=True).decode("utf-8").lower()
|
||||
self.assertTrue(start_date.isoformat(), msg_content)
|
||||
self.assertTrue("indefinite", msg_content)
|
||||
self.assertEqual(period.reason, "Whimsy")
|
||||
|
||||
# end unavailable period
|
||||
empty_outbox()
|
||||
|
|
|
@ -1704,10 +1704,11 @@ def change_reviewer_settings(request, acronym, reviewer_email, group_type=None):
|
|||
in_the_past = period.end_date and period.end_date < today
|
||||
|
||||
if not in_the_past:
|
||||
msg = "Unavailable for review: {} - {} ({})".format(
|
||||
msg = "Unavailable for review: {} - {} ({}) {}".format(
|
||||
period.start_date.isoformat() if period.start_date else "indefinite",
|
||||
period.end_date.isoformat() if period.end_date else "indefinite",
|
||||
period.get_availability_display(),
|
||||
period.reason,
|
||||
)
|
||||
|
||||
if period.availability == "unavailable":
|
||||
|
|
|
@ -20,7 +20,7 @@ class ReviewSecretarySettingsAdmin(admin.ModelAdmin):
|
|||
admin.site.register(ReviewSecretarySettings, ReviewSecretarySettingsAdmin)
|
||||
|
||||
class UnavailablePeriodAdmin(admin.ModelAdmin):
|
||||
list_display = ["person", "team", "start_date", "end_date", "availability"]
|
||||
list_display = ["person", "team", "start_date", "end_date", "availability", "reason"]
|
||||
list_display_links = ["person"]
|
||||
list_filter = ["team"]
|
||||
date_hierarchy = "start_date"
|
||||
|
|
|
@ -164,6 +164,7 @@ with db_con.cursor() as c:
|
|||
start_date=None,
|
||||
end_date=end_date,
|
||||
availability="unavailable",
|
||||
reason="reason",
|
||||
)
|
||||
|
||||
# check that we got the needed names
|
||||
|
|
|
@ -60,6 +60,7 @@ class UnavailablePeriod(models.Model):
|
|||
("unavailable", "Completely unavailable - reassign any outstanding reviews"),
|
||||
]
|
||||
availability = models.CharField(max_length=30, choices=AVAILABILITY_CHOICES)
|
||||
reason = models.TextField(verbose_name="Reason why reviewer is unavailable (Optional)", max_length=2048, blank=True, help_text="Provide (for the secretary's benefit) the reason why the review is unavailable", default='')
|
||||
|
||||
def state(self):
|
||||
import datetime
|
||||
|
|
|
@ -86,6 +86,7 @@ class UnavailablePeriodResource(ModelResource):
|
|||
"start_date": ALL,
|
||||
"end_date": ALL,
|
||||
"availability": ALL,
|
||||
"reason": ALL,
|
||||
"team": ALL_WITH_RELATIONS,
|
||||
"person": ALL_WITH_RELATIONS,
|
||||
}
|
||||
|
|
|
@ -32,12 +32,18 @@
|
|||
|
||||
{% if unavailable_periods %}
|
||||
<table class="table">
|
||||
<th>Period</th>
|
||||
<th>Availability</th>
|
||||
<th>Reason</th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
{% for o in unavailable_periods %}
|
||||
<tr class="unavailable-period-{{ o.state }}">
|
||||
<td>
|
||||
{{ o.start_date|default:"indefinite" }} - {{ o.end_date|default:"indefinite" }}
|
||||
</td>
|
||||
<td>{{ o.get_availability_display }}</td>
|
||||
<td>{{ o.reason }}</td>
|
||||
<td>
|
||||
{% if not o.end_date %}
|
||||
<form method="post" class="form-inline" style="display:inline-block">
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<table class="simple-table">
|
||||
<tr>
|
||||
<th>Dates</th>
|
||||
<th>Availability</th>
|
||||
<th>Reason</th>
|
||||
</tr>
|
||||
{% for p in unavailable_periods %}
|
||||
<tr class="unavailable-period-{{ p.state }}">
|
||||
<td> {% if p.start_date or p.end_date %}{{ p.start_date|default:"∞" }} -{% endif %} {{ p.end_date|default:"∞" }}</td>
|
||||
<td>{{ p.get_availability_display }}</td>
|
||||
<td>{{ p.reason }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue