<commit_before>from django.contrib import admin

from django_celery_results.models import TaskResult

from models import (Service, Layer, Check, SpatialReferenceSystem, EndpointList,
                    Endpoint, LayerDate, LayerWM, Catalog, IssueType, Issue)


class ServiceAdmin(admin.ModelAdmin):
    model = Service
    list_display = ('id', 'type', 'is_valid', 'title', 'active', 'url', )
    list_display_links = ('id', )
    search_fields = ['title', 'url', ]
    list_filter = ('type', )


class SpatialReferenceSystemAdmin(admin.ModelAdmin):
    model = SpatialReferenceSystem
    list_display = ('code', )


class LayerDateAdmin(admin.ModelAdmin):
    model = LayerDate
    list_display = ('date', 'type', 'layer', 'layer_abstract')
    list_filter = ('type', )

    def layer_abstract(self, instance):
        return instance.layer.abstract


class LayerAdmin(admin.ModelAdmin):
    model = Layer
    list_display = ('name', 'is_valid',  'title', 'service', )
    search_fields = ['name', 'title', ]
    list_filter = ('is_public', )


class LayerWMAdmin(admin.ModelAdmin):
    model = LayerWM
    list_display = ('layer', 'username', 'category', 'temporal_extent_start', 'temporal_extent_end')


class CheckAdmin(admin.ModelAdmin):
    model = Check
    list_display = ('id', 'content_type', 'content_object', 'checked_datetime', 'success', 'response_time', )
    search_fields = ['=object_id']
    list_filter = ('success', 'content_type')
    date_hierarchy = 'checked_datetime'


class EndpointListAdmin(admin.ModelAdmin):
    model = EndpointList
    list_display = ('id', 'upload', 'endpoints_admin_url', 'catalog', 'greedy')<commit_msg>make 'view on site' link in layer and service admin page work (#277)<commit_after>from django.contrib import admin

from django_celery_results.models import TaskResult

from django.core.urlresolvers import reverse

from models import (Service, Layer, Check, SpatialReferenceSystem, EndpointList,
                    Endpoint, LayerDate, LayerWM, Catalog, IssueType, Issue)


class ServiceAdmin(admin.ModelAdmin):
    model = Service
    list_display = ('id', 'type', 'is_valid', 'title', 'active', 'url', )
    list_display_links = ('id', )
    search_fields = ['title', 'url', ]
    list_filter = ('type', )

    def view_on_site(self, obj):
        return reverse("service_detail", args=[obj.catalog.slug, obj.uuid])


class SpatialReferenceSystemAdmin(admin.ModelAdmin):
    model = SpatialReferenceSystem
    list_display = ('code', )


class LayerDateAdmin(admin.ModelAdmin):
    model = LayerDate
    list_display = ('date', 'type', 'layer', 'layer_abstract')
    list_filter = ('type', )

    def layer_abstract(self, instance):
        return instance.layer.abstract


class LayerAdmin(admin.ModelAdmin):
    model = Layer
    list_display = ('name', 'is_valid',  'title', 'service', )
    search_fields = ['name', 'title', ]
    list_filter = ('is_public', )

    def view_on_site(self, obj):
        return reverse("layer_detail", args=[obj.catalog.slug, obj.uuid])


class LayerWMAdmin(admin.ModelAdmin):
    model = LayerWM
    list_display = ('layer', 'username', 'category', 'temporal_extent_start', 'temporal_extent_end')


class CheckAdmin(admin.ModelAdmin):
    model = Check
    list_display = ('id', 'content_type', 'content_object', 'checked_datetime', 'success', 'response_time', )
    search_fields = ['=object_id']
    list_filter = ('success', 'content_type')
    date_hierarchy = 'checked_datetime'


class EndpointListAdmin(admin.ModelAdmin):
    model = EndpointList
    list_display = ('id', 'upload', 'endpoints_admin_url', 'catalog', 'greedy')
{'fraction_non_alphanumeric': 0.13647642679900746, 'fraction_numerical': 0.0008271298593879239, 'mean_word_length': 4.463855421686747, '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': '5296922', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1082, 'n_words': 257}