<commit_before># coding=utf-8
"""Model Admin Class."""
from django.contrib.admin.sites import AdminSite
from django.contrib.admin import ModelAdmin

from django.contrib import admin
from django.contrib.flatpages.admin import FlatPageAdmin
from django.contrib.flatpages.models import FlatPage

from leaflet.admin import LeafletGeoAdmin

from realtime.forms.coreflatpage import CoreFlatPageForm
from realtime.models.coreflatpage import CoreFlatPage
from realtime.models.earthquake import Earthquake, EarthquakeReport, \
    EarthquakeMMIContour
from realtime.models.flood import Boundary, Flood, FloodEventBoundary, \
    FloodReport
from realtime.models.ash import Ash, AshReport
from realtime.models.volcano import Volcano


# Define a new FlatPageAdmin
class CoreFlatPageAdmin(FlatPageAdmin):
    fieldsets = (
        (None, {
            'fields': (
                'url',
                'language',
                'title',
                'content',
                'group',
                'order',
                'sites'
            )
        }),
    )
    list_display = ('title', 'url', 'language', 'group', 'order')
    form = CoreFlatPageForm


admin.site.unregister(FlatPage)
admin.site.register(CoreFlatPage, CoreFlatPageAdmin)


class RealtimeAdminSite(AdminSite):
    site_header = 'Realtime Model Administration'
    site_title = 'Realtime Admin'


realtime_admin_site = RealtimeAdminSite(name='realtime_admin')


class EarthquakeAdmin(LeafletGeoAdmin):
    """Admin Class for Earthquake Model."""
    list_display = ('shake_id', 'source_type', 'time', 'location_description',
                    'magnitude', 'depth')
    list_filter = ('location_description', )
    search_fields = ['shake_id', 'location_description']


class EarthquakeReportAdmin(ModelAdmin):
    """Admin Class for Earthquake Report Model."""
    list_display = ('earthquake', 'language', 'report_pdf',
                    'report_thumbnail')
    list_filter = ('earthquake__location_description', 'language')
    search_fields = ['earthquake__shake_id',
                     'earthquake__location_description']


class EarthquakeMMIContourAdmin(LeafletGeoAdmin):
    """Admin Class for Earthquake MMI Contour."""
    list_display = ('earthquake', 'mmi', 'properties')


class BoundaryAdmin(LeafletGeoAdmin):
    """Admin Class for Flood Boundary."""

    list_display = ('name', 'parent', 'boundary_alias')
    list_filter = ('name', 'parent', 'boundary_alias')
    search_fields = ['name', 'parent__name']


class FloodAdmin(ModelAdmin):
    """Admin Class for Flood Event."""
    list_display = ('event_id', 'data_source', 'time',
                    'total_affected', 'boundary_flooded')


class FloodEventBoundaryAdmin(ModelAdmin):
    list_display = ('flood', 'hazard_data')
    list_filter = ('flood', 'hazard_data')


class FloodReportAdmin(ModelAdmin):
    list_display = ('flood', 'language', 'impact_map')


class AshAdmin(ModelAdmin):
    """Admin class for Ash model"""
    list_display = ('volcano', 'alert_level', 'event_time',
                    'event_time_zone_string', 'eruption_height',
                    'forecast_duration')


class AshReportAdmin(ModelAdmin):
    """Admin class for Ash Report"""
    list_display = ('ash', 'language', 'report_map')


class VolcanoAdmin(LeafletGeoAdmin):
    """Admin class for volcano model"""
    list_display = (
        'volcano_name', 'location', 'elevation', 'province', 'district',
        'morphology')
    list_filter = ('province', 'district', 'morphology')
    search_fields = ['volcano_name', 'province', 'district', 'morphology']


realtime_admin_site.register(Earthquake, EarthquakeAdmin)
realtime_admin_site.register(EarthquakeReport, EarthquakeReportAdmin)
realtime_admin_site.register(EarthquakeMMIContour, EarthquakeMMIContourAdmin)
realtime_admin_site.register(Boundary, BoundaryAdmin)
realtime_admin_site.register(Flood, FloodAdmin)
realtime_admin_site.register(FloodEventBoundary, FloodEventBoundaryAdmin)
realtime_admin_site.register(FloodReport, FloodReportAdmin)
realtime_admin_site.register(Ash, AshAdmin)
realtime_admin_site.register(AshReport, AshReportAdmin)
realtime_admin_site.register(Volcano, VolcanoAdmin)<commit_msg>register report template to admin page<commit_after># coding=utf-8
"""Model Admin Class."""
from django.contrib.admin.sites import AdminSite
from django.contrib.admin import ModelAdmin

from django.contrib import admin
from django.contrib.flatpages.admin import FlatPageAdmin
from django.contrib.flatpages.models import FlatPage

