Skip to content

Commit

Permalink
Added few verifications
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiao committed Dec 2, 2014
1 parent 2e68dad commit cb01513
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
ADMINS = (('Luís Bastião', '[email protected]'), )
BASE_URL = "http://localhost:8000/"
PROJECT_NAME = "Your project name"
DOWNLOAD_FOLDER = "/dir/with/your/private/files"
```
23 changes: 23 additions & 0 deletions django_download_manager/download_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<html><body>This request has been already handled. Approved = %s </body></html>" % str(dr.approved)
return HttpResponse(html)
dr.pending = False
dr.approved = True
dr.save()
Expand All @@ -76,6 +79,7 @@ def get(self, request, hash_id=None,*args, **kwargs):
html_content += 'Please download: %s <br />' % (settings.BASE_URL + "dw/link/" + hash_id)

html_content += "<br /><br />See you next download! "
html_content += "<br />Dicoogle Team. "


msg = EmailMultiAlternatives(subject, "", from_email, [to])
Expand All @@ -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 = "<html><body>This request has been already handled. Approved = %s </body></html>" % 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 = '<p>Dear %s,</p>' % dr.communityUser.name
html_content += 'Your download request has been rejected. <br />'

html_content += "<br /><br />Best Regards, "
html_content += "<br />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):
Expand Down

0 comments on commit cb01513

Please sign in to comment.