Skip to content
Open

Docs #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ node_modules/
.eggs/*
build/*
dist/*
README.rst
4 changes: 4 additions & 0 deletions .pyup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# autogenerated pyup.io config file
# see https://pyup.io/docs/configuration/ for all available options

update: insecure
11 changes: 11 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

python:
version: 3.7
install:
- requirements: docs/requirements.pip
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Changelog

## [Unreleased]
## 4.0.0 (23.05.2020)
### Added
- Support of Django 2.1
- Support of Django 2.2

### Removed
- Support of Django < 1.11
- Support of Python 2
- Support of Python 3.4

## 3.2.0 (03.05.2018)
* Support ImageField with constraints
Expand Down
142 changes: 0 additions & 142 deletions README.md

This file was deleted.

71 changes: 71 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
|Python| |Django| |License| |PyPIv| |PyPIs| |Build Status| |Coverage
Status| |Documentation Status| |Downloads|

ConstrainedFileField for Django
===============================

This Django app adds a new field type, ``ConstrainedFileField``, that
has the capability of checking the file size and type. Also provides a
javascript checker for the form field.

Features
--------

- File size limitation
- File type limitation
- Javascript file size checker

Documentation
-------------

Docs are available locally or on
`readthedocs.io <https://django-constrainedfilefield.readthedocs.io/>`__.

Note on DOS attacks
-------------------

Important note: the check of the file size is made by Django once the
whole file has been uploaded to the server and stored in a temp
directory (or in memory if the file is small). Thus, this is useful to
guarantee the quota of the users, for example, but will not stop an
attacking user that wants to block the server by sending huge files (e.
g. of several Gb).

To avoid this, you need to configure your front end to limit the size of
uploaded files. How to do it depends on the software you are using. For
example, if you use apache, you should use
`**LimitRequestBody** <http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody>`__
directive.

This is a complementary measure, because you'll usually want normal
users that exceed the size by a reasonable amount to get a friendly form
validation message, while attacking users will see how their connection
is abruptly cut before the file finishes uploading. So the recommended
setting is to give ``max_upload_size`` a small value (e.g. 5Mb) and
``LimitRequestBody`` a higher one (e.g. 100Mb).

Credits
-------

This is a fork of
`django-validated-file <https://github.com/kaleidos/django-validated-file>`__
from `Kaleidos <https://github.com/kaleidos>`__.

.. |Python| image:: https://img.shields.io/badge/Python-3.5,3.6,3.7,3.8-blue.svg?style=flat-square
:target: /
.. |Django| image:: https://img.shields.io/badge/Django-1.11,2.1,2.2-blue.svg?style=flat-square
:target: /
.. |License| image:: https://img.shields.io/badge/License-BSD--3--Clause-blue.svg?style=flat-square
:target: /LICENSE
.. |PyPIv| image:: https://img.shields.io/pypi/v/django-constrainedfilefield.svg?style=flat-square
:target: https://pypi.org/project/django-constrainedfilefield
.. |PyPIs| image:: https://img.shields.io/pypi/status/django-constrainedfilefield.svg
:target: https://pypi.org/project/django-constrainedfilefield
.. |Build Status| image:: https://travis-ci.org/mbourqui/django-constrainedfilefield.svg?branch=master
:target: https://travis-ci.org/mbourqui/django-constrainedfilefield
.. |Coverage Status| image:: https://coveralls.io/repos/github/mbourqui/django-constrainedfilefield/badge.svg
:target: https://coveralls.io/github/mbourqui/django-constrainedfilefield
.. |Documentation Status| image:: https://readthedocs.org/projects/django-constrainedfilefield/badge/?version=latest&style=flat-square
:target: https://django-constrainedfilefield.readthedocs.io/en/latest/?badge=latest
.. |Downloads| image:: https://pepy.tech/badge/django-constrainedfilefield
:target: https://pepy.tech/project/django-constrainedfilefield
2 changes: 1 addition & 1 deletion constrainedfilefield/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

__license__ = "BSD-3-Clause"
__author__ = "Marc Bourqui"
__version__ = "3.2.0"
__version__ = "4.0.0"
__version_info__ = tuple(
[
int(num) if num.isdigit() else num
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
72 changes: 72 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

try:
from importlib.metadata import metadata
except ImportError:
# Python <3.8
from importlib_metadata import metadata

PROJECT_NAME = "django-constrainedfilefield"
project_metadata = metadata(PROJECT_NAME)

project = project_metadata["name"]
author = project_metadata["author"]
copyright = f"2020, {author}"

# The full version, including alpha/beta/rc tags, in x.y.z.misc format
release = project_metadata["version"]
# The short X.Y version.
version = ".".join(release.split(".")[:2])


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx_rtd_theme", # RTD look and feel
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# Fix for RTD's old sphinx version, https://github.com/readthedocs/readthedocs.org/issues/2569
master_doc = 'index'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
21 changes: 21 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. django-constrainedfilefield documentation master file, created by
sphinx-quickstart on Sat May 30 22:44:47 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to django-constrainedfilefield's documentation!
=======================================================

.. toctree::
:maxdepth: 2
:caption: Contents:

installation
usage

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Loading