Skip to content

Commit

Permalink
Merge pull request #22 from caktus/django-1-10
Browse files Browse the repository at this point in the history
Django 1.8-1.10 support
  • Loading branch information
vkurup committed Oct 26, 2017
2 parents d6d5db3 + 3d7e91e commit 362f619
Show file tree
Hide file tree
Showing 39 changed files with 417 additions and 372 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source = file_picker
omit = */tests*,*/migrations/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
*.db
sample_project/sample_project/media
sample_project/media
_build
*.egg-info*
.tox
.coverage
7 changes: 0 additions & 7 deletions .hgignore

This file was deleted.

10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python

python:
- "2.7"

install:
- pip install tox

script:
- tox
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2007-2012, Caktus Consulting Group, LLC
Copyright (c) 2007-2017, Caktus Consulting Group, LLC
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
22 changes: 11 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ Dependencies

Required
````````
* Python 2.6 or 2.7 (**note**: Python 3 is not yet supported)
* `Django 1.6 to 1.9 (inclusive) <http://www.djangoproject.com/>`_
* sorl-thumbnail==12.3
* Python 2.7 (**note**: Python 3 is not yet supported)
* `Django 1.8 to 1.10 (inclusive) <http://www.djangoproject.com/>`_
* sorl-thumbnail==12.4a1
* `jQuery 1.4.x <http://www.jquery.com/>`_
* `jQuery Tools 1.2.x <http://flowplayer.org/tools/>`_
* `AJAX Upload <http://valums.com/ajax-upload/>`_ (included)

Optional
````````
* `django-staticfiles <https://github.com/jezdez/django-staticfiles>`_
* `django.contrib.staticfiles <https://docs.djangoproject.com/en/1.8/howto/static-files/>`_
* `WYMeditor 0.5 <http://www.wymeditor.org/>`_

If you are using *django-staticfiles* (or ``django.contrib.staticfiles`` in Django
1.3) then add ``file_picker`` to your INSTALLED_APPS to include the related css/js.
If you are using ``django.contrib.staticfiles``, then add ``file_picker`` to your INSTALLED_APPS
to include the related css/js.

Otherwise make sure to include the contents of the static folder in your projects
media folder.
Expand All @@ -54,17 +54,17 @@ Basic Installation
'file_picker.wymeditor', # optional WYMeditor plugin
)

``file_picker.uploads`` will automatically create two pickers name 'images' and 'files'.
``file_picker.uploads`` will automatically create two pickers named 'images' and 'files'.

#. Add the ``file_picker`` URLs to urls.py, e.g.::

from django.conf.urls import include, url
import file_picker
file_picker.autodiscover()

urlpatterns = patterns('',
urlpatterns = [
# ...
(r'^file-picker/', include(file_picker.site.urls)),
url(r'^file-picker/', include(file_picker.site.urls)),
# ...
)
]

Development sponsored by `Caktus Consulting Group, LLC. <http://www.caktusgroup.com/services>`_.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# General information about the project.
project = u'django-file-picker'
copyright = u'2011, Caktus Consulting Group LLC'
copyright = u'2011-2017, Caktus Consulting Group LLC'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ Contents

.. toctree::
:maxdepth: 2

setup
uploads
wymeditor
picker_config
screenshots
motivation
sample

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

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

6 changes: 3 additions & 3 deletions docs/motivation.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Motivation
==========

The deep concern while building file picker has been flexibility. Too many
projects focus on wrapping everything together so that they can make
The deep concern while building a file picker has been flexibility. Too many
projects focus on wrapping everything together so that they can make
deep connections.

Our main goal has been to build a application that facilitates connections,
that can be attached accross multiple applications and models.
that can be attached across multiple applications and models.
35 changes: 16 additions & 19 deletions docs/picker_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The FilePickerBase Class
========================

The base file picker class has a mixture of class based views and helper functions
for building the colorbox on the page. File pickers should be included in the
for building the colorbox on the page. File pickers should be included in the
*file_pickers.py* file in the root directory of any app so that the auto-discovery
process can find it.
process can find it.


