Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shelldweller committed Nov 17, 2013
1 parent 541efe3 commit dbb1a77
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Media browser for Django.
Setup
-----

By default mediabrowser uses [easy-thumbnails](https://github.com/SmileyChris/easy-thumbnails)
for crating image thumbnails. Unless you plan to use your own thumbnailing tool you need to
install easy-thumbnails too.

In settings.py:

```python
Expand All @@ -23,7 +27,7 @@ MEDIABROWSER_UPLOAD_TO = "mb/%Y/%m"
MEDIABROWSER_PAGE_SELECTOR_URL = "my-cms-url-content-selector-name"

# Function for user access to mediabrowser
# (defaults is user.is_staff)
# (defaults to user.is_staff)
MEDIABROWSER_USER_PASSES_TEST = lambda user:user.is_authenticated
```

Expand All @@ -43,7 +47,8 @@ After having added ```mediabrowser``` to ```INSTALLED_APPS``` run ```./manage.py
Controlling mediabrowser access
-------------------------------

By default media browser access is allowed for any authenticated user. If this is not
By default media browser access is allowed for any authenticated stuff user
(i.e., ```user.is_stuff == True```). If this is not
what you need you could do one of the following:

* Set ```MEDIABROWSER_USER_PASSES_TEST```. It should be a callable that takes user object as argument
Expand All @@ -60,25 +65,25 @@ to link to, do the following:
* Define your own view listing content.
* Set ```MEDIABROWSER_PAGE_SELECTOR_URL``` to url name of this view.
* Make your view's template inherit from ```mediabrowser/base.html```.
(Required context variables: asset_type=doc, page_selector_url=<your_url>)
(Required context variables: asset_type=doc, page_selector_url=*your_url*)

Subclass ```mediabrowser.views.BaseAssetListView``` or create your own view with
the following to template context:
You CMS integration view can be created by subclassing
```mediabrowser.views.BaseAssetListView```. But you can also create your view from scratch.
Just pass the following context to the template:

```python
context = {
# media browser needs to retain original query string set by the editor:
# mediabrowser needs to retain original query string set by the editor:
'QUERY_STRING': self.request.GET.urlencode(),

# set asset_type to doc to use mediabrowser in link mode (as apposed to image insertion mode),
# set asset_type to doc to use mediabrowser in link mode
# (as apposed to image insertion mode),
# otherwise "Browse documents" and "Browse content" tabs won't appear:
"asset_type": "doc",

# Editor needs to know your page_selector_url, otherwise it will not display the
# "Browse content" tab:
"page_selector_url": settings.MEDIABROWSER_PAGE_SELECTOR_URL

'QUERY_STRING': request.GET.urlencode(),
}
```

Expand Down

0 comments on commit dbb1a77

Please sign in to comment.