# Path: nasman/snapshots/models.py
# class File(models.Model):
#     """
#     Model representing a file/directory/etc on the filesystem
#     """
#     snapshot_path = models.TextField(
#         'snapshot path',
#         help_text='The path to the file when the relevant snapshot is mounted')
#     original_path = models.TextField(
#         'original path',
#         help_text='The original path on the filesystem when the snapshot was '
#                   'taken'
#     )
#     snapshot_name = models.TextField(
#         'snapshot name',
#         help_text='Name of the snapshot'
#     )
#     path_encoding = models.TextField(
#         'path encoding',
#         help_text='The filesystem encoding for this file',
#         blank=True
#     )
#     search_index = VectorField()
# 
#     objects = SearchManager(
#         fields=('snapshot_path', 'original_path'),
#         config='pg_catalog.english',
#         search_field='search_index',
#         auto_update_search_field=True
#     )
# 
#     class Meta:
#         app_label = 'snapshots'
# 
# class IconMapping(models.Model):
#     """
#     Model to manage icon mapping to mimetypes
#     """
#     icon = IconField(
#         'icon',
#         default='fa-file-o'
#     )
#     mime_type = models.CharField(
#         'mime-type',
#         max_length=255,
#         primary_key=True,
#         db_index=True
#     )
# 
#     class Meta:
#         app_label = 'snapshots'
# 
#     def __str__(self):
#         return self.mime_type
# 
# Path: nasman/snapshots/forms.py
# class FileForm(forms.ModelForm):
#     snapshot_name = forms.ChoiceField(
#         choices=snapshot_choices
#     )
# 
#     class Meta:
#         model = File
#         fields = (
#             'snapshot_path',
#             'original_path',
#             'snapshot_name',
#         )
#         widgets = {
#             'snapshot_path': forms.TextInput(),
#             'original_path': forms.TextInput(),
#             'search_index': forms.Textarea(),
#         }


from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from sitetree.admin import TreeItemAdmin, override_item_admin
from .models import File, IconMapping
from .forms import FileForm


@admin.register(File)
class FileAdmin(admin.ModelAdmin):
    list_display = ('original_path', 'snapshot_name')
    list_display_links = ('original_path',)
    form = FileForm
    readonly_fields = ('path_encoding', 'search_index')

@admin.register(IconMapping)
class IconMappingAdmin(admin.ModelAdmin):
    list_display = ['icon', 'mime_type', ]


class NasmanTreeItemAdmin(TreeItemAdmin):
    fieldsets = (
        (_('Basic settings'), {
            'fields': ('parent', 'title', 'url', 'icon', )
        }),
        (_('Access settings'), {
            'classes': ('collapse',),
            'fields': ('access_loggedin', 'access_guest', 'access_restricted',
                       'access_permissions', 'access_perm_type')
        }),
        (_('Display settings'), {
            'classes': ('collapse',),
            'fields': ('hidden', 'inmenu', 'inbreadcrumbs', 'insitetree')
        }),
        (_('Additional settings'), {
            'classes': ('collapse',),

# Path: nasman/snapshots/models.py
# class File(models.Model):
#     """
#     Model representing a file/directory/etc on the filesystem
#     """
#     snapshot_path = models.TextField(
#         'snapshot path',
#         help_text='The path to the file when the relevant snapshot is mounted')
#     original_path = models.TextField(
#         'original path',
#         help_text='The original path on the filesystem when the snapshot was '
#                   'taken'
#     )
#     snapshot_name = models.TextField(
#         'snapshot name',
#         help_text='Name of the snapshot'
#     )
#     path_encoding = models.TextField(
#         'path encoding',
#         help_text='The filesystem encoding for this file',
#         blank=True
#     )
#     search_index = VectorField()
# 
#     objects = SearchManager(
#         fields=('snapshot_path', 'original_path'),
#         config='pg_catalog.english',
#         search_field='search_index',
#         auto_update_search_field=True
#     )
# 
#     class Meta:
#         app_label = 'snapshots'
# 
# class IconMapping(models.Model):
#     """
#     Model to manage icon mapping to mimetypes
#     """
#     icon = IconField(
#         'icon',
#         default='fa-file-o'
#     )
#     mime_type = models.CharField(
#         'mime-type',
#         max_length=255,
#         primary_key=True,
#         db_index=True
#     )
# 
#     class Meta:
#         app_label = 'snapshots'
# 
#     def __str__(self):
#         return self.mime_type
# 
# Path: nasman/snapshots/forms.py
# class FileForm(forms.ModelForm):
#     snapshot_name = forms.ChoiceField(
#         choices=snapshot_choices
#     )
# 
#     class Meta:
#         model = File
#         fields = (
#             'snapshot_path',
#             'original_path',
#             'snapshot_name',
#         )
#         widgets = {
#             'snapshot_path': forms.TextInput(),
#             'original_path': forms.TextInput(),
#             'search_index': forms.Textarea(),
#         }


# Path: nasman/snapshots/admin.py
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from sitetree.admin import TreeItemAdmin, override_item_admin
from .models import File, IconMapping
from .forms import FileForm



@admin.register(File)
class FileAdmin(admin.ModelAdmin):
    list_display = ('original_path', 'snapshot_name')
    list_display_links = ('original_path',)
    form = FileForm
    readonly_fields = ('path_encoding', 'search_index')

@admin.register(IconMapping)
class IconMappingAdmin(admin.ModelAdmin):
    list_display = ['icon', 'mime_type', ]


class NasmanTreeItemAdmin(TreeItemAdmin):
    fieldsets = (
        (_('Basic settings'), {
            'fields': ('parent', 'title', 'url', 'icon', )
        }),
        (_('Access settings'), {
            'classes': ('collapse',),
            'fields': ('access_loggedin', 'access_guest', 'access_restricted',
                       'access_permissions', 'access_perm_type')
        }),
        (_('Display settings'), {
            'classes': ('collapse',),
            'fields': ('hidden', 'inmenu', 'inbreadcrumbs', 'insitetree')
        }),
        (_('Additional settings'), {
            'classes': ('collapse',),

            'fields': ('hint', 'description', 'alias', 'urlaspattern')