mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-22 09:18:13 +00:00
Remind me to never use Django again
This commit is contained in:
@@ -14,4 +14,4 @@ RUN mkdir /files/static && \
|
|||||||
chmod +x /code/run_celery.sh
|
chmod +x /code/run_celery.sh
|
||||||
|
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
RUN pip install -r requirements.txt
|
#RUN pip install -r requirements.txt
|
||||||
|
|||||||
@@ -1,37 +1,33 @@
|
|||||||
from azure.common import AzureMissingResourceHttpError
|
from azure.common import AzureMissingResourceHttpError
|
||||||
from azure.storage.blob import BlobService
|
from azure.storage.blob import BlockBlobService, ContentSettings
|
||||||
|
|
||||||
from dss import settings
|
from dss import settings
|
||||||
from dss.storagesettings import AZURE_ACCOUNT_NAME, AZURE_ACCOUNT_KEY, AZURE_CONTAINER
|
from dss.storagesettings import AZURE_ACCOUNT_NAME, AZURE_ACCOUNT_KEY, AZURE_CONTAINER
|
||||||
|
|
||||||
|
|
||||||
def upload_file_to_azure(in_file, file_name, container_name=settings.AZURE_CONTAINER):
|
def upload_file_to_azure(in_file, file_name, content_type='audio/mpeg', container_name=settings.AZURE_CONTAINER):
|
||||||
try:
|
try:
|
||||||
blob_service = BlobService(AZURE_ACCOUNT_NAME, AZURE_ACCOUNT_KEY)
|
blob_service = BlockBlobService(account_name=AZURE_ACCOUNT_NAME, account_key=AZURE_ACCOUNT_KEY)
|
||||||
blob_service.put_block_blob_from_path(
|
blob_service.create_blob_from_path(
|
||||||
container_name=container_name,
|
container_name=container_name,
|
||||||
blob_name=file_name,
|
blob_name=file_name,
|
||||||
file_path=in_file,
|
file_path=in_file,
|
||||||
x_ms_blob_content_type='application/octet-stream'
|
content_settings=ContentSettings(content_type=content_type)
|
||||||
)
|
)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print("Failed to upload blob: {0}".format(ex))
|
print("Failed to upload blob: {0}".format(ex))
|
||||||
|
|
||||||
|
|
||||||
def set_azure_details(blob_name, download_name, container_name=AZURE_CONTAINER):
|
def set_azure_details(blob_name, download_name, content_type='audio/mpeg', container_name=AZURE_CONTAINER):
|
||||||
try:
|
try:
|
||||||
blob_service = BlobService(AZURE_ACCOUNT_NAME, AZURE_ACCOUNT_KEY)
|
blob_service = BlockBlobService(account_name=AZURE_ACCOUNT_NAME, account_key=AZURE_ACCOUNT_KEY)
|
||||||
blob = blob_service.get_blob(container_name, blob_name)
|
blob_service.set_blob_properties(
|
||||||
if blob:
|
container_name,
|
||||||
blob_service.set_blob_properties(
|
blob_name,
|
||||||
container_name,
|
content_settings=ContentSettings(content_type=content_type,
|
||||||
blob_name,
|
content_disposition='attachment;filename="{0}"'.format(download_name))
|
||||||
x_ms_blob_content_type='audio/mpeg',
|
)
|
||||||
x_ms_blob_content_disposition='attachment;filename="{0}"'.format(download_name)
|
print("Processed: %s" % download_name)
|
||||||
)
|
|
||||||
print("Processed: %s" % download_name)
|
|
||||||
else:
|
|
||||||
print("No blob found for: %s" % download_name)
|
|
||||||
except AzureMissingResourceHttpError:
|
except AzureMissingResourceHttpError:
|
||||||
print("No blob found for: %s" % download_name)
|
print("No blob found for: %s" % download_name)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@@ -50,7 +46,7 @@ def file_exists(url):
|
|||||||
|
|
||||||
|
|
||||||
def enumerate_objects(container):
|
def enumerate_objects(container):
|
||||||
blob_service = BlobService(AZURE_ACCOUNT_NAME, AZURE_ACCOUNT_KEY)
|
blob_service = BlockBlobService(account_name=AZURE_ACCOUNT_NAME, account_key=AZURE_ACCOUNT_KEY)
|
||||||
blobs = blob_service.list_blobs(container)
|
blobs = blob_service.list_blobs(container)
|
||||||
items = []
|
items = []
|
||||||
for blob in blobs:
|
for blob in blobs:
|
||||||
@@ -60,5 +56,5 @@ def enumerate_objects(container):
|
|||||||
|
|
||||||
|
|
||||||
def delete_object(container, name):
|
def delete_object(container, name):
|
||||||
blob_service = BlobService(AZURE_ACCOUNT_NAME, AZURE_ACCOUNT_KEY)
|
blob_service = BlockBlobService(account_name=AZURE_ACCOUNT_NAME, account_key=AZURE_ACCOUNT_KEY)
|
||||||
blob_service.delete_blob(container, name)
|
blob_service.delete_blob(container, name)
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ DATABASE_HOST = os.environ.get('DATABASE_HOST', 'localhost')
|
|||||||
|
|
||||||
STATIC_URL = '/assets/'
|
STATIC_URL = '/assets/'
|
||||||
|
|
||||||
MEDIA_ROOT = os.environ.get('MEDIA_ROOT', '/mnt/dev/deepsouthsounds.com/media')
|
MEDIA_ROOT = os.environ.get('MEDIA_ROOT', '/home/fergalm/dev/deepsouthsounds.com/media')
|
||||||
STATIC_ROOT = os.environ.get('STATIC_ROOT', '/home/fergalm/dev/personal/deepsouthsounds.com/cache/static')
|
STATIC_ROOT = os.environ.get('STATIC_ROOT', '/home/fergalm/dev/deepsouthsounds.com/cache/static')
|
||||||
CACHE_ROOT = os.environ.get('CACHE_ROOT', '/mnt/dev/deepsouthsounds.com/cache')
|
CACHE_ROOT = os.environ.get('CACHE_ROOT', '/home/fergalm/dev/deepsouthsounds.com/cache')
|
||||||
|
|
||||||
MEDIA_URL = os.environ.get('MEDIA_URL', 'http://localhost/DSSMedia/') # '{0}media/'.format(CDN_URL)
|
MEDIA_URL = os.environ.get('MEDIA_URL', 'http://localhost/DSSMedia/') # '{0}media/'.format(CDN_URL)
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ from dss.psa import *
|
|||||||
from dss.celerysettings import *
|
from dss.celerysettings import *
|
||||||
from dss.localsettings import *
|
from dss.localsettings import *
|
||||||
|
|
||||||
|
DEBUG = False
|
||||||
|
DEFAULT_FILE_STORAGE = 'storages.backends.azure_storage.AzureStorage'
|
||||||
|
|
||||||
DEVELOPMENT = DEBUG
|
DEVELOPMENT = DEBUG
|
||||||
|
|
||||||
# AUTH_USER_MODEL = 'spa.UserProfile'
|
# AUTH_USER_MODEL = 'spa.UserProfile'
|
||||||
@@ -95,7 +98,7 @@ TEMPLATES = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.gzip.GZipMiddleware',
|
'django.middleware.gzip.GZipMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
@@ -160,7 +163,7 @@ INSTALLED_APPS = (
|
|||||||
LOGIN_REDIRECT_URL = reverse_lazy('home')
|
LOGIN_REDIRECT_URL = reverse_lazy('home')
|
||||||
LOGOUT_URL = reverse_lazy('home')
|
LOGOUT_URL = reverse_lazy('home')
|
||||||
|
|
||||||
FACEBOOK_APP_ID = '154504534677009'
|
FACEBOOK_APP_ID = '344996219591469'
|
||||||
|
|
||||||
AVATAR_STORAGE_DIR = MEDIA_ROOT + '/avatars/'
|
AVATAR_STORAGE_DIR = MEDIA_ROOT + '/avatars/'
|
||||||
ACCOUNT_LOGOUT_REDIRECT_URL = '/'
|
ACCOUNT_LOGOUT_REDIRECT_URL = '/'
|
||||||
@@ -225,8 +228,6 @@ DEFAULT_WAVEFORM_GENERATING = '/assets/images/waveform-interstitial.gif'
|
|||||||
SITE_NAME = 'Deep South Sounds'
|
SITE_NAME = 'Deep South Sounds'
|
||||||
THUMBNAIL_PREFIX = '_tn/'
|
THUMBNAIL_PREFIX = '_tn/'
|
||||||
|
|
||||||
# THUMBNAIL_STORAGE = 'storages.backends.azure_storage.AzureStorage'
|
|
||||||
|
|
||||||
JWT_AUTH = {
|
JWT_AUTH = {
|
||||||
'JWT_EXPIRATION_DELTA': timedelta(seconds=(60 * 60 * 24) * 14),
|
'JWT_EXPIRATION_DELTA': timedelta(seconds=(60 * 60 * 24) * 14),
|
||||||
# 'JWT_EXPIRATION_DELTA': timedelta(seconds=5),
|
# 'JWT_EXPIRATION_DELTA': timedelta(seconds=5),
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ Django==2.1.2
|
|||||||
django-extensions
|
django-extensions
|
||||||
django-sendfile
|
django-sendfile
|
||||||
Werkzeug
|
Werkzeug
|
||||||
psycopg2
|
|
||||||
gunicorn
|
gunicorn
|
||||||
|
psycopg2-binary
|
||||||
|
|
||||||
dropbox
|
dropbox
|
||||||
django-dirtyfields
|
django-dirtyfields
|
||||||
django-storages
|
django-storages
|
||||||
@@ -23,9 +24,8 @@ django-celery
|
|||||||
django-scheduler
|
django-scheduler
|
||||||
django-recurrence
|
django-recurrence
|
||||||
django-compressor
|
django-compressor
|
||||||
|
|
||||||
azure
|
azure
|
||||||
azure-storage==0.20.0
|
|
||||||
|
|
||||||
sorl-thumbnail
|
sorl-thumbnail
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ from django.conf.urls import url
|
|||||||
from spa.podcast.views import favourites, following, user, featured
|
from spa.podcast.views import favourites, following, user, featured
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^(?P<uid>[\w\d_.-]+)/favourites/?$', favourites, name='podast_favourites_slug'),
|
url(r'^(?P<uid>[\w\d_.-]+)/favourites/?$', favourites, name='podcast_favourites_slug'),
|
||||||
url(r'^(?P<uid>[\w\d_.-]+)/following/?$', following, name='podast_following_slug'),
|
url(r'^(?P<uid>[\w\d_.-]+)/following/?$', following, name='podcast_following_slug'),
|
||||||
url(r'^(?P<slug>[\w\d_.-]+)/?$', user, name='podast_user_slug'),
|
url(r'^(?P<slug>[\w\d_.-]+)/?$', user, name='podast_user_slug'),
|
||||||
url(r'^/?$', featured, name='podast_featured_slug'),
|
url(r'', featured, name='`podcast_featured_slug'),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user