def checkPointGone(point_id, username): print(point_id, username) try: user = User.get(username=username) p = Point.get(id=point_id) UserPoint.get(point=p, user=user) return True except DoesNotExist: return False
def ungone(): point_id = request.form.get('point_id', False) user = request.cookies.get('username', False) if not user or not point_id: print('missing sth') return 'nothing done' else: try: p = Point.get(id=point_id) u = User.get(username=user) u = UserPoint.get(user=u, point=p) # type: UserPoint u.delete_instance() return 'success' except DoesNotExist: return 'not exist'
def gone(): point_id = request.form.get('point_id', False) user = request.cookies.get('username', False) if not user or not point_id: return 'nothing done' else: p = Point.get(id=point_id) u = User.get(username=user) try: u, _ = UserPoint.get_or_create(user=u, point=p) if not _: return 'nothing done' else: return 'success' except DoesNotExist: return 'nothing done'
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]) t.delete() if sys.argv[2] == 'point': p = Point.get(longitude=sys.argv[3], latitude=sys.argv[4]) p.delete_instance() else: t = Tag.select(Tag).execute() for x in t: [print(y.point.treasure) for y in x.pointtag]