def get(self, request, *args, **kwargs): context = {} context["topnav"] = 5 #课程 if 'id' in kwargs and kwargs['id']: courseid = int(kwargs['id']) try: course = CourseInfo.objects.get(id=courseid) except CourseInfo.DoesNotExist: return HttpResponseRedirect(reverse('web-course')) #阅读数+1 course.viewcounts = course.viewcounts + 1 course.save() #图片 if course.imagepath: course.imagepath = Util.getFileUrl(course.imagepath) #视频 if course.video : course.video = Util.getFileUrl(course.video) course.createtime = Util.timeFormat(course.createtime,True) context["course"] = course context["commentObjId"] = course.id #评论数,#1:新闻,2:课程,3:活动 context["commentCounts"] = CommentInfo.objects.filter(mod=2,obj_id=course.id).count() #课程 context["courselist"] = CourseInfo.objects.filter().order_by("-viewcounts")[0:10] return render_to_response("web-course-detail.html", context, context_instance=RequestContext(request))
def get(self, request, *args, **kwargs): context = {} context["topnav"] = 2 #新闻 if 'id' in kwargs and kwargs['id']: newsid = int(kwargs['id']) try: news = NewsInfo.objects.get(id=newsid) except NewsInfo.DoesNotExist: return HttpResponseRedirect(reverse('web-news')) news.createtime = Util.timeFormat(news.createtime,True) context["news"] = news #新闻 context["newslist"] = NewsInfo.objects.filter().order_by("-createtime")[0:10] return render_to_response("web-news-detail.html", context, context_instance=RequestContext(request))
def get(self, request, *args, **kwargs): context = {} context["topnav"] = 2 pageindex,pagesize = Util.InitPagenation(request) #新闻 newslist = NewsInfo.objects.filter().order_by("-createtime")[(pageindex - 1) * pagesize:pagesize * pageindex] if newslist: newslist_new = [] for news in newslist: news.createtime = Util.timeFormat(news.createtime,True) newslist_new.append(news) context["newslist"] = newslist_new counts = NewsInfo.objects.filter().count() context["pagenationHtml"] = Util.GetPagenation(request,counts,pagesize) return render_to_response("web-news.html", context, context_instance=RequestContext(request))
def get(self, request, *args, **kwargs): context = {} context["topnav"] = 6 #育儿宝典id if 'id' in kwargs and kwargs['id']: educationid = int(kwargs['id']) try: education = EducationCare.objects.get(id=educationid) except EducationCare.DoesNotExist: return HttpResponseRedirect(reverse('web-education')) #阅读数+1 education.viewcounts = education.viewcounts + 1 education.save() #视频 if education.video : education.video = Util.getFileUrl( education.video) education.createtime = Util.timeFormat(education.createtime,True) context["education"] = education #育儿宝典 context["educationlist"] = EducationCare.objects.filter().order_by("-viewcounts")[0:10] return render_to_response("web-education-detail.html", context, context_instance=RequestContext(request))