Implement Web Assets' theme system and selection, and add 'light' theme #118
@ -1,3 +1,4 @@
|
||||
from collections import defaultdict
|
||||
import logging
|
||||
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
@ -12,10 +13,11 @@ from reviewers.models import ApprovalActivity
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# the ordering of this list determines the order of rows in approval queue listing
|
||||
STATUS_CHANGE_TYPES = [
|
||||
ApprovalActivity.ActivityType.APPROVED,
|
||||
ApprovalActivity.ActivityType.AWAITING_CHANGES,
|
||||
ApprovalActivity.ActivityType.AWAITING_REVIEW,
|
||||
ApprovalActivity.ActivityType.AWAITING_CHANGES,
|
||||
ApprovalActivity.ActivityType.APPROVED,
|
||||
]
|
||||
|
||||
|
||||
@ -36,13 +38,13 @@ class ApprovalQueueView(ListView):
|
||||
.all()
|
||||
)
|
||||
by_extension = {}
|
||||
result = []
|
||||
by_date_created = []
|
||||
for item in qs:
|
||||
extension = item.extension
|
||||
stats = by_extension.get(extension, None)
|
||||
if not stats:
|
||||
# this check guarantees that we add a record only once per extension,
|
||||
# and iterating over qs we get result also ordered by item.date_created
|
||||
# and iterating over qs we get by_date_created also ordered by item.date_created
|
||||
stats = {
|
||||
'count': 0,
|
||||
'extension': extension,
|
||||
@ -50,12 +52,19 @@ class ApprovalQueueView(ListView):
|
||||
'last_type_display': None,
|
||||
}
|
||||
by_extension[extension] = stats
|
||||
result.append(stats)
|
||||
by_date_created.append(stats)
|
||||
stats['count'] += 1
|
||||
if not stats.get('last_activity', None):
|
||||
stats['last_activity'] = item
|
||||
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()
|
||||
stats['type'] = item.type
|
||||
groupped_by_type = defaultdict(list)
|
||||
for stats in by_date_created:
|
||||
groupped_by_type[stats['type']].append(stats)
|
||||
result = []
|
||||
for type in STATUS_CHANGE_TYPES:
|
||||
result.extend(groupped_by_type[type])
|
||||
return result
|
||||
|
||||
template_name = 'reviewers/extensions_review_list.html'
|
||||
|
Loading…
Reference in New Issue
Block a user