Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] usable waffle admin #10679

Open
wants to merge 1 commit into
base: feature/gravy_valet_integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading