|
4 | 4 |
|
5 | 5 | from django.conf import settings |
6 | 6 | from django.contrib.auth.models import User |
7 | | -from django.urls import resolve, reverse |
8 | 7 | from django.test import TestCase |
9 | 8 | from django.test.utils import override_settings |
| 9 | +try: |
| 10 | + from django.urls import resolve, reverse |
| 11 | +except ImportError: |
| 12 | + from django.core.urlresolvers import resolve, reverse |
10 | 13 |
|
11 | 14 | from s3direct import widgets |
12 | 15 |
|
|
39 | 42 | u'server_side_encryption': None, |
40 | 43 | } |
41 | 44 |
|
| 45 | +def is_authenticated(user): |
| 46 | + if callable(user.is_authenticated): # Django =< 1.9 |
| 47 | + return user.is_authenticated() |
| 48 | + return user.is_authenticated |
| 49 | + |
42 | 50 | TEST_DESTINATIONS = { |
43 | 51 | 'misc': {'key': lambda original_filename: 'images/unique.jpg'}, |
44 | 52 | 'files': {'key': '/', 'auth': lambda u: u.is_staff}, |
45 | 53 | 'imgs': {'key': 'uploads/imgs', 'allowed': ['image/jpeg', 'image/png']}, |
46 | 54 | 'thumbs': {'key': 'uploads/thumbs', 'allowed': ['image/jpeg'], 'content_length_range': (1000, 50000)}, |
47 | | - 'vids': {'key': 'uploads/vids', 'auth': lambda u: u.is_authenticated, 'allowed': ['video/mp4']}, |
48 | | - 'cached': {'key': 'uploads/vids', 'auth': lambda u: u.is_authenticated, 'allowed': '*', |
| 55 | + 'vids': {'key': 'uploads/vids', 'auth': is_authenticated, 'allowed': ['video/mp4']}, |
| 56 | + 'cached': {'key': 'uploads/vids', 'auth': is_authenticated, 'allowed': '*', |
49 | 57 | 'acl': 'authenticated-read', 'bucket': 'astoragebucketname', 'cache_control': 'max-age=2592000', |
50 | 58 | 'content_disposition': 'attachment', 'server_side_encryption': 'AES256'}, |
51 | 59 | 'accidental-leading-slash': {'key': '/directory/leading'}, |
|
0 commit comments