<commit_before>from django.contrib import admin

from ..models.agreements import Agreement, AgreementOption
from .filters import ActiveListFilter


class AgreementOptionInlineAdmin(admin.TabularInline):
    model = AgreementOption
    extra = 0
    min_num = 1


@admin.register(Agreement)
class AgreementAdmin(admin.ModelAdmin):
    inlines = (AgreementOptionInlineAdmin,)
    list_display = ('name', 'order')
    list_editable = ('order',)
    list_filter = (ActiveListFilter,)<commit_msg>prevent legal agreement from being deleted<commit_after>from django.contrib import admin

from ..models.agreements import Agreement, AgreementOption
from .filters import ActiveListFilter


class AgreementOptionInlineAdmin(admin.TabularInline):
    model = AgreementOption
    extra = 0
    min_num = 1


@admin.register(Agreement)
class AgreementAdmin(admin.ModelAdmin):
    inlines = (AgreementOptionInlineAdmin,)
    list_display = ('name', 'order')
    list_editable = ('order',)
    list_filter = (ActiveListFilter,)

    def has_delete_permission(self, request, obj=None):
        if obj and obj.registrations.exists():
            return False
        else:
            return super().has_delete_permission(request, obj)

    def get_actions(self, request):
        actions = super().get_actions(request)
        if 'delete_selected' in actions:
            del(actions['delete_selected'])
        return actions
{'fraction_non_alphanumeric': 0.09155429382540808, 'fraction_numerical': 0.0028388928317956, 'mean_word_length': 3.9823321554770317, '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': '4011826', 'n_tokens_mistral': 393, 'n_tokens_neox': 378, 'n_words': 96}