Implement Web Assets' theme system and selection, and add 'light' theme #118

Merged
Márton Lente merged 97 commits from martonlente/extensions-website:ui/theme-light into main 2024-05-08 14:20:07 +02:00
Showing only changes of commit 9715c5a8b9 - Show all commits

View File

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