from django.views.generic import ListView, TemplateView

from ajax_datatable.views import AjaxDatatableView

from ...models.vessel import Vessel
from ...mixins.auth import SuperuserRequiredMixin


class AdminVesselsListView(SuperuserRequiredMixin, TemplateView):
    template_name = "core/admin/vessels_list.html"


class AdminVesselsListDataTableView(AjaxDatatableView):
    model = Vessel
    title = 'Vessels'
    initial_order = [["name", "asc"], ]
    length_menu = [[10, 20, 50, 100, -1], [10, 20, 50, 100, 'all']]
    search_values_separator = '+'

    column_defs = [
        AjaxDatatableView.render_row_tools_column_def(),
        {'name': 'id', 'visible': False, },
        {'name': 'name', 'visible': True, },
        {'name': 'imo', 'visible': True, },
        {'name': 'mmsi', 'visible': True, },
    ]