<commit_before>from django.contrib import admin

from .models import Timetable, Booking, Event, Week, ColourScheme


# Register your models here.

class BookingInline(admin.StackedInline):
    model = Booking
    fields = ['room', 'event']
    extra = 6

class WeekAdmin(admin.ModelAdmin):
    model = Week
    inlines = [BookingInline]

class TimetableAdmin(admin.ModelAdmin):
    model = Timetable

admin.site.register(Event)
admin.site.register(Week, WeekAdmin)
admin.site.register(ColourScheme)
admin.site.register(Timetable)<commit_msg>Fix timetable changes add 6 extra blank events to admin view<commit_after>from django.contrib import admin

from .models import Timetable, Booking, Event, Week, ColourScheme


# Register your models here.

class NewBookingInline(admin.StackedInline):
    model = Booking
    fields = ['room', 'event']
    extra = 6


class ChangeBookingInline(admin.StackedInline):
    model = Booking
    fields = ['room', 'event']
    extra = 0


class WeekAdmin(admin.ModelAdmin):
    model = Week
    inlines = []

    def change_view(self, request, object_id, form_url='', extra_context=None):
        self.inlines = [ChangeBookingInline]
        return super().change_view(request, object_id, form_url, extra_context)

    def add_view(self, request, form_url='', extra_context=None):
        self.inlines = [NewBookingInline]
        return super().add_view(request, form_url, extra_context)


class TimetableAdmin(admin.ModelAdmin):
    model = Timetable


admin.site.register(Event)
admin.site.register(Week, WeekAdmin)
admin.site.register(ColourScheme)
admin.site.register(Timetable)
{'fraction_non_alphanumeric': 0.103831891223733, 'fraction_numerical': 0.002472187886279357, 'mean_word_length': 4.488135593220339, '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': '3993348', 'n_tokens_mistral': 505, 'n_tokens_neox': 491, 'n_words': 121}