<commit_before>from django.contrib import admin
from django_extensions.admin import ForeignKeyAutocompleteAdmin

from osf.models import *  # noqa


class NodeAdmin(ForeignKeyAutocompleteAdmin):
    fields = (
        'affiliated_institutions',
        'alternative_citations',
        'category',
        'creator',
        'deleted_date',
        'description',
        'forked_from',
        'is_deleted',
        'is_fork',
        'is_public',
        'keenio_read_key',
        'node_license',
        'piwik_site_id',
        'preprint_article_doi',
        'preprint_file',
        'public_comments',
        'suspended',
        'tags',
        'template_node',
        'title',
        'type',
        'wiki_pages_current',
        'wiki_pages_versions',
        'wiki_private_uuids',
        '_has_abandoned_preprint',
        '_is_preprint_orphan',
    )

admin.site.register(Node, NodeAdmin)  # noqa
admin.site.register(OSFUser)<commit_msg>Make fields for admin models "migration-proof" by including all editable fields in the current model, instead of hard-coding fields.<commit_after>from django.contrib import admin
from django_extensions.admin import ForeignKeyAutocompleteAdmin

from osf.models import *  # noqa


def list_displayable_fields(cls):
    return [x.name for x in cls._meta.fields if x.editable and not x.is_relation and not x.primary_key]

class NodeAdmin(ForeignKeyAutocompleteAdmin):
    fields = list_displayable_fields(Node)

class OSFUserAdmin(admin.ModelAdmin):
    fields = list_displayable_fields(OSFUser)

admin.site.register(OSFUser, OSFUserAdmin)
admin.site.register(Node, NodeAdmin)
{'fraction_non_alphanumeric': 0.09236453201970443, 'fraction_numerical': 0.0, 'mean_word_length': 3.310344827586207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4756386', 'n_tokens_mistral': 499, 'n_tokens_neox': 489, 'n_words': 102}