30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
# coding:utf-8
|
|
import types
|
|
|
|
from django.shortcuts import render
|
|
from django.http import HttpResponse
|
|
from news.models import *
|
|
from metadata.models import *
|
|
from results.models import *
|
|
|
|
|
|
# Create your views here.
|
|
def index(request):
|
|
user = None
|
|
if request.user.is_authenticated():
|
|
user = request.user
|
|
news1 = News.objects.filter(category=1).order_by('-created')[:6]
|
|
news2 = News.objects.filter(category=2).order_by('-created')[:6]
|
|
news3 = News.objects.filter(category=3).order_by('-created')[:6]
|
|
metadatas = Metadata.objects.all().order_by('-created')[:4]
|
|
newest_datas = Metadata.objects.all().order_by('-updated')[:4]
|
|
hot_datas = Metadata.objects.all().order_by('-hit_count')[:4]
|
|
papers = Paper.objects.all().order_by('-publication_time')[:3]
|
|
win_results = WinResult.objects.all().order_by('-win_time')[:3]
|
|
c = Cart.objects.filter(user=user).first()
|
|
count = LineItem.objects.filter(cart=c).count()
|
|
request.session['count'] = count
|
|
return render(request, 'index.html',
|
|
{'news1': news1, 'news2': news2, 'news3': news3, 'newest_datas': newest_datas, 'hot_datas': hot_datas, 'metadatas': metadatas,
|
|
'papers': papers, 'win_results': win_results})
|