forked from pycontw/pycon.tw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add registry package and adjust admin for PyCon TW
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django.contrib import admin | ||
from django.conf import settings | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from registry.models import Entry | ||
from registry.admin import EntryAdmin | ||
|
||
|
||
class CurrentConferenceFilter(admin.filters.SimpleListFilter): | ||
title = 'Current Conference' | ||
parameter_name = 'current' | ||
|
||
def lookups(self, request, model_admin): | ||
return [ | ||
(None, _('Current')), | ||
('other', _('Other')), | ||
('all', _('All')), | ||
] | ||
|
||
def queryset(self, request, queryset): | ||
if self.value() == 'all': | ||
return queryset | ||
elif self.value() == 'other': | ||
return queryset.exclude(key__startswith=f'{settings.CONFERENCE_DEFAULT_SLUG}') | ||
|
||
return queryset.filter(key__startswith=f'{settings.CONFERENCE_DEFAULT_SLUG}') | ||
|
||
def choices(self, changelist): | ||
for lookup, title in self.lookup_choices: | ||
yield { | ||
'selected': self.value() == lookup, | ||
'query_string': changelist.get_query_string({self.parameter_name: lookup}), | ||
'display': title, | ||
} | ||
|
||
|
||
class PyConEntryAdmin(EntryAdmin): | ||
list_filter = (CurrentConferenceFilter, ) + EntryAdmin.list_filter | ||
|
||
|
||
admin.site.unregister(Entry) | ||
admin.site.register(Entry, PyConEntryAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,7 @@ | |
'django_q', | ||
'import_export', | ||
'sorl.thumbnail', | ||
'registry', | ||
) | ||
|
||
LOCAL_APPS = ( | ||
|