def get(self, request): select = request.GET.get('select') user = request.user if select == '1': genebooks = user.genebook_set.filter( audit_status=1).order_by('-create_time') elif select == '2': genebooks = user.genebook_set.filter( audit_status=2).order_by('-create_time') elif select == '3': genebooks = user.genebook_set.filter( audit_status=3).order_by('-create_time') elif select == '4': genebooks = user.genebook_set.filter( audit_status=4).order_by('-create_time') else: select = '0' genebooks = user.genebook_set.all().order_by('-create_time') page = request.GET.get('page') pageobj = Page(genebooks, 8, page) context = pageobj.paging() context['select'] = int(select) return render(request, 'user_center_gene.html', context)
def get(self, request): category_id = request.GET.get('select') if category_id: try: category = CultureCategory.objects.get(id=category_id) except CultureCategory.DoesNotExist: return render(request, 'culture_center.html') articles = category.culturearticle_set.all().order_by( '-create_time') select = category.id else: articles = CultureArticle.objects.all().order_by('-create_time') select = 0 categorys = CultureCategory.objects.all().order_by('-create_time') page = request.GET.get('page') pageobj = Page(articles, 5, page) context = pageobj.paging() # context['category_id'] = category context['categorys'] = categorys context['select'] = select return render(request, 'culture_center.html', context)
def get(self, request): '''查询谱书''' search_key = request.GET.get('q') books = GeneBook.objects.filter( Q(name__contains=search_key) | Q(author__contains=search_key) | Q(addr__contains=search_key)) book_list = [] for book in books: if book.audit_status != 3: continue if book.grant: continue book_list.append(book) books = book_list page = request.GET.get('page') pageobj = Page(books, 8, page) context = pageobj.paging() context['query'] = search_key if books: context['books_total_num'] = len(books) else: context['books_total_num'] = 0 return render(request, 'search_book.html', context)
def get(self, request): '''查询谱书图片''' search_key = request.GET.get('q') articles = Article.objects.filter( Q(name__contains=search_key) | Q(content__contains=search_key)) article_list = [] for article in articles: if article.book_id.audit_status != 3: continue if article.book_id.grant: continue article_list.append(article) article.desc = self.handle_str(article.content[:1000]) articles = article_list page = request.GET.get('page') pageobj = Page(articles, 5, page) context = pageobj.paging() context['query'] = search_key if articles: context['articles_total_num'] = len(articles) else: context['articles_total_num'] = 0 return render(request, 'search_book_article.html', context)
def get(self, request): '''查询文化中心文章''' search_key = request.GET.get('q') if search_key: articles = CultureArticle.objects.filter( Q(title__contains=search_key) | Q(author__contains=search_key) | Q(introduce__contains=search_key)) page = request.GET.get('page') pageobj = Page(articles, 5, page) context = pageobj.paging() context['query'] = search_key else: context = {'query', '关键字为空,请重新输入'} return render(request, 'search_culture_center.html', context)
def get(self, request, imgdb_id): '''展示上传图片页面''' try: imgdb = ImgsDatabase.objects.get(id=imgdb_id) except ImgsDatabase.DoesNotExist: return HttpResponse("获取失败") book_id = imgdb.book_id.id imgs = imgdb.imgs_set.all().order_by('-create_time') page = request.GET.get('page') pageobj = Page(imgs, 12, page) context = pageobj.paging() context['imgs'] = imgs context['imgdb_id'] = imgdb_id context['imgdb'] = imgdb context['book_id'] = book_id return render(request, 'family_create_upload_img.html', context)
def get(self, request): '''显示''' sort = request.GET.get('sort') if sort == 'intro': genebooks = GeneBook.objects.filter( grant=False, audit_status=3).order_by('-read_count') elif sort == 'new': genebooks = GeneBook.objects.filter( audit_status=3).order_by('-create_time') elif sort == 'open': genebooks = GeneBook.objects.filter(grant=False, audit_status=3) else: sort = 'all' genebooks = GeneBook.objects.filter(audit_status=3) page = request.GET.get('page') pageobj = Page(genebooks, 8, page) context = pageobj.paging() context['books'] = genebooks context['sort'] = sort return render(request, 'family_center.html', context)
def get(self, request): '''查询谱书图片''' search_key = request.GET.get('q') imgs = Imgs.objects.filter(Q(detail__contains=search_key)) img_list = [] for img in imgs: if img.imgsdb_id.book_id.audit_status != 3: continue if img.imgsdb_id.book_id.grant: continue img_list.append(img) imgs = img_list page = request.GET.get('page') pageobj = Page(imgs, 12, page) context = pageobj.paging() # 左右箭头换图 img_id = request.GET.get('img_id') if img_id: if imgs: paginator = FooterPage(imgs, 1, img_id) img_page_prev, img_page_next, num_pages, img_page = paginator.paging( ) img = Imgs.objects.get(id=img_id) print(img) context['img'] = img context['img_page'] = img_page context['img_page_prev'] = img_page_prev context['img_page_next'] = img_page_next context['num_pages'] = num_pages context['query'] = search_key if imgs: context['imgs_total_num'] = len(imgs) else: context['imgs_total_num'] = 0 return render(request, 'search_book_img.html', context)
def get(self, request, imgdb_id): '''展示图片''' # 获取图片信息 try: imgdb = ImgsDatabase.objects.get(id=imgdb_id) except ImgsDatabase.DoesNotExist: return HttpResponse("获取失败") book = imgdb.book_id imgdbs = ImgsDatabase.objects.filter(book_id=book) paginator = FooterPage(imgdbs, 1, imgdb_id) imgdb_page_prev, imgdb_page_next, num_pages, imgdb_page = paginator.paging( ) imgs = imgdb.imgs_set.all().order_by('-create_time') page = request.GET.get('page') pageobj = Page(imgs, 12, page) context = pageobj.paging() context['imgdb_id'] = imgdb_id context['imgdb'] = imgdb context['book'] = book context['imgdb_page_prev'] = imgdb_page_prev context['imgdb_page_next'] = imgdb_page_next img_id = request.GET.get('img_id') if img_id: paginator = FooterPage(imgs, 1, img_id) img_page_prev, img_page_next, num_pages, img_page = paginator.paging( ) img = Imgs.objects.get(id=img_id) context['img'] = img context['img_page'] = img_page context['img_page_prev'] = img_page_prev context['img_page_next'] = img_page_next context['num_pages'] = num_pages return render(request, 'family_read_preview_img.html', context)
def get(self, request): '''查询谱书世系人物''' search_key = request.GET.get('q') key = search_key.lstrip('王') # 判断是哪个页面发起的访问:世系表页面where,需要世系节点id, where = request.GET.get('where') if where == 'ztree': # 若是世系表阅读发起的异步请求 ztree_id = request.GET.get('id') try: ztree = Ztree.objects.get(id=ztree_id) except: return JsonResponse({"res": 2, "errmsg": '世系表获取失败'}) persons = NodePerson.objects.filter(first_name=key) if not persons: return JsonResponse({"res": 3, "errmsg": '无相关人物信息'}) person_list = [] person_dict = {} for person in persons: if person.node_id.ztree_id == ztree: person = self.manage_info(person) person_dict['name'] = search_key person_dict['rank'] = person.rank person_dict['brank'] = person.brank person_dict['ztree'] = person.node_id.ztree_id.name person_dict['node_id'] = person.node_id.id if person.node_id.pid: person_dict['parent'] = person.node_id.pid.name else: person_dict['parent'] = '根节点人物' person_dict['brank'] = '' person_list.append(person_dict) return JsonResponse({"res": 1, "successmsg": person_list}) persons = NodePerson.objects.filter( Q(first_name__contains=key) | Q(other_name__contains=key) | Q(desc__contains=key)) person_list = [] for person in persons: if person.node_id.ztree_id.book_id.audit_status != 3: continue if person.node_id.ztree_id.book_id.grant: continue person_list.append(self.manage_info(person)) persons = person_list page = request.GET.get('page') pageobj = Page(persons, 5, page) context = pageobj.paging() context['query'] = search_key if persons: context['persons_total_num'] = len(persons) else: context['persons_total_num'] = 0 return render(request, 'search_book_person.html', context)