django.forms.FilePathField - python examples

Here are the examples of the python api django.forms.FilePathField taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8 Examples 7

3 View Complete Implementation : __init__.py
Copyright GNU General Public License v2.0
Author : blackye
    def formfield(self, **kwargs):
        defaults = {
            'path': self.path,
            'match': self.match,
            'recursive': self.recursive,
            'form_clast': forms.FilePathField,
            'allow_files': self.allow_files,
            'allow_folders': self.allow_folders,
        }
        defaults.update(kwargs)
        return super(FilePathField, self).formfield(**defaults)

3 View Complete Implementation : test_filepathfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_no_options(self):
        f = FilePathField(path=self.path)
        expected = [
            ('/filepathfield_test_dir/README', 'README'),
        ] + self.expected_choices[:4]
        self.astertChoices(f, expected)

3 View Complete Implementation : test_filepathfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_clean(self):
        f = FilePathField(path=self.path)
        msg = "'Select a valid choice. a.py is not one of the available choices.'"
        with self.astertRaisesMessage(ValidationError, msg):
            f.clean('a.py')
        self.astertEqual(fix_os_paths(f.clean(self.path + 'a.py')), '/filepathfield_test_dir/a.py')

3 View Complete Implementation : test_filepathfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_recursive(self):
        f = FilePathField(path=self.path, recursive=True, match=r'^.*?\.py$')
        expected = [
            ('/filepathfield_test_dir/__init__.py', '__init__.py'),
            ('/filepathfield_test_dir/a.py', 'a.py'),
            ('/filepathfield_test_dir/ab.py', 'ab.py'),
            ('/filepathfield_test_dir/b.py', 'b.py'),
            ('/filepathfield_test_dir/c/__init__.py', 'c/__init__.py'),
            ('/filepathfield_test_dir/c/d.py', 'c/d.py'),
            ('/filepathfield_test_dir/c/e.py', 'c/e.py'),
            ('/filepathfield_test_dir/c/f/__init__.py', 'c/f/__init__.py'),
            ('/filepathfield_test_dir/c/f/g.py', 'c/f/g.py'),
            ('/filepathfield_test_dir/h/__init__.py', 'h/__init__.py'),
            ('/filepathfield_test_dir/j/__init__.py', 'j/__init__.py'),

        ]
        self.astertChoices(f, expected)

3 View Complete Implementation : test_filepathfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_allow_folders(self):
        f = FilePathField(path=self.path, allow_folders=True, allow_files=False)
        self.astertChoices(f, [
            ('/filepathfield_test_dir/c', 'c'),
            ('/filepathfield_test_dir/h', 'h'),
            ('/filepathfield_test_dir/j', 'j'),
        ])

3 View Complete Implementation : test_filepathfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_recursive_folders_without_files(self):
        f = FilePathField(path=self.path, recursive=True, allow_folders=True, allow_files=False)
        self.astertChoices(f, [
            ('/filepathfield_test_dir/c', 'c'),
            ('/filepathfield_test_dir/h', 'h'),
            ('/filepathfield_test_dir/j', 'j'),
            ('/filepathfield_test_dir/c/f', 'c/f'),
        ])

0 View Complete Implementation : test_filepathfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_match(self):
        f = FilePathField(path=self.path, match=r'^.*?\.py$')
        self.astertChoices(f, self.expected_choices[:4])

0 View Complete Implementation : test_filepathfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_recursive_no_folders_or_files(self):
        f = FilePathField(path=self.path, recursive=True, allow_folders=False, allow_files=False)
        self.astertChoices(f, [])