def query_tag(tag): x = (Point.select().join(PointTag).join(Tag).where( Tag.tag == tag).order_by(Point.created_date.desc())) return render_template('index.html', points=x)
def homepage(): x = Point.select().order_by(Point.created_date.desc()).execute() return render_template('index.html', points=x)
def nearest(lon, lat): x = list(Point.select().execute()) # type: list[Point] x.sort(key=lambda z: (float(z.longitude) - lon)**2 + (float(z.latitude) - lat)**2) return render_template('index.html', points=x)
'三代雷达龙(光)', '三代雷达龙(暗)', '三代雷达龙(水)', '三代雷达龙(火)', '三代雷达龙(木)', '297光玻璃', '彩喇叭', '圣诞龙(不区分颜色)' ]: Tag.create(tag=tag) if sys.argv[1] == 'clear': Point.delete().execute() PointTag.delete().execute() elif sys.argv[1] == 'clear_mark': tags = {x.tag for x in Tag.select().execute()} tags.remove('地狱级npc') tags = list(tags) tags_id = [x for x in Tag.select().where(Tag.tag.in_(tags))] q = PointTag.delete().where(PointTag.tag.in_(tags_id)).execute() for p in Point.select(Point): new_tr = [x.tag.tag for x in p.pointtag] if not new_tr: p.delete_instance() else: p.treasure = ', '.join(new_tr) p.save() for p in UserPoint.select(): p.delete_instance() if sys.argv[1] == 'add': if sys.argv[2] == 'tag': Tag.create(sys.argv[3]) if sys.argv[1] == 'delete': if sys.argv[2] == 'tag': t = Tag.get(sys.argv[3])