mirror of
https://github.com/nikdoof/limetime.git
synced 2025-12-18 13:19:20 +00:00
Basic styling, lots of feature work
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user