diff --git a/download/forms.py b/download/forms.py index 9cc2b69..238dd9d 100644 --- a/download/forms.py +++ b/download/forms.py @@ -1,11 +1,15 @@ from django import forms class CodeForm(forms.Form): - code = forms.CharField(label='Code', max_length=8, required=True, + address = forms.CharField(label='Address', max_length=120, required=True, widget=forms.TextInput( - attrs={'placeholder': '123A56'} - )) + attrs={'placeholder': '123 Main St.'} + )) email = forms.EmailField(label='Email', max_length=32, required=True, widget=forms.TextInput( attrs={'placeholder': 'jane@joe.com'} - )) \ No newline at end of file + )) + code = forms.CharField(label='Code', max_length=8, required=True, + widget=forms.TextInput( + attrs={'placeholder': '123A56'} + )) diff --git a/download/templates/download/code-form.html b/download/templates/download/code-form.html index f80aab6..cc19e8d 100644 --- a/download/templates/download/code-form.html +++ b/download/templates/download/code-form.html @@ -1,9 +1,37 @@ {% extends 'common/master.html' %} {% block body %}

Type In Your Code

-
+ {% csrf_token %} {{ form.as_p }}
+
+ + {% endblock %} diff --git a/download/urls.py b/download/urls.py index c4ffb86..d146dca 100644 --- a/download/urls.py +++ b/download/urls.py @@ -2,8 +2,8 @@ from django.urls import path from . import views urlpatterns = [ - path('', views.starter, name='download'), - path('d//', views.download, name='download_f'), + path('', views.download, name='download'), + #path('d//', views.download, name='download_f'), path('dp//', views.download_preload, name='download_f_plus'), path('search//', views.search, name='search'), ] diff --git a/download/views.py b/download/views.py index 6d0695d..505092f 100644 --- a/download/views.py +++ b/download/views.py @@ -78,12 +78,12 @@ def save_email(user, addr, pdf, dt): ref_code=hashlib.sha256(dt.strftime("%Y%m%d%H%M%S").encode()).hexdigest() ) -def download(request, addrid): +def download(request): if request.method == 'POST': form = CodeForm(request.POST) if form.is_valid(): # get addr by id - addr = Address.objects.filter(id=addrid) + addr = Address.objects.filter(address=form.cleaned_data['address']) if len(addr) == 0: return render(request, 'common/not-found.html') # only get first addr @@ -119,7 +119,7 @@ def download(request, addrid): except Exception as e: print(e) return render(request, 'download/email-not-sent.html', { - 'id': addrid, + 'id': addr.id, 'code': form.cleaned_data['code'] }) # only saves email if it sent @@ -131,8 +131,7 @@ def download(request, addrid): else: form = CodeForm() return render(request, 'download/code-form.html', { - 'form': form, - 'id': addrid + 'form': form }) def download_preload(request, addid):