25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

52 satır
1.5 KiB

  1. import webnotes
  2. @webnotes.whitelist()
  3. def remove_attach():
  4. """remove attachment"""
  5. import webnotes.utils.file_manager
  6. fid = webnotes.form.getvalue('fid')
  7. webnotes.utils.file_manager.delete_file(fid, verbose=1)
  8. # remove from dt dn
  9. return str(webnotes.utils.file_manager.remove_file_list(webnotes.form.getvalue('dt'), webnotes.form.getvalue('dn'), fid))
  10. @webnotes.whitelist()
  11. def get_fields():
  12. """get fields"""
  13. r = {}
  14. args = {
  15. 'select':webnotes.form.getvalue('select')
  16. ,'from':webnotes.form.getvalue('from')
  17. ,'where':webnotes.form.getvalue('where')
  18. }
  19. ret = webnotes.conn.sql("select %(select)s from `%(from)s` where %(where)s limit 1" % args)
  20. if ret:
  21. fl, i = webnotes.form.getvalue('fields').split(','), 0
  22. for f in fl:
  23. r[f], i = ret[0][i], i+1
  24. webnotes.response['message']=r
  25. @webnotes.whitelist()
  26. def validate_link():
  27. """validate link when updated by user"""
  28. import webnotes
  29. import webnotes.utils
  30. value, options, fetch = webnotes.form.getvalue('value'), webnotes.form.getvalue('options'), webnotes.form.getvalue('fetch')
  31. # no options, don't validate
  32. if not options or options=='null' or options=='undefined':
  33. webnotes.response['message'] = 'Ok'
  34. return
  35. if webnotes.conn.sql("select name from `tab%s` where name=%s" % (options, '%s'), value):
  36. # get fetch values
  37. if fetch:
  38. webnotes.response['fetch_values'] = [webnotes.utils.parse_val(c) \
  39. for c in webnotes.conn.sql("select %s from `tab%s` where name=%s" \
  40. % (fetch, options, '%s'), value)[0]]
  41. webnotes.response['message'] = 'Ok'