from leaflet.admin import LeafletGeoAdmin
from realtime.forms.report_template import ReportTemplate

from realtime.forms.coreflatpage import CoreFlatPageForm
from realtime.models.coreflatpage import CoreFlatPage
from realtime.models.earthquake import Earthquake, EarthquakeReport, \
    EarthquakeMMIContour
from realtime.models.flood import Boundary, Flood, FloodEventBoundary, \
    FloodReport
from realtime.models.ash import Ash, AshReport
from realtime.models.volcano import Volcano


# Define a new FlatPageAdmin
class CoreFlatPageAdmin(FlatPageAdmin):
    fieldsets = (
        (None, {
            'fields': (
                'url',
                'language',
                'title',
                'content',
                'group',
                'order',
                'sites'
            )
        }),
    )
    list_display = ('title', 'url', 'language', 'group', 'order')
    form = CoreFlatPageForm


admin.site.unregister(FlatPage)
admin.site.register(CoreFlatPage, CoreFlatPageAdmin)


class RealtimeAdminSite(AdminSite):
    site_header = 'Realtime Model Administration'
    site_title = 'Realtime Admin'


realtime_admin_site = RealtimeAdminSite(name='realtime_admin')


class EarthquakeAdmin(LeafletGeoAdmin):
    """Admin Class for Earthquake Model."""
    list_display = ('shake_id', 'source_type', 'time', 'location_description',
                    'magnitude', 'depth')
    list_filter = ('location_description', )
    search_fields = ['shake_id', 'location_description']


class EarthquakeReportAdmin(ModelAdmin):
    """Admin Class for Earthquake Report Model."""
    list_display = ('earthquake', 'language', 'report_pdf',
                    'report_thumbnail')
    list_filter = ('earthquake__location_description', 'language')
    search_fields = ['earthquake__shake_id',
                     'earthquake__location_description']


class EarthquakeMMIContourAdmin(LeafletGeoAdmin):
    """Admin Class for Earthquake MMI Contour."""
    list_display = ('earthquake', 'mmi', 'properties')


class BoundaryAdmin(LeafletGeoAdmin):
    """Admin Class for Flood Boundary."""

    list_display = ('name', 'parent', 'boundary_alias')
    list_filter = ('name', 'parent', 'boundary_alias')
    search_fields = ['name', 'parent__name']


class FloodAdmin(ModelAdmin):
    """Admin Class for Flood Event."""
    list_display = ('event_id', 'data_source', 'time',
                    'total_affected', 'boundary_flooded')


class FloodEventBoundaryAdmin(ModelAdmin):
    list_display = ('flood', 'hazard_data')
    list_filter = ('flood', 'hazard_data')


class FloodReportAdmin(ModelAdmin):
    list_display = ('flood', 'language', 'impact_map')


class AshAdmin(ModelAdmin):
    """Admin class for Ash model"""
    list_display = ('volcano', 'alert_level', 'event_time',
                    'event_time_zone_string', 'eruption_height',
                    'forecast_duration')


class AshReportAdmin(ModelAdmin):
    """Admin class for Ash Report"""
    list_display = ('ash', 'language', 'report_map')


class VolcanoAdmin(LeafletGeoAdmin):
    """Admin class for volcano model"""
    list_display = (
        'volcano_name', 'location', 'elevation', 'province', 'district',
        'morphology')
    list_filter = ('province', 'district', 'morphology')
    search_fields = ['volcano_name', 'province', 'district', 'morphology']


class ReportTemplateAdmin(ModelAdmin):
    """Admin class for report template model"""


realtime_admin_site.register(Earthquake, EarthquakeAdmin)
realtime_admin_site.register(EarthquakeReport, EarthquakeReportAdmin)
realtime_admin_site.register(EarthquakeMMIContour, EarthquakeMMIContourAdmin)
realtime_admin_site.register(Boundary, BoundaryAdmin)
realtime_admin_site.register(Flood, FloodAdmin)
realtime_admin_site.register(FloodEventBoundary, FloodEventBoundaryAdmin)
realtime_admin_site.register(FloodReport, FloodReportAdmin)
realtime_admin_site.register(Ash, AshAdmin)
realtime_admin_site.register(AshReport, AshReportAdmin)
realtime_admin_site.register(Volcano, VolcanoAdmin)
realtime_admin_site.register(ReportTemplate, ReportTemplateAdmin)
{'fraction_non_alphanumeric': 0.11150995831403428, 'fraction_numerical': 0.0002315886984715146, 'mean_word_length': 4.263254113345521, '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': '2114132', 'n_tokens_mistral': 2679, 'n_tokens_neox': 2496, 'n_words': 538}