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