publishers_6.py 737 B

123456789101112131415161718192021
  1. def validate_plupload(request, pub_name, file_name, labelsContent):
  2. file_name = os.path.basename(file_name).strip().replace(" ", "_")
  3. if pub_name == "BED":
  4. # validate bed file name is unique
  5. if models.Content.objects.filter(file__endswith="/" + file_name).count() > 0:
  6. raise Exception(
  7. validation.invalid_entity_field_unique_value(
  8. labelsContent.verbose_name,
  9. labelsContent.pickfile.verbose_name,
  10. file_name,
  11. )
  12. )
  13. # validate file name
  14. if not validation.is_valid_chars(file_name):
  15. raise Exception(validation.invalid_chars_error("BED file name"))
  16. return file_name