Пример #1
0
 def test_sanitize_filename(self):
     self.assertEqual(sanitize_filename('foo.dat'), 'foo.dat')
     self.assertEqual(sanitize_filename('foo.bar.dat'), 'foobar.dat')
     self.assertEqual(sanitize_filename('foo bar.dat'), 'foo-bar.dat')
     self.assertEqual(sanitize_filename('ěščřž.dat'), 'escrz.dat')
     self.assertEqual(sanitize_filename(u'ěščřž.dat'), 'escrz.dat')
     self.assertEqual(sanitize_filename('.dat'), 'dat')
     self.assertEqual(sanitize_filename('foo.dať'), 'foo.dat')
Пример #2
0
def attachment_filename(instance, filename):
    return sanitize_filename(filename, 'files/courses')
Пример #3
0
def thesis_filename(instance, filename):
    return sanitize_filename(filename, 'thesis')
Пример #4
0
 def test_path(self):
     self.assertEqual(sanitize_filename('foo.dat'), 'foo.dat')
     self.assertEqual(sanitize_filename('foo.dat', ''), 'foo.dat')
     self.assertEqual(sanitize_filename('foo.dat', 'files/courses/'), 'files/courses/foo.dat')
     self.assertEqual(sanitize_filename('foo.dat', 'files/courses'), 'files/courses/foo.dat')
Пример #5
0
def cv_filename(instance, filename):
    return sanitize_filename(filename, 'cv')
Пример #6
0
def image_filename(instance, filename):
    return sanitize_filename(filename, 'img/person')