|
|
|
|
@ -58,6 +58,7 @@ class BannerGroupList(AbstractList): |
|
|
|
|
model = BannerGroup |
|
|
|
|
verbose = u'Список груп' |
|
|
|
|
|
|
|
|
|
from django.db.models import Q |
|
|
|
|
|
|
|
|
|
class BannerList(AbstractList): |
|
|
|
|
model = Banner |
|
|
|
|
@ -65,8 +66,11 @@ class BannerList(AbstractList): |
|
|
|
|
template_name = 'admin/expobanner/banner_list.html' |
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
qs = super(BannerList, self).get_queryset() |
|
|
|
|
qs = qs.filter(group__isnull=False) |
|
|
|
|
qs = self.model.objects.filter(group__isnull=False).order_by('-fr') |
|
|
|
|
if not self.request.GET.get('show_inactive'): |
|
|
|
|
qs = qs.filter(Q(fr__lte=date.today()) & (Q(to__isnull=True) | Q( to__gte=date.today()))) |
|
|
|
|
if self.request.GET.get('q'): |
|
|
|
|
qs = qs.filter(title__icontains=self.request.GET['q']) |
|
|
|
|
return qs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -121,6 +125,12 @@ class BannerStat(DetailView): |
|
|
|
|
if date_to: |
|
|
|
|
date_to = datetime.strptime(date_to, "%d.%m.%Y") |
|
|
|
|
qs = qs.filter(date__lte=date_to) |
|
|
|
|
context['all'] = qs.aggregate( |
|
|
|
|
view=Sum('view'), |
|
|
|
|
click=Sum('click'), |
|
|
|
|
unique_view=Sum('unique_view'), |
|
|
|
|
unique_click=Sum('unique_click') |
|
|
|
|
) |
|
|
|
|
context['stats'] = qs |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
@ -132,8 +142,10 @@ class PaidList(ListView): |
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
qs = self.model.objects.language().filter(paid_new__isnull=False).order_by('-paid_new__public') |
|
|
|
|
if self.request.GET.get('onlypublic'): |
|
|
|
|
if not self.request.GET.get('show_inactive'): |
|
|
|
|
qs = qs.filter(paid_new__public=True) |
|
|
|
|
if self.request.GET.get('q'): |
|
|
|
|
qs = qs.filter(name__icontains=self.request.GET['q']) |
|
|
|
|
return qs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -212,7 +224,7 @@ class MainList(ListView): |
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
qs = self.model.objects.language().filter(main__isnull=False).order_by('-main__public') |
|
|
|
|
if self.request.GET.get('onlypublic'): |
|
|
|
|
if not self.request.GET.get('show_inactive'): |
|
|
|
|
qs = qs.filter(main__public=True) |
|
|
|
|
return qs |
|
|
|
|
|
|
|
|
|
@ -243,7 +255,7 @@ class MainConfList(ListView): |
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
qs = self.model.objects.language().filter(main__isnull=False).order_by('-main__public') |
|
|
|
|
if self.request.GET.get('onlypublic'): |
|
|
|
|
if not self.request.GET.get('show_inactive'): |
|
|
|
|
qs = qs.filter(main__public=True) |
|
|
|
|
return qs |
|
|
|
|
|
|
|
|
|
@ -327,7 +339,7 @@ class TopList(ListView): |
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
qs = self.model.objects.language().filter(top__isnull=False).order_by('-top__fr') |
|
|
|
|
if self.request.GET.get('onlypublic'): |
|
|
|
|
if not self.request.GET.get('show_inactive'): |
|
|
|
|
qs = qs.filter(top__fr__lte=date.today(), top__to__gte=date.today()) |
|
|
|
|
return qs |
|
|
|
|
|
|
|
|
|
|