Refactor approval queue to display last meaningful status #94
@ -19,10 +19,12 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ extension.get_review_url }}" class="text-decoration-none">
|
<a href="{{ extension.get_review_url }}" class="text-decoration-none">
|
||||||
<div class="d-block badge badge-status-{{ stats.last_type_display|slugify }}">
|
{% with last_type=stats.last_type_display|default:"Awaiting Review" %}
|
||||||
|
<div class="d-block badge badge-status-{{ last_type|slugify }}">
|
||||||
<i class="i-eye"></i>
|
<i class="i-eye"></i>
|
||||||
<span>{{ stats.last_type_display }}</span>
|
<span>{{ last_type }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{% endwith %}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -101,8 +101,7 @@
|
|||||||
{% for activity in extension.review_activity.all %}
|
{% for activity in extension.review_activity.all %}
|
||||||
<li id="activity-{{ activity.id }}">
|
<li id="activity-{{ activity.id }}">
|
||||||
|
|
||||||
{# All activities except comments. #}
|
{% if activity.type in status_change_types %}
|
||||||
{% if activity.type != 'COM' %}
|
|
||||||
<div class="activity-item activity-status-change activity-status-{{ activity.get_type_display|slugify }}">
|
<div class="activity-item activity-status-change activity-status-{{ activity.get_type_display|slugify }}">
|
||||||
<i class="activity-icon i-activity-{{ activity.get_type_display|slugify }}"></i>
|
<i class="activity-icon i-activity-{{ activity.get_type_display|slugify }}"></i>
|
||||||
|
|
||||||
|
@ -13,6 +13,12 @@ from reviewers.models import ApprovalActivity
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
STATUS_CHANGE_TYPES = [
|
||||||
|
ApprovalActivity.ActivityType.APPROVED,
|
||||||
|
ApprovalActivity.ActivityType.AWAITING_CHANGES,
|
||||||
|
ApprovalActivity.ActivityType.AWAITING_REVIEW,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class ApprovalQueueView(ListView):
|
class ApprovalQueueView(ListView):
|
||||||
model = Extension
|
model = Extension
|
||||||
@ -49,7 +55,7 @@ class ApprovalQueueView(ListView):
|
|||||||
stats['count'] += 1
|
stats['count'] += 1
|
||||||
if not stats.get('last_activity', None):
|
if not stats.get('last_activity', None):
|
||||||
stats['last_activity'] = item
|
stats['last_activity'] = item
|
||||||
if not stats.get('last_type_display', None):
|
if not stats.get('last_type_display', None) and item.type in STATUS_CHANGE_TYPES:
|
||||||
stats['last_type_display'] = item.get_type_display
|
stats['last_type_display'] = item.get_type_display
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -66,32 +72,30 @@ class ExtensionsApprovalDetailView(DetailView):
|
|||||||
ctx['pending_previews'] = self.object.preview_set.exclude(
|
ctx['pending_previews'] = self.object.preview_set.exclude(
|
||||||
file__status=File.STATUSES.APPROVED
|
file__status=File.STATUSES.APPROVED
|
||||||
)
|
)
|
||||||
|
ctx['status_change_types'] = STATUS_CHANGE_TYPES
|
||||||
|
|
||||||
if self.request.user.is_authenticated:
|
if self.request.user.is_authenticated:
|
||||||
form = ctx['comment_form'] = CommentForm()
|
form = ctx['comment_form'] = CommentForm()
|
||||||
# Remove 'Approved' status from dropdown it not moderator
|
# anyone can comment
|
||||||
filtered_activity_types = ApprovalActivity.ActivityType.choices
|
filtered_activity_types = {ApprovalActivity.ActivityType.COMMENT}
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
if not (user.is_moderator or user.is_superuser):
|
if self.object.has_maintainer(user):
|
||||||
filtered_activity_types = [
|
filtered_activity_types.add(ApprovalActivity.ActivityType.AWAITING_REVIEW)
|
||||||
t
|
if user.is_moderator or user.is_superuser:
|
||||||
for t in ApprovalActivity.ActivityType.choices
|
filtered_activity_types.update(
|
||||||
if t[0]
|
[
|
||||||
not in [
|
|
||||||
ApprovalActivity.ActivityType.APPROVED,
|
ApprovalActivity.ActivityType.APPROVED,
|
||||||
ApprovalActivity.ActivityType.AWAITING_CHANGES,
|
ApprovalActivity.ActivityType.AWAITING_CHANGES,
|
||||||
]
|
]
|
||||||
]
|
)
|
||||||
if not self.object.has_maintainer(user):
|
choices = list(
|
||||||
# Other accounts can only comment
|
filter(
|
||||||
filtered_activity_types = [
|
lambda c: c[0] in filtered_activity_types, ApprovalActivity.ActivityType.choices
|
||||||
t
|
)
|
||||||
for t in ApprovalActivity.ActivityType.choices
|
)
|
||||||
if t[0] == ApprovalActivity.ActivityType.COMMENT
|
form.fields['type'].choices = choices
|
||||||
]
|
form.fields['type'].widget.choices = choices
|
||||||
form.fields['type'].choices = filtered_activity_types
|
if len(choices) == 1:
|
||||||
form.fields['type'].widget.choices = filtered_activity_types
|
|
||||||
if len(filtered_activity_types) == 1:
|
|
||||||
form.fields['type'].widget = django.forms.HiddenInput()
|
form.fields['type'].widget = django.forms.HiddenInput()
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user