Attributes
Expand All @@ -21,7 +21,7 @@ Each picker can take a set of attributes for easy customization.::
from myapp.models import CustomModel
from myapp.forms import CustomForm
import file_pickers

class CustomPicker(file_picker.FilePickerBase):
form = CustomForm
page_size = 4
Expand All @@ -30,30 +30,30 @@ Each picker can take a set of attributes for easy customization.::
extra_headers = ['Name', 'Body', 'Description',]
ordering = '-date'

file_picker.site.register(CustomModel, CustomPicker, name='custom')
None of these attributes are required and they all have sane defaults.
file_picker.site.register(CustomModel, CustomPicker, name='custom')

None of these attributes are required and they all have sane defaults.

* *form*- If left blank is created by building a *ModelForm* from the model defined
* *form*- If left blank is created by building a *ModelForm* from the model defined
in the register function. It is used to build the form on the Upload tab.

* *link_headers*- Defines the headers for the first set of columns which are used
* *link_headers*- Defines the headers for the first set of columns which are used
to insert content into the textbox or WYSIWYG of your choice. By default it
converts _ to ' ' and capitalizes first letter of the fields name.

* *columns*- Defines the fields you want to be included on the listing page
and their ordering.
and their ordering.
* *extra_headers*- The list is used to define the headers for the columns
and needs to be in the same order as columns.
* *ordering*- Defines the order of items on the listing page in
and needs to be in the same order as columns.
* *ordering*- Defines the order of items on the listing page in
to be used as ``query_set.order_by('-date')``.

Methods
-------

The three main methods consist of *append*, *list*, and *upload_file*. List and upload_file
take in the request object and act as views while append takes in an model item and helps
build the JSON output for list. Other methods are available but typically do not
build the JSON output for list. Other methods are available but typically do not
need to be modified.

append(obj)
Expand All @@ -63,7 +63,7 @@ This method takes in *obj* which is a item from the model and outputs a dictiona
to be used by list. This dictoinary is of the form.::

{
'name': 'Name for the object.',
'name': 'Name for the object.',
'url': 'The url to the file.',
'extra': {
'column_name_1': 'value',
Expand Down Expand Up @@ -96,15 +96,12 @@ This takes in a *request* object and outputs.::
upload_file(request)
^^^^^^^^^^^^^^^^^^^^

Builds the upload file form and is used to upload files in two steps,
Builds the upload file form and is used to upload files in two steps,
file first then the other form parameters.

If called without a POST it returns a JSON dictionary with the key form
with an html block for the form.

If called with a file and then with the post, its a two step process. If the form
passed on the second step it returns the result of append for the object which
If called with a file and then with the post, it's a two step process. If the form
passed on the second step it returns the result of append for the object which
was just created.



17 changes: 17 additions & 0 deletions docs/sample.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Running the Sample Project
===============================

django-file-picker includes a sample project to use as an example. You can run the sample project like so::

~$ mkvirtualenv --distribute filepicker-sample
(filepicker-sample)~$ pip install "django>=1.8,<1.11"
(filepicker-sample)~$ git clone git://github.com/caktus/django-file-picker.git
(filepicker-sample)~$ cd django-file-picker/
(filepicker-sample)~/django-file-picker$ python setup.py develop
(filepicker-sample)~/django-file-picker$ cd sample_project/
(filepicker-sample)~/django-file-picker/sample_project$ ./manage.py migrate
(filepicker-sample)~/django-file-picker/sample_project$ ./manage.py createsuperuser
(filepicker-sample)~/django-file-picker/sample_project$ ./manage.py runserver

Then go to the `admin <http://localhost:8000/admin/>`_, log in, and add an Article Post. There will be 2
links to 'Insert File' and 'Insert Image' which will pop up the File Picker dialog.
7 changes: 3 additions & 4 deletions docs/screenshots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ Screenshots
.. figure:: images/overlay_upload.png
:align: center
:width: 800px

The upload pane from the sample project.

.. figure:: images/browse.png
:align: center
:width: 800px

The browser pane from the sample project.

.. figure:: images/insert.png
:align: center
:width: 800px

An example of inseting an image with File Picker.

An example of inserting an image with File Picker.
20 changes: 9 additions & 11 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
Basic Setup
===========

#. Use or create a model for storing images and/or files. For simplicity here
we will use the models in ``file_picker.uploads``, Image and File.
#. Use or create a model for storing images and/or files. For simplicity here
we will use the models in ``file_picker.uploads``: Image and File.

#. Use or create another model to contian the text field(s) to be inserted in
#. Use or create another model to contain the text field(s) to be inserted
by the picker. Here we will use the Post model from the ``sample_project.article``.
Which has two text fields, Body and Teaser.
It has two text fields, Body and Teaser.

#. To use the pickers on both the teaser and body fields use a *formfield_override*
to override the widget with the ``file_picker.widgets.SimpleFilePickerWidget``::

import file_picker
from django.contrib import admin
from sample_project.article import models as article_models

class PostAdmin(admin.ModelAdmin):
formfield_overrides = {
models.TextField: {
Expand All @@ -26,10 +26,10 @@ Basic Setup
}),
},
}

