From 4072a1524cc2cbc215d1996a2a3a7880bcda3fe9 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Sat, 7 Nov 2020 00:59:33 +0000 Subject: [PATCH] Remove request asking system; track downloads instead of reuqests. Use IP address lookup --- download/__pycache__/models.cpython-38.pyc | Bin 1553 -> 1944 bytes download/__pycache__/views.cpython-38.pyc | Bin 3237 -> 3475 bytes .../migrations/0010_downloadattempt.py | 14 +++---- .../0011_downloadattempt_geolocation.py | 19 +++++++++ .../0010_downloadattempt.cpython-38.pyc | Bin 0 -> 1065 bytes ...downloadattempt_geolocation.cpython-38.pyc | Bin 0 -> 675 bytes download/models.py | 8 ++++ download/views.py | 36 ++++++++++++----- request/__pycache__/__init__.cpython-38.pyc | Bin 169 -> 0 bytes request/__pycache__/admin.cpython-38.pyc | Bin 210 -> 0 bytes request/__pycache__/forms.cpython-38.pyc | Bin 506 -> 0 bytes request/__pycache__/models.cpython-38.pyc | Bin 688 -> 0 bytes request/__pycache__/urls.cpython-38.pyc | Bin 304 -> 0 bytes request/__pycache__/views.cpython-38.pyc | Bin 1321 -> 0 bytes request/apps.py | 5 --- request/forms.py | 5 --- .../__pycache__/0001_initial.cpython-38.pyc | Bin 990 -> 0 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 180 -> 0 bytes request/models.py | 9 ----- request/templates/request/request.html | 10 ----- request/urls.py | 6 --- request/views.py | 38 ------------------ {request => viewdownloads}/__init__.py | 0 .../__pycache__/__init__.cpython-38.pyc | Bin .../__pycache__/admin.cpython-38.pyc | Bin .../__pycache__/models.cpython-38.pyc | Bin viewdownloads/__pycache__/urls.cpython-38.pyc | Bin 0 -> 316 bytes .../__pycache__/views.cpython-38.pyc | Bin 0 -> 527 bytes {request => viewdownloads}/admin.py | 0 {viewrequests => viewdownloads}/apps.py | 0 .../migrations/__init__.py | 0 .../__pycache__/__init__.cpython-38.pyc | Bin {viewrequests => viewdownloads}/models.py | 0 .../templates/viewrequests/requests.html | 32 +++++++++++++++ {request => viewdownloads}/tests.py | 0 {viewrequests => viewdownloads}/urls.py | 1 - {viewrequests => viewdownloads}/views.py | 9 ++--- viewrequests/__init__.py | 0 viewrequests/__pycache__/urls.cpython-38.pyc | Bin 365 -> 0 bytes viewrequests/__pycache__/views.cpython-38.pyc | Bin 604 -> 0 bytes viewrequests/admin.py | 3 -- viewrequests/migrations/__init__.py | 0 .../templates/viewrequests/requests.html | 31 -------------- viewrequests/tests.py | 3 -- 44 files changed, 94 insertions(+), 135 deletions(-) rename request/migrations/0001_initial.py => download/migrations/0010_downloadattempt.py (58%) create mode 100644 download/migrations/0011_downloadattempt_geolocation.py create mode 100644 download/migrations/__pycache__/0010_downloadattempt.cpython-38.pyc create mode 100644 download/migrations/__pycache__/0011_downloadattempt_geolocation.cpython-38.pyc delete mode 100644 request/__pycache__/__init__.cpython-38.pyc delete mode 100644 request/__pycache__/admin.cpython-38.pyc delete mode 100644 request/__pycache__/forms.cpython-38.pyc delete mode 100644 request/__pycache__/models.cpython-38.pyc delete mode 100644 request/__pycache__/urls.cpython-38.pyc delete mode 100644 request/__pycache__/views.cpython-38.pyc delete mode 100644 request/apps.py delete mode 100644 request/forms.py delete mode 100644 request/migrations/__pycache__/0001_initial.cpython-38.pyc delete mode 100644 request/migrations/__pycache__/__init__.cpython-38.pyc delete mode 100644 request/models.py delete mode 100644 request/templates/request/request.html delete mode 100644 request/urls.py delete mode 100644 request/views.py rename {request => viewdownloads}/__init__.py (100%) rename {viewrequests => viewdownloads}/__pycache__/__init__.cpython-38.pyc (100%) rename {viewrequests => viewdownloads}/__pycache__/admin.cpython-38.pyc (100%) rename {viewrequests => viewdownloads}/__pycache__/models.cpython-38.pyc (100%) create mode 100644 viewdownloads/__pycache__/urls.cpython-38.pyc create mode 100644 viewdownloads/__pycache__/views.cpython-38.pyc rename {request => viewdownloads}/admin.py (100%) rename {viewrequests => viewdownloads}/apps.py (100%) rename {request => viewdownloads}/migrations/__init__.py (100%) rename {viewrequests => viewdownloads}/migrations/__pycache__/__init__.cpython-38.pyc (100%) rename {viewrequests => viewdownloads}/models.py (100%) create mode 100644 viewdownloads/templates/viewrequests/requests.html rename {request => viewdownloads}/tests.py (100%) rename {viewrequests => viewdownloads}/urls.py (66%) rename {viewrequests => viewdownloads}/views.py (52%) delete mode 100644 viewrequests/__init__.py delete mode 100644 viewrequests/__pycache__/urls.cpython-38.pyc delete mode 100644 viewrequests/__pycache__/views.cpython-38.pyc delete mode 100644 viewrequests/admin.py delete mode 100644 viewrequests/migrations/__init__.py delete mode 100644 viewrequests/templates/viewrequests/requests.html delete mode 100644 viewrequests/tests.py diff --git a/download/__pycache__/models.cpython-38.pyc b/download/__pycache__/models.cpython-38.pyc index 982061c372ca8b8084d37d3d3443df5d258f5280..d6aebfa1f633a7e671cf4b5ca7f4d6c97c340b16 100644 GIT binary patch delta 466 zcmYk2J4?hs5XZC0C6~+XA5|)rg6H%7>G;a%+2btjEe0doiYNn2=(n0*lG>>yRAJmQzl^>iInoq`-)Kc@5B8(t zSMkjeMPXuApD1BlR$kqV&stF&h>bLr&31aY1ylHuZw7xlfeDlz%Zoxbf=-kIH3KEY zp65b;m(&1Zkf0K1Bv>N+8;0aEVFBS=NvB?yNz&*w gK%#z{+>?day%@D8C$X#Xfvn~MO7SoYaS3q%0O4gCBLDyZ diff --git a/download/__pycache__/views.cpython-38.pyc b/download/__pycache__/views.cpython-38.pyc index 3cbfebd7459863392f9ecdff07b00d0a0a0c29ab..1183e72554583bce6f91e802361fd6543c21e968 100644 GIT binary patch delta 1935 zcmZt{O>Y}TbY}M3pYcZ%yGhefFv10;Ng;&_wI$$GfYef&AX>M`ES^nbckPX4C;eQ@ z5(cRVRgmrt^cPyQxmPo`yByhMVbR>)Cj1x)YsTJr}PnH($>K z-*OA}LX3;`B2Vz-7o@(Ar+6ChB+u|H;3+=AbAU@c&kKOdyvX+f-p{R7Qk{H&wp7{9 zpQjJ2k+ICVaC|>f&ecvw)=I~2xvNfBM%kKot?PO=UzXD8Y=v*rpJ@Irb7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fRwi4`n^V{#khJkbb>U-XNUV#*FDvU9QPq0NdV4#aUV~kMQLN~Jum_Fe04fEVRGw-N z>NX4Yvq96NzzRy(*Tg269Pu^DGu=}vZGAA!K6rlAA$djqm8o3QbJx{apHMx9p{3L1 zw@)maqjqaFQ-fO6p)=4c F{{mO4R$2f6 diff --git a/request/migrations/0001_initial.py b/download/migrations/0010_downloadattempt.py similarity index 58% rename from request/migrations/0001_initial.py rename to download/migrations/0010_downloadattempt.py index 9cf5783..92bbb03 100644 --- a/request/migrations/0001_initial.py +++ b/download/migrations/0010_downloadattempt.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.2 on 2020-11-06 18:06 +# Generated by Django 3.1.2 on 2020-11-06 22:28 from django.db import migrations, models import django.db.models.deletion @@ -6,21 +6,21 @@ import django.db.models.deletion class Migration(migrations.Migration): - initial = True - dependencies = [ - ('download', '0009_auto_20201106_1718'), ('core', '0002_quoteuser'), + ('download', '0009_auto_20201106_1718'), ] operations = [ migrations.CreateModel( - name='QuoteRequest', + name='DownloadAttempt', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('timestamp', models.DateTimeField(auto_now_add=True)), - ('address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quote_requests', to='download.address')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quote_requests', to='core.quoteuser')), + ('successful', models.BooleanField(default=False)), + ('ip', models.GenericIPAddressField()), + ('pdf', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attempts', to='download.pdf')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attempts', to='core.quoteuser')), ], ), ] diff --git a/download/migrations/0011_downloadattempt_geolocation.py b/download/migrations/0011_downloadattempt_geolocation.py new file mode 100644 index 0000000..6ace948 --- /dev/null +++ b/download/migrations/0011_downloadattempt_geolocation.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.2 on 2020-11-07 00:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('download', '0010_downloadattempt'), + ] + + operations = [ + migrations.AddField( + model_name='downloadattempt', + name='geolocation', + field=models.CharField(default='', max_length=64), + preserve_default=False, + ), + ] diff --git a/download/migrations/__pycache__/0010_downloadattempt.cpython-38.pyc b/download/migrations/__pycache__/0010_downloadattempt.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2aacadeb7cdb0851106c72f9a04a1bbe15c826d9 GIT binary patch literal 1065 zcmZWoO>fgc5VhBilQxAB<52*ooGu{GvTtheBS_b;dUJHa)h!t#4lt_orCdv1Gl}(}QtgUg_7J le`K$`alMt&?4FXOvRsKPzq-W9+S9U4&y?*#EnC-X#$UtUL5lzY literal 0 HcmV?d00001 diff --git a/download/migrations/__pycache__/0011_downloadattempt_geolocation.cpython-38.pyc b/download/migrations/__pycache__/0011_downloadattempt_geolocation.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..99b12f7e37ce23ec99eb0895510a1986bbf1250a GIT binary patch literal 675 zcmZ8fy>8S%5Z?9Aoox~kAw=FF(iNAz^aurkLPZ)x<7Tzz8T)*)z0R(W15rYo$DrUH zc#>_YQqd!%Fze)$Q^uOnex9A5@3TK19%hW}>z^O;7ia9Z2m2NgI48F!6o3J5Sj%(X z26@2QI|c!S-x-9+*WtG?4pDz|?3%P@8 z7_jY!{OO|??n#BZ(Z#rf;gYBL2a)utJUfch*O?5bgPF^dR#4zg1%x@e4XSz`n4 zs5fZQd_s9&c{xj6BFCFjx=c!{+%!n%11YaIs`1qx0ruDdc14ZW1T@|yuK_N6R}*@e zzF8?VVwdS2@8$f-%nQnn;ja-Z-J%$jDaBh|Y+CFFD+=0GSZvDq*3`tm6I)!)m&ziD ztBoFT-a{#Nf{2GtB}lrn$I{6?p-%fR#{U-+a{G)z5(c+X9Pxmj10MW~ZpZv3NtVJ| hb(KDa<;ZU2G$tSRzdIdMAD6tm)9IC`ZoM2w;eVMrzdQf{ literal 0 HcmV?d00001 diff --git a/download/models.py b/download/models.py index 421d598..b1625c3 100644 --- a/download/models.py +++ b/download/models.py @@ -26,3 +26,11 @@ class EmailSent(models.Model): user = models.ForeignKey(QuoteUser, on_delete=models.CASCADE) pdf = models.ForeignKey(PDF, on_delete=models.CASCADE) ref_code = models.CharField(max_length=256) + +class DownloadAttempt(models.Model): + timestamp = models.DateTimeField(auto_now_add=True, editable=False, null=False, blank=False) + user = models.ForeignKey(QuoteUser, on_delete=models.CASCADE, related_name='attempts') + successful = models.BooleanField(default=False) + pdf = models.ForeignKey(PDF, on_delete=models.CASCADE, related_name='attempts') + ip = models.GenericIPAddressField() + geolocation = models.CharField(max_length=64) \ No newline at end of file diff --git a/download/views.py b/download/views.py index e8ceb9a..f5d5093 100644 --- a/download/views.py +++ b/download/views.py @@ -1,7 +1,7 @@ from django.shortcuts import render, HttpResponse from django.http import FileResponse from django.core.mail import EmailMultiAlternatives -from .models import Address, PDF, EmailSent +from .models import Address, PDF, EmailSent, DownloadAttempt from .forms import CodeForm from core.models import QuoteUser from django.template.loader import render_to_string @@ -19,16 +19,10 @@ def search(request, addr): if len(addr) <= 3: return HttpResponse(json.dumps([])) return HttpResponse(json.dumps( - [x.toDict() for x in Address.objects.filter(address__startswith=addr)] + [x.toDict() for x in Address.objects.filter(address__contains=addr)[:10]] )) def send_email(to, addr, pdf, dt_date): - # save email in user database; do nothing if exception - user, created = QuoteUser.objects.get_or_create(username=to, email=to) - # disallow login for new user - if created: - user.set_unusable_password() - user.save() # send email email = EmailMultiAlternatives() email.subject = 'Your free quote!' @@ -44,9 +38,9 @@ def send_email(to, addr, pdf, dt_date): email.attach(str(pdf.upload_file), content, 'application/octate-stream') email.send() -def save_email(to, addr, pdf, dt): +def save_email(user, addr, pdf, dt): EmailSent.objects.create( - user=QuoteUser.objects.get(email=to), + user=user, pdf=pdf, ref_code=hashlib.sha256(dt.strftime("%Y%m%d%H%M%S").encode()).hexdigest() ) @@ -64,6 +58,23 @@ def download(request, pdfid): if len(pdf) == 0: return render(request, 'common/password-incorrect.html') pdf = pdf[0] + # create user + user, created = QuoteUser.objects.get_or_create(username=form.cleaned_data['email'], email=form.cleaned_data['email']) + # disallow login for new user + if created: + user.set_unusable_password() + user.save() + # create download attempt + dla = DownloadAttempt.objects.create( + user=user, + pdf=pdf, + ip=request.META.get('REMOTE_ADDR'), + geolocation="{0}, {1}, {2}".format( + request.ipinfo.city, + request.ipinfo.region, + request.ipinfo.country + ) + ) # create timestamps dt_date = datetime.datetime.now() try: @@ -74,7 +85,10 @@ def download(request, pdfid): 'code': form.cleaned_data['code'] }) # only saves email if it sent - save_email(form.cleaned_data['email'], addr, pdf, dt_date) + save_email(user, addr, pdf, dt_date) + # only makes successful if email is sent + dla.successful = True + dla.save() return render(request, 'download/email-confirm.html') else: form = CodeForm() diff --git a/request/__pycache__/__init__.cpython-38.pyc b/request/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index e1e6230beaeef3d8445a4dafda36f297533f878b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 169 zcmWIL<>g`k0@lu@@gVv!h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6vHKO;XkRlg*$ zC{5obKe;qFHLs*tKRG`oRlhhjCr!7!D6^y_HBY}hHAy!qu{bqFzpymFBvrQ{B~8C5 mwXig`xI{lbJ~J<~BtBlRpz;=nO>TZlX-=vg$ezzY%m4rl1}bv^ diff --git a/request/__pycache__/admin.cpython-38.pyc b/request/__pycache__/admin.cpython-38.pyc deleted file mode 100644 index 6dff48c03c7692b024d3712b8a013022250a011a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 210 zcmYjKF$%&!5WI^7L{R)jiex_^YGEhXh>eXT*^NeWcgfv_;1hg^g$Kv@YT_fiTBwjvt5xD}Cngej_0Z=zs7!E>sQ zCdrNVw#;lla2IyK_LI*VPDT;<)E2NZd8Ik7}jiJ5ViM{EFnk;E`aDF5qtrJf`CvUrQp+SV>y`#N#xy4>|FshR7hNbj)L1z zyQRt%s2J}e!ALXqv!CC5e7m*PVPtPF@A8w@FAx4(L|{N}_bC7au35%Y&e;Wn0K#Vm zA@W7=6s93W*Q^(>iN|`}#nZxMcH+^0iwO+K?EwX3DF>DY7%n2OpGE@5-4=4AJKX!L?5S3|hM$ z5PL*QiIlm@P)gU4GAp3ce&3aHRVm%vn1HyhQ)d~@QG<)oXLK8RJ>yuG0axGY>{H|!qjQmLItG_~;-7dXz$x+keG51owv2O4K2U&v8 diff --git a/request/__pycache__/models.cpython-38.pyc b/request/__pycache__/models.cpython-38.pyc deleted file mode 100644 index d6113f45b93b23e6ddf8f07d4a40ff16249af81b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 688 zcmYjP!H&}~5Vf16NxLaXNbnCiw7DaMwrsZ?fR$i(FS%H5XS%dFNozZ*_6*lO@DUvN z55B@zPW%EV#tw+i$fGwSk7wSDZzq#6BN>1FCVp_netPFrVsg&unCE1G0avW%73Urg z)S!;4DBwuNby6jqy=D+Y@`XWyd^h|YRVfUwS&{ytd{%HbtXn{32#wx%t;Jh|nw)eF zpwXDMzji7^a?a_PS7eY?99T8LXcq&ALD1+St`dq2F(sS%@()op3X$Cz#)F%a3i1rImV9F4}chV`ELZ zroop6)n|goHY6a DvjVu5 diff --git a/request/__pycache__/urls.cpython-38.pyc b/request/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index dda39cbca7d58fa8bf34d34696e4cb89c2168538..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 304 zcmYjLF;2uV5VYeYcOrNEBSqp5AVfh$L4#=0pxo`|E~nVe*$#mxQ1A>2dS2s}>b^h& zYeB(EJFC&`?9Tmqea5IhUfv!Q&Cf{wS4QND+SLTWfDcUZhI0l9h#^s;5u7216vZKh z4Dwg8<4p#OJ60}FDc=HiT{%9vB%j378Vwd6FMIkbgS^T%tHZ(R_{zb*}>U_ z3^oR^DM8434fqra(&(N?tKB=ZMbsmF-N?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wc3=b3Il2LW?=uS5uRrP;t%BYN4pEd1&-k>L} diff --git a/request/migrations/__pycache__/__init__.cpython-38.pyc b/request/migrations/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 579cab6c673d92d265f9983300b61ead9168d484..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 180 zcmWIL<>g`k0@lu@@gVv!h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10UKO;XkRlg*$ zC{5obKe;qFHLs*tKRG`oRlhhjCr!7!D6^y_HBY}hHAy!qu{bqFzpymFBvrQ{B~8C5 xwXig`xI{lUGrcIWBr`v+SU)~KGcU6wK3=b&@)n0pZhlH>PO2Tq%FjT|001DYF6saP diff --git a/request/models.py b/request/models.py deleted file mode 100644 index 644cbd6..0000000 --- a/request/models.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.db import models -from core.models import QuoteUser -from download.models import Address - -# Create your models here. -class QuoteRequest(models.Model): - timestamp = models.DateTimeField(auto_now_add=True, editable=False, null=False, blank=False) - address = models.ForeignKey(Address, on_delete=models.CASCADE, related_name='quote_requests') - user = models.ForeignKey(QuoteUser, on_delete=models.CASCADE, related_name='quote_requests') \ No newline at end of file diff --git a/request/templates/request/request.html b/request/templates/request/request.html deleted file mode 100644 index d055353..0000000 --- a/request/templates/request/request.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends 'common/master.html' %} -{% block body %} -

Request A Quote

-
- {% csrf_token %} - {{ form.as_p }} - -
-

{{ message }}

-{% endblock %} \ No newline at end of file diff --git a/request/urls.py b/request/urls.py deleted file mode 100644 index 05dff9b..0000000 --- a/request/urls.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.urls import path -from . import views - -urlpatterns = [ - path('', views.index, name='request') -] \ No newline at end of file diff --git a/request/views.py b/request/views.py deleted file mode 100644 index 82f6dde..0000000 --- a/request/views.py +++ /dev/null @@ -1,38 +0,0 @@ -from django.shortcuts import render, HttpResponse -from .forms import RequestForm - -from django.conf import settings -from django.core.mail import EmailMultiAlternatives - -from core.models import QuoteUser -from download.models import Address -from .models import QuoteRequest - -# Create your views here. -def index(request): - if request.method == 'POST': - form = RequestForm(request.POST) - if form.is_valid(): - to_addr = form.cleaned_data['email'] - address = form.cleaned_data['address'] - email = EmailMultiAlternatives() - email.to = [to_addr] - email.bcc = [settings.REQUEST_BBC] - email.body = 'Somebody has requested a quote' - try: - email.send() - except: - return HttpResponse('Error', code=500) - # if all went all, add user, address, and request to database - # TODO: add messages - user, user_created = QuoteUser.objects.get_or_create(username=to_addr, email=to_addr) - addr, addr_created = Address.objects.get_or_create(address=address) - qr, qr_created = QuoteRequest.objects.get_or_create(user=user, address=addr) - return render(request, 'request/request.html', { - 'form': RequestForm(), - 'message': 'Thank you for requesting a quote. We will get back to you soon.' - }) - else: - return render(request, 'request/request.html', { - 'form': RequestForm() - }) \ No newline at end of file diff --git a/request/__init__.py b/viewdownloads/__init__.py similarity index 100% rename from request/__init__.py rename to viewdownloads/__init__.py diff --git a/viewrequests/__pycache__/__init__.cpython-38.pyc b/viewdownloads/__pycache__/__init__.cpython-38.pyc similarity index 100% rename from viewrequests/__pycache__/__init__.cpython-38.pyc rename to viewdownloads/__pycache__/__init__.cpython-38.pyc diff --git a/viewrequests/__pycache__/admin.cpython-38.pyc b/viewdownloads/__pycache__/admin.cpython-38.pyc similarity index 100% rename from viewrequests/__pycache__/admin.cpython-38.pyc rename to viewdownloads/__pycache__/admin.cpython-38.pyc diff --git a/viewrequests/__pycache__/models.cpython-38.pyc b/viewdownloads/__pycache__/models.cpython-38.pyc similarity index 100% rename from viewrequests/__pycache__/models.cpython-38.pyc rename to viewdownloads/__pycache__/models.cpython-38.pyc diff --git a/viewdownloads/__pycache__/urls.cpython-38.pyc b/viewdownloads/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bb2075c202f4b1577c9e143091d9e0f91e27d8aa GIT binary patch literal 316 zcmYjMy-ve05VqqaRJ7qeG9-Qhgcz6+5@N|xxxGu9%0H>?5O@e4gMnA_iWs^vvw#f? zC*61Y?(VyvhpIX!(LO$3*FMJgME+Y5$#rzsMgRg-5=A>o31q-zrdY=)K?*stLkX9E9GPcCymh zEXr&;!{!k}F=)W2u#B}h)uYw!jo9?WFMQqcy-~=$usy#q+exAJj&BVhcPRU2wnJ2D vKI5j@2#3IrlkwP$(DQT$m|06B!11)b9iPMEQW=;eUZn?I8DT|N?Be?eNnuuA literal 0 HcmV?d00001 diff --git a/viewdownloads/__pycache__/views.cpython-38.pyc b/viewdownloads/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6d0de35679680236fbd1bb0091a2d65c2c4deada GIT binary patch literal 527 zcmYjNu};G<5Vf78t)NvqA;HW*hBhM$LLfRYRRYA41tsy7ri$a#b||gbfd6O*27bvB z6B8RV3tUQzIO$IJ zeI4@*Q}1IjZ#YyGvoJU{ZoMI@mP5krA0~ zY~XyWYf^!XNE9C&r~96&wp1<_TbJ<|5~HmXW%x-dbbk}i&~kk};FYLtWPV))BPk#- zks1blnUn%@6ip{lKr;4j)JPt?cQMR3<5n{x$C4bJ*U@>j|`w>D4-`pDVlnN)zd} SafGxogX8Mhx>~(Mo6Zksk%}k) literal 0 HcmV?d00001 diff --git a/request/admin.py b/viewdownloads/admin.py similarity index 100% rename from request/admin.py rename to viewdownloads/admin.py diff --git a/viewrequests/apps.py b/viewdownloads/apps.py similarity index 100% rename from viewrequests/apps.py rename to viewdownloads/apps.py diff --git a/request/migrations/__init__.py b/viewdownloads/migrations/__init__.py similarity index 100% rename from request/migrations/__init__.py rename to viewdownloads/migrations/__init__.py diff --git a/viewrequests/migrations/__pycache__/__init__.cpython-38.pyc b/viewdownloads/migrations/__pycache__/__init__.cpython-38.pyc similarity index 100% rename from viewrequests/migrations/__pycache__/__init__.cpython-38.pyc rename to viewdownloads/migrations/__pycache__/__init__.cpython-38.pyc diff --git a/viewrequests/models.py b/viewdownloads/models.py similarity index 100% rename from viewrequests/models.py rename to viewdownloads/models.py diff --git a/viewdownloads/templates/viewrequests/requests.html b/viewdownloads/templates/viewrequests/requests.html new file mode 100644 index 0000000..8757a6d --- /dev/null +++ b/viewdownloads/templates/viewrequests/requests.html @@ -0,0 +1,32 @@ +{% extends 'common/master.html' %} +{% block body %} + +

View Download Attempts

+ + + + + + + + + {% for req in requests %} + + + + + + + + {% endfor %} +
EmailAddressIPGeolocationTimestamp
{{ req.user.email }}{{ req.pdf.address.address }}{{ req.ip }}{{ req.geolocation }}{{ req.timestamp }}
+{% endblock %} \ No newline at end of file diff --git a/request/tests.py b/viewdownloads/tests.py similarity index 100% rename from request/tests.py rename to viewdownloads/tests.py diff --git a/viewrequests/urls.py b/viewdownloads/urls.py similarity index 66% rename from viewrequests/urls.py rename to viewdownloads/urls.py index 6f3d181..bd6956d 100644 --- a/viewrequests/urls.py +++ b/viewdownloads/urls.py @@ -3,5 +3,4 @@ from . import views urlpatterns = [ path('', views.index, name='requests_view'), - path('delete/', views.delete, name='requests_delete') ] \ No newline at end of file diff --git a/viewrequests/views.py b/viewdownloads/views.py similarity index 52% rename from viewrequests/views.py rename to viewdownloads/views.py index d05357b..51dfb09 100644 --- a/viewrequests/views.py +++ b/viewdownloads/views.py @@ -1,12 +1,9 @@ from django.shortcuts import render, HttpResponse -from request.models import QuoteRequest +from download.models import DownloadAttempt # Create your views here. def index(request): + # TODO: Allow search return render(request, 'viewrequests/requests.html', { - 'requests': QuoteRequest.objects.all() + 'requests': DownloadAttempt.objects.all().order_by('-timestamp')[:100] }) - -def delete(request): - print(request.POST) - pass \ No newline at end of file diff --git a/viewrequests/__init__.py b/viewrequests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/viewrequests/__pycache__/urls.cpython-38.pyc b/viewrequests/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 1cc866d22e7c41b388e952dc7388b1c2c7c781b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 365 zcmYk1O-{ow5QXjh(=_EAS){%|g;=nL1wumERB30@rpjM!hX8lr0_<6^;XvN9>J?ZZ z#)?3Uz0G8m2_yJ^sRU##;;nyM-xnL6O)JD)hJu_&SY$TR=#e; zzH3nELYCsH+YSx3T8V83C=}LZHp+@_wPM6gwkZ^XI1Zi0tcOzAq`$F*4YBN>Otfk` T7;3z*KU5LPoX_0_Uwr=naXn?o diff --git a/viewrequests/__pycache__/views.cpython-38.pyc b/viewrequests/__pycache__/views.cpython-38.pyc deleted file mode 100644 index 8d9a63952f888629569139813c0efe83c7f27e3b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 604 zcmZWmy>1&Z3>NRthtx?kb;ujsU@H$$1OeKilk3{;a!X*J==u!ZPefha2Hn!P=+X`y z@*sT)t)21;SrY1;1PMxj6hDX}`F;AdzrQEg{{H-Pb__!N^Wdok3{KhUn1d1uw5TA5 zD#!!yIM87gOw?d5vh|YTarbiP!j6ZXlqJq zv6fq0j+P5TCC@#NQL9$+*)kr`xc%nhlKFp)xjCgA1SAlM^wtbH|Bts{wC8=miRZn6 zOYm|tUzo6*acj!jx@h`-{?Yh;{o1?mf}u+kYP9IdkY_Al56nwGC)vOqs?DPQ+>B}6 x7+Z9fcFKf&ogdsQF|L@bre3ao$^P||F}}6wXQi*Xw$pgxzl{8!9l|h7<2zN+jb8u& diff --git a/viewrequests/admin.py b/viewrequests/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/viewrequests/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/viewrequests/migrations/__init__.py b/viewrequests/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/viewrequests/templates/viewrequests/requests.html b/viewrequests/templates/viewrequests/requests.html deleted file mode 100644 index c849567..0000000 --- a/viewrequests/templates/viewrequests/requests.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends 'common/master.html' %} -{% block body %} - -
- {% csrf_token %} - - - - - - - {% for req in requests %} - - - - - - {% endfor %} -
UserAddressDelete
{{ req.user.email }}{{ req.address.address }}
- -
-{% endblock %} \ No newline at end of file diff --git a/viewrequests/tests.py b/viewrequests/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/viewrequests/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here.