<commit_before>:tocdepth: 2

.. |grappelli| replace:: Grappelli
.. |filebrowser| replace:: FileBrowser

.. _views:

Views
=====

All views use the ``staff_member_requird`` and ``path_exists`` decorator in order to check if the server path actually exists. Some views also use the ``file_exists`` decorator.

Browse
------

Browse a directory on your server. Returns a :ref:`filelisting`::

    http://mysite.com/adminurl/filebrowser/browse/

* URL: ``fb_browse``
* Optional query string args: ``dir``, ``o``, ``ot``, ``q``, ``p``, ``filter_date``, ``filter_type``, ``type``

.. _views_createdir:

Create directory
----------------

Create a new folder on your server::

    http://mysite.com/adminurl/filebrowser/createdir/

* URL: ``fb_createdir``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_createdir`, :ref:`filebrowser_post_createdir`

.. _views_upload:

Upload
------

Multiple upload::

    http://mysite.com/adminurl/filebrowser/upload/

* URL: ``fb_upload``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_upload`, :ref:`filebrowser_post_upload`

.. _views_edit:

Edit
----

Edit a file or folder::

    http://mysite.com/adminurl/filebrowser/edit/?filename=testimage.jpg

* URL: ``fb_edit``
* Required query string args: ``filename``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_rename`, :ref:`filebrowser_post_rename`

You are able to apply custom actions (see :ref:`actions`) to the edit-view.

.. note::
    This won't check if you use the file or folder anywhere with your models.

.. _views_confirm_delete:

Confirm delete
--------------

Confirm the deletion of a file or folder::

    http://mysite.com/adminurl/filebrowser/confirm_delete/?filename=testimage.jpg

* URL: ``fb_confirm_delete``
* Required query string args: ``filename``
* Optional query string args: ``dir``

.. note::
    If you try to delete a folder, all files/folders within this folder are listed on this page.

.. _views_delete:

Delete
------

Delete a file or folder::

    http://mysite.com/adminurl/filebrowser/delete/?filename=testimage.jpg

* URL: ``fb_delete``
* Required query string args: ``filename``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_delete`, :ref:`filebrowser_post_delete`

.. note::
    This won't check if you use the file or folder anywhere with your models.

.. warning::
    If you delete a Folder, all items within this Folder are being deleted.

.. _views_version:

Version
-------

Generate a version of an Image as defined with ``ADMIN_VERSIONS``::

    http://mysite.com/adminurl/filebrowser/version/?filename=testimage.jpg

* URL: ``fb_version``
* Required query string args: ``filename``
* Query string args: ``dir``

.. note::
    This is a helper used by the ``FileBrowseField`` and TinyMCE for selecting an Image-Version.

.. _signals:

Signals
=======

The FileBrowser sends a couple of different signals:

.. _filebrowser_pre_upload:

``filebrowser_pre_upload``
--------------------------
<commit_msg>updating docs for admin interface, #166<commit_after>:tocdepth: 2

.. |grappelli| replace:: Grappelli
.. |filebrowser| replace:: FileBrowser

.. _views:

Adding Sites
============

Similar to ``django.contrib.admin``, you first need to add a ``filebrowser.site`` to your admin interface.

In your ``urls.py`` import the default FileBrowser site (or your custom site)::

    from filebrowser.sites import site

and add the site to your URL-patterns (before any admin-urls)::
    
    urlpatterns = patterns('',
       url(r'^adminurl/filebrowser/', include(site.urls)),
    )

Now you are able to browse the location defined with the storage engine associated to your site.

Views
=====

All views use the ``staff_member_requird`` and ``path_exists`` decorator in order to check if the server path actually exists. Some views also use the ``file_exists`` decorator.

Browse
------

Browse a directory on your server. Returns a :ref:`filelisting`::

    /adminurl/filebrowser/browse/

* URL: ``fb_browse``
* Optional query string args: ``dir``, ``o``, ``ot``, ``q``, ``p``, ``filter_date``, ``filter_type``, ``type``

.. _views_createdir:

Create directory
----------------

Create a new folder on your server::

    /adminurl/filebrowser/createdir/

* URL: ``fb_createdir``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_createdir`, :ref:`filebrowser_post_createdir`

.. _views_upload:

Upload
------

Multiple upload::

    /adminurl/filebrowser/upload/

* URL: ``fb_upload``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_upload`, :ref:`filebrowser_post_upload`

.. _views_edit:

Edit
----

Edit a file or folder::

    /adminurl/filebrowser/edit/?filename=testimage.jpg

* URL: ``fb_edit``
* Required query string args: ``filename``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_rename`, :ref:`filebrowser_post_rename`

You are able to apply custom actions (see :ref:`actions`) to the edit-view.

.. note::
    This won't check if you use the file or folder anywhere with your models.

.. _views_confirm_delete:

Confirm delete
--------------

Confirm the deletion of a file or folder::

    /adminurl/filebrowser/confirm_delete/?filename=testimage.jpg

* URL: ``fb_confirm_delete``
* Required query string args: ``filename``
* Optional query string args: ``dir``

.. note::
    If you try to delete a folder, all files/folders within this folder are listed on this page.

.. _views_delete:

Delete
------

Delete a file or folder::

    /adminurl/filebrowser/delete/?filename=testimage.jpg

* URL: ``fb_delete``
* Required query string args: ``filename``
* Optional query string args: ``dir``
* Signals: :ref:`filebrowser_pre_delete`, :ref:`filebrowser_post_delete`

.. note::
    This won't check if you use the file or folder anywhere with your models.

.. warning::
    If you delete a Folder, all items within this Folder are being deleted.

.. _views_version:

Version
-------

Generate a version of an Image as defined with ``ADMIN_VERSIONS``::

    /adminurl/filebrowser/version/?filename=testimage.jpg

* URL: ``fb_version``
* Required query string args: ``filename``
* Query string args: ``dir``

.. note::
    This is a helper used by the ``FileBrowseField`` and TinyMCE for selecting an Image-Version.

.. _signals:

Signals
=======

The FileBrowser sends a couple of different signals:

.. _filebrowser_pre_upload:

``filebrowser_pre_upload``
--------------------------

{'fraction_non_alphanumeric': 0.15349052242256125, 'fraction_numerical': 0.0007705347511172754, 'mean_word_length': 3.8833709556057188, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6835967', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1969, 'n_words': 650}