class Media:
js = ("http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js",)

admin.site.register(article_models.Post, PostAdmin)


Expand All @@ -38,10 +38,8 @@ Simple File Picker Widget

.. class:: file_picker.widgets.SimpleFilePickerWidget

To use the simple file picker widget override the desired form field's widget.
To use the simple file picker widget, override the desired form field's widget.
It takes in a dictionary with expected keys `"image"` and/or `"file"` these
define which link to use "Add Image" and/or "Add File".

For an example of usage look at the.


12 changes: 6 additions & 6 deletions docs/uploads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
The Uploads App
=======================

Designed to make it easy to get File Picker up and running without having to add
models or register them with ``file_picker``. The uploads app includes two
simple pickers which can be attached to your own projects text fields. For install
instructions check out :ref:`setup`
The uploads app is designed to make it easy to get File Picker up and running without
having to add models or register them with ``file_picker``. The uploads app includes two
simple pickers which can be attached to your own project's text fields. For installation
instructions, check out :ref:`setup`

FilePicker
----------

.. class:: file_picker.uploads.file_pickers.FilePicker

Is a simple class based off of the ``file_picker.FilePickerBase``
Is a simple class based off of the ``file_picker.FilePickerBase``
which is connected to the *File* model and can be found in the Uploads admin
section.

Expand All @@ -23,7 +23,7 @@ ImagePicker

.. class:: file_picker.uploads.file_pickers.ImagePicker

Is a simple class based off of the ``file_picker.ImagePickerBase``
Is a simple class based off of the ``file_picker.ImagePickerBase``
which is connected to the *Image* model and can be found in the Uploads admin
section.

Expand Down
13 changes: 6 additions & 7 deletions docs/wymeditor.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
The WYMeditor App
=================

Included to make the intergration of File Picker with a popular WYSIWYG easy.
WYMeditor is a javascript based editor, its documentation can be found
`here <http://www.wymeditor.org/>`_. This application offers an extra form
widget for applying WYMeditor to a text field with buttons for files and images
if desired.
The WYMeditor app is included to make it easy to integrate a File Picker with a popular WYSIWYG
interface. WYMeditor is a Javascript based editor. Its documentation can be found `here
<http://www.wymeditor.org/>`_. This application offers an extra form widget for applying WYMeditor
to a text field with buttons for files and images if desired.

WYMeditorWidget
---------------

.. class:: file_picker.wymeditor.widgets.WYMeditorWidget

To use the WYMeditorWidget override the desired form field's widget. It takes in a
To use the WYMeditorWidget, override the desired form field's widget. It takes in a
dictionary with expected keys `"image"` and/or `"file"` these define which button
is used to call the overlay, either an image or a paper clip icon respectively.

Expand All @@ -34,6 +33,6 @@ File Picker for each `TextField` in the form.
),
},
}

class Media:
js = ("http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js",)

0 comments on commit 362f619

Please sign in to comment.