user_watch_list_name.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from .tool.func import *
  2. def user_watch_list_name(tool, name = 'Test'):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. ip = ip_check()
  6. if ip_or_user(ip) != 0:
  7. return redirect('/login')
  8. if tool == 'watch_list':
  9. curs.execute(db_change("select count(*) from scan where user = ?"), [ip])
  10. count = curs.fetchall()
  11. if count and count[0][0] > 9:
  12. return re_error('/error/28')
  13. type_data = ''
  14. else:
  15. type_data = 'star'
  16. curs.execute(db_change("select title from scan where user = ? and title = ? and type = ?"), [ip, name, type_data])
  17. if curs.fetchall():
  18. curs.execute(db_change("delete from scan where user = ? and title = ? and type = ?"), [ip, name, type_data])
  19. else:
  20. curs.execute(db_change("insert into scan (user, title, type) values (?, ?, ?)"), [ip, name, type_data])
  21. conn.commit()
  22. if tool == 'watch_list':
  23. return redirect('/watch_list')
  24. else:
  25. return redirect('/star_doc')