def get_tags(): tags = Item.list('editor_tags', TAGS, coerce=str) data = [] for tag in tags: subs = [] t = Tag.objects(name=tag).first() if t: subs = list(Tag.objects(parents=t).order_by('-weight').limit(30)) data.append(dict(tag=tag, subs=subs)) return data
def index(): tags = Item.list('algorithm_tags', TAGS, coerce=str) data = [] for tag in tags: subs = [] t = Tag.objects(name=tag).first() if t: subs = list(Tag.objects(parents=t).order_by('-weight').limit(20)) questions = Question.objects( tags__in=subs + [t]).order_by('-weight').limit(9) if questions: data.append(dict(tag=tag, subs=subs[:8], questions=questions)) return render_template('common/index.html', data=data)