Extensions list: sort_by parameter #159
@ -0,0 +1,29 @@
|
||||
# Generated by Django 4.2.11 on 2024-05-31 09:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extensions', '0031_extension_latest_version'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='extension',
|
||||
options={},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='extension',
|
||||
index=models.Index(fields=['average_score'], name='extensions__average_c33b2b_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='extension',
|
||||
index=models.Index(fields=['date_approved'], name='extensions__date_ap_b18acd_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='extension',
|
||||
index=models.Index(fields=['download_count'], name='extensions__downloa_516939_idx'),
|
||||
),
|
||||
]
|
@ -220,6 +220,11 @@ class Extension(CreatedModifiedMixin, RatingMixin, TrackChangesMixin, models.Mod
|
||||
objects = ExtensionManager()
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(fields=['average_score']),
|
||||
models.Index(fields=['date_approved']),
|
||||
models.Index(fields=['download_count']),
|
||||
]
|
||||
ordering = ['-average_score', '-date_created', 'name']
|
||||
|
||||
def __str__(self):
|
||||
|
@ -46,6 +46,7 @@ class HomeView(ListedExtensionsView):
|
||||
'ratings',
|
||||
'team',
|
||||
)
|
||||
.order_by('-average_score')
|
||||
)
|
||||
context['addons'] = q.filter(type=EXTENSION_TYPE_CHOICES.BPY)[:8]
|
||||
context['themes'] = q.filter(type=EXTENSION_TYPE_CHOICES.THEME)[:8]
|
||||
@ -68,13 +69,13 @@ def extension_version_download(request, type_slug, slug, version, filename):
|
||||
class SearchView(ListedExtensionsView):
|
||||
paginate_by = 16
|
||||
template_name = 'extensions/list.html'
|
||||
default_sort_by = '-date_approved'
|
||||
default_sort_by = '-average_score'
|
||||
sort_by_options = OrderedDict(
|
||||
[
|
||||
('-date_approved', _('Newest First')),
|
||||
('date_approved', _('Oldest First')),
|
||||
('-average_score', _('Rating')),
|
||||
('-download_count', _('Downloads')),
|
||||
('-date_approved', _('Newest First')),
|
||||
('date_approved', _('Oldest First')),
|
||||
('name', _('Title (A-Z)')),
|
||||
('-name', _('Title (Z-A)')),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user