diff --git a/README.md b/README.md index 3dcba26..e95351e 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,27 @@ Requirements * Developed to Django 1.7.1 +Please add it in local_settings.py (you have to create it, in the same folder of settings): +``` +# -*- coding: utf-8 -*- + + +EMAIL_HOST = '' +EMAIL_HOST_PASSWORD = '' +EMAIL_HOST_USER = 'youremail' +EMAIL_PORT = 25 +EMAIL_USE_TLS = True + +DEFAULT_FROM_EMAIL = "yourmeial@email.com" + + +ADMINS = (('Luís Bastião', 'yourock@email.com'), ) +BASE_URL = "http://localhost:8000/" + + +PROJECT_NAME = "Your project name" + +DOWNLOAD_FOLDER = "/dir/with/your/private/files" + +``` diff --git a/django_download_manager/download_manager/views.py b/django_download_manager/download_manager/views.py index c498014..7c2d0be 100644 --- a/django_download_manager/download_manager/views.py +++ b/django_download_manager/download_manager/views.py @@ -66,6 +66,9 @@ def get(self, request, hash_id=None,*args, **kwargs): print hash_id dr = DownloadRequest.objects.get(hashLink=hash_id) + if (not dr.pending): + html = "This request has been already handled. Approved = %s " % str(dr.approved) + return HttpResponse(html) dr.pending = False dr.approved = True dr.save() @@ -76,6 +79,7 @@ def get(self, request, hash_id=None,*args, **kwargs): html_content += 'Please download: %s
' % (settings.BASE_URL + "dw/link/" + hash_id) html_content += "

See you next download! " + html_content += "
Dicoogle Team. " msg = EmailMultiAlternatives(subject, "", from_email, [to]) @@ -93,8 +97,27 @@ def get(self, request, hash_id=None,*args, **kwargs): print "reject" print hash_id dr = DownloadRequest.objects.get(hashLink=hash_id) + if (not dr.pending): + html = "This request has been already handled. Approved = %s " % str(dr.approved) + return HttpResponse(html) + dr.pending = False dr.save() + + # This could be refactor (next time I hack ) + subject, from_email, to = settings.PROJECT_NAME + ' - Download Manager', settings.DEFAULT_FROM_EMAIL, dr.communityUser.email + + html_content = '

Dear %s,

' % dr.communityUser.name + html_content += 'Your download request has been rejected.
' + + html_content += "

Best Regards, " + html_content += "
Dicoogle Team. " + + + msg = EmailMultiAlternatives(subject, "", from_email, [to]) + msg.attach_alternative(html_content, "text/html") + msg.send() + return super(RejectView, self).get(request, *args, **kwargs) class HomePageView(SingleObjectMixin, TemplateView):