Basic styling, lots of feature work

This commit is contained in:
2013-05-12 17:12:48 +01:00
parent 33cf34ba92
commit a644b280eb
24 changed files with 10681 additions and 24 deletions

View File

@@ -1,14 +1,38 @@
from django.views.generic import ListView
from django.views.generic import ListView, CreateView
from django.utils.timezone import now
from timer.models import Timer
from timer.models import Timer, Location, Station, Moon, System
from timer.forms import TimerForm
class TimerCreateView(CreateView):
model = Timer
form_class = TimerForm
class TimerListView(ListView):
model = Timer
template_name = 'timer/timer_list.html'
def get_queryset(self):
qs = super(TimerListView, self).get_queryset()
if 'active' in self.kwargs:
qs = qs.filter(expiry_datetime__gt=now())
qs = super(TimerListView, self).get_queryset().select_related('location', 'station', 'moon', 'system')
if int(self.request.GET.get('all', 0)) == 0:
qs = qs.filter(expiration__gt=now())
type = int(self.request.GET.get('type', 0))
if type == 1:
qs = [m for m in qs if m.location.get_type == 'Station']
if type == 2:
qs = [m for m in qs if m.location.get_type == 'System']
if type == 3:
qs = [m for m in qs if m.location.get_type == 'Moon']
return qs
def get_context_data(self, **kwargs):
ctx = super(TimerListView, self).get_context_data(**kwargs)
ctx.update({
'list_all': int(self.request.GET.get('all', 0)),
'list_type': int(self.request.GET.get('type', 0)),
})
return ctx