# Path: looksee/queues.py
# class MasscanQueue(LookseeQueue):
#     """ Masscan parameter queue """
#     name = 'masscan'
# 
#     def serialize(self, value):
#         return json.dumps(map(str, value))
# 
#     def deserialize(self, value):
#         if value:
#             return MasscanJob(*json.loads(value))


from django.core.urlresolvers import reverse_lazy
from horizon import tables
from horizon import forms
from looksee.queues import MasscanQueue
import tables as scan_tables
import forms as scan_forms
import tasa.store





class CreateView(forms.ModalFormView):
    form_class = scan_forms.CreateScan
    template_name = 'tasks/portscan/create.html'
    success_url = reverse_lazy('horizon:tasks:portscan:index')


class IndexView(tables.DataTableView):
    table_class = scan_tables.TCPScanTable
    template_name = 'tasks/portscan/index.html'

    def get_data(self):
        result = []
        marker = int(self.request.GET.get(
                self.table_class._meta.pagination_param, 0))

# Path: looksee/queues.py
# class MasscanQueue(LookseeQueue):
#     """ Masscan parameter queue """
#     name = 'masscan'
# 
#     def serialize(self, value):
#         return json.dumps(map(str, value))
# 
#     def deserialize(self, value):
#         if value:
#             return MasscanJob(*json.loads(value))


# Path: caravan/caravan/dashboards/tasks/portscan/views.py
from django.core.urlresolvers import reverse_lazy
from horizon import tables
from horizon import forms
from looksee.queues import MasscanQueue
import tables as scan_tables
import forms as scan_forms
import tasa.store






class CreateView(forms.ModalFormView):
    form_class = scan_forms.CreateScan
    template_name = 'tasks/portscan/create.html'
    success_url = reverse_lazy('horizon:tasks:portscan:index')


class IndexView(tables.DataTableView):
    table_class = scan_tables.TCPScanTable
    template_name = 'tasks/portscan/index.html'

    def get_data(self):
        result = []
        marker = int(self.request.GET.get(
                self.table_class._meta.pagination_param, 0))

        return MasscanQueue().id_and_chunk(marker)