from django.views.generic import ListView, TemplateView
from django.views.generic.edit import FormView

from .models import Alphaname


class IndexView(TemplateView):
    """Shows all menu entries of an app"""
    template_name = 'main.html'


class AlphanameIndexView(ListView):
    """Shows all alphaname list available along with registrar and registration date"""
    template_name = 'alphanames-list.html'
    model = Alphaname

    def get_queryset(self):
        return self.model.objects.for_user(crm_user_id=self.request.session['crm_user_id']).all()


class AlphanameRegisterView(FormView):
    """Sends new alphaname register request"""
    template_name = 'alphaname-new.html'
    form_class = dict  # TODO: replace fake form with an existing one
    success_url = ''

    def form_valid(self, form):
        # Add job for sending request to register a new alphanumeric name
        return super().form_valid(form)


class CampaignIndexView(ListView):
    """Lists all active campaigns currently in progress (scheduled)"""
    template_name = 'campaigns-list.html'
    queryset = []  # TODO: replace fake queryset with an existing model


class CampaignNewView(FormView):
    """Helps schedule a new campaign or send new one instantly"""
    template_name = 'campaign-edit.html'
    form_class = dict  # TODO: replace fake form with an existing one
    success_url = ''

    def form_valid(self, form):
        # Save new campaign and notify everyone about it, add job into queue if needed
        return super().form_valid(form)


class CampaignEditView(FormView):
    """Makes modifications on an active campaign"""
    template_name = 'campaign-edit.html'
    form_class = dict  # TODO: replace fake form with an existing one
    success_url = ''

    def form_valid(self, form):
        # Change campaign settings and notify everyone about its change, which involves changing DB and rescheduling job
        return super().form_valid(form)


class CampaignArchiveView(ListView):
    """Keeps a history of campaigns, which are inactive"""
    template_name = 'campaigns-list.html'
    queryset = []  # TODO: replace fake queryset with an existing model


class CampaignMessagesView(ListView):
    """Keeps a history of messages"""
    template_name = 'sent-messages.html'
    queryset = []  # TODO: replace fake queryset with an existing model


class CampaignStatsView(ListView):
    """Shows stats on campaigns"""
    template_name = 'campaigns-stats.html'
    queryset = []  # TODO: replace fake queryset with an existing model

@@ -127,16 +127,59 @@
 phaname%0A
+from .forms import AlphanameForm, TaskForm%0A
 %0A%0Aclass 
@@ -746,60 +746,21 @@
 s = 
-dict  # TODO: replace fake form with an existing one
+AlphanameForm
 %0A   
@@ -767,32 +767,33 @@
  success_url = '
+/
 '%0A%0A    def form_
@@ -1690,60 +1690,16 @@
 s = 
-dict  # TODO: replace fake form with an existing one
+TaskForm
 %0A   

Add forms to formviews