Skip to content

Commit

Permalink
usable waffle admin
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Jul 18, 2024
1 parent 106994b commit 6df28cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/base/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,5 @@

CITATION_STYLES_REPO_URL = 'https://github.com/CenterForOpenScience/styles/archive/88e6ed31a91e9f5a480b486029cda97b535935d4.zip'
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

WAFFLE_ENABLE_ADMIN_PAGES = False # instead, customized waffle admins in osf/admin.py
14 changes: 14 additions & 0 deletions osf/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.db.models import Q, Count
from django.http import HttpResponseRedirect
from django.urls import reverse
import waffle

from osf.external.spam.tasks import reclassify_domain_references
from osf.models import OSFUser, Node, NotableDomain, NodeLicense
Expand Down Expand Up @@ -140,7 +141,20 @@ def get_queryset(self, request):
qs = super().get_queryset(request).annotate(number_of_references=Count('domainreference'))
return qs


class _ManygroupWaffleFlagAdmin(waffle.admin.FlagAdmin):
'''customized `waffle.admin.FlagAdmin` to support many groups
(reverse incorrect assumption in https://github.com/jazzband/django-waffle/commit/bf36c19ee03baf1c5850ffe0b284900a5c416f53 )
'''
raw_id_fields = (*waffle.admin.FlagAdmin.raw_id_fields, 'groups')


admin.site.register(OSFUser, OSFUserAdmin)
admin.site.register(Node, NodeAdmin)
admin.site.register(NotableDomain, NotableDomainAdmin)
admin.site.register(NodeLicense, LicenseAdmin)

admin.site.register(waffle.models.Flag, _ManygroupWaffleFlagAdmin)
admin.site.register(waffle.models.Sample, waffle.admin.SampleAdmin)
admin.site.register(waffle.models.Switch, waffle.admin.SwitchAdmin)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ google-api-python-client==1.6.4
Babel==2.9.1
citeproc-py==0.4.0
boto3==1.4.7
django-waffle==2.4.1
django-waffle==2.5.0 # TODO: 4.1.0 when python 3.8+
pymongo==3.7.1
PyYAML==6.0.1
tqdm==4.28.1
Expand Down

0 comments on commit 6df28cd

Please sign in to comment.