From e7f21fa2533d33d6ec6c5fcef2265e988a011752 Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Fri, 23 Feb 2024 14:51:04 +1100 Subject: [PATCH] Remove unused ccs-upload feature Use the Source uploads now go to a NextCloud anonymous upload. --- conservancy/ccs_upload/__init__.py | 0 conservancy/ccs_upload/forms.py | 5 ---- conservancy/ccs_upload/urls.py | 8 ------- conservancy/ccs_upload/views.py | 38 ------------------------------ conservancy/urls.py | 1 - 5 files changed, 52 deletions(-) delete mode 100644 conservancy/ccs_upload/__init__.py delete mode 100644 conservancy/ccs_upload/forms.py delete mode 100644 conservancy/ccs_upload/urls.py delete mode 100644 conservancy/ccs_upload/views.py diff --git a/conservancy/ccs_upload/__init__.py b/conservancy/ccs_upload/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/conservancy/ccs_upload/forms.py b/conservancy/ccs_upload/forms.py deleted file mode 100644 index 3d54bda2..00000000 --- a/conservancy/ccs_upload/forms.py +++ /dev/null @@ -1,5 +0,0 @@ -from django import forms - - -class UploadForm(forms.Form): - file = forms.FileField() diff --git a/conservancy/ccs_upload/urls.py b/conservancy/ccs_upload/urls.py deleted file mode 100644 index dd79c6c9..00000000 --- a/conservancy/ccs_upload/urls.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.urls import path - -from . import views - -app_name = "ccs_upload" -urlpatterns = [ - path('', views.upload, name='form') -] diff --git a/conservancy/ccs_upload/views.py b/conservancy/ccs_upload/views.py deleted file mode 100644 index ba203c1d..00000000 --- a/conservancy/ccs_upload/views.py +++ /dev/null @@ -1,38 +0,0 @@ -import logging -import os -import random - -from django.contrib import messages -from django.shortcuts import redirect, render - -from .forms import UploadForm - -CCS_UPLOAD_PATH = '/tmp/' - -logger = logging.getLogger(__name__) - - -def upload(request): - if request.method == 'POST': - form = UploadForm(request.POST, request.FILES) - if form.is_valid(): - file = request.FILES['file'] - _handle_uploaded_file(file) - messages.add_message(request, messages.INFO, '"{}" was successfully uploaded.'.format(file.name)) - return redirect('ccs_upload:form') - else: - form = UploadForm() - return render(request, 'ccs_upload/upload.html', {'form': form}) - - -def _handle_uploaded_file(f): - filename = _hash_prefixed_filename(f.name) - path = os.path.join(CCS_UPLOAD_PATH, filename) - with open(path, 'wb+') as destination: - for chunk in f.chunks(): - destination.write(chunk) - logger.info('Wrote uploaded file to {}.'.format(path)) - - -def _hash_prefixed_filename(name): - return '{hash:x} {name}'.format(hash=random.getrandbits(32), name=name) diff --git a/conservancy/urls.py b/conservancy/urls.py index ebe4ceb9..0a325345 100644 --- a/conservancy/urls.py +++ b/conservancy/urls.py @@ -61,7 +61,6 @@ urlpatterns = [ url(r'^sustainer/', include('conservancy.supporter.urls')), url(r'^coming-soon.html', static_views.index), url(r'^fundraiser_data', fundgoal_views.view), - path('ccs-upload/', include('conservancy.ccs_upload.urls', namespace='ccs_upload')), path('assignment/', include('conservancy.assignment.urls')), url(r'^fossy/$', static_views.index), path('fossy/', include('conservancy.fossy.urls')),