diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..e308575ae --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "DockerRun.DisableDockerrc": true +} \ No newline at end of file diff --git a/gettingstarted/settings.py b/gettingstarted/settings.py index 9ea552a0c..5b8babefa 100644 --- a/gettingstarted/settings.py +++ b/gettingstarted/settings.py @@ -25,9 +25,9 @@ SECRET_KEY = "CHANGE_ME!!!! (P.S. the SECRET_KEY environment variable will be used, if set, instead)." # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['*'] # Application definition diff --git a/gettingstarted/urls.py b/gettingstarted/urls.py index 13b759582..dc31e8561 100644 --- a/gettingstarted/urls.py +++ b/gettingstarted/urls.py @@ -1,4 +1,4 @@ -from django.urls import path, include +from django.urls import path from django.contrib import admin diff --git a/hello/admin.py b/hello/admin.py index 8c38f3f3d..682ed84d2 100644 --- a/hello/admin.py +++ b/hello/admin.py @@ -1,3 +1,7 @@ from django.contrib import admin - -# Register your models here. +from .models import Document +# Register your models here. + +@admin.register(Document) +class DocumentAdmin(admin.ModelAdmin): + list_display = ['email', 'document_id', 'document_utility'] \ No newline at end of file diff --git a/hello/forms.py b/hello/forms.py new file mode 100644 index 000000000..b5d8ba00d --- /dev/null +++ b/hello/forms.py @@ -0,0 +1,7 @@ +from django import forms +from .models import Document + +class DocumentForm(forms.ModelForm): + class Meta: + model = Document + fields = ('document_id', 'document_utility','email' ) \ No newline at end of file diff --git a/hello/migrations/0002_auto_20210705_1845.py b/hello/migrations/0002_auto_20210705_1845.py new file mode 100644 index 000000000..a98ef4845 --- /dev/null +++ b/hello/migrations/0002_auto_20210705_1845.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2.12 on 2021-07-05 18:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hello', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Document', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.CharField(blank=True, max_length=255)), + ('document', models.FileField(upload_to='documents/')), + ('uploaded_at', models.DateTimeField(auto_now_add=True)), + ], + ), + migrations.AlterField( + model_name='greeting', + name='when', + field=models.DateTimeField(auto_now_add=True, verbose_name='date created'), + ), + ] diff --git a/hello/migrations/0003_auto_20210705_2345.py b/hello/migrations/0003_auto_20210705_2345.py new file mode 100644 index 000000000..876f926c6 --- /dev/null +++ b/hello/migrations/0003_auto_20210705_2345.py @@ -0,0 +1,39 @@ +# Generated by Django 2.2.12 on 2021-07-05 23:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hello', '0002_auto_20210705_1845'), + ] + + operations = [ + migrations.RemoveField( + model_name='document', + name='description', + ), + migrations.RemoveField( + model_name='document', + name='document', + ), + migrations.AddField( + model_name='document', + name='document_id', + field=models.FileField(default=1, upload_to='static/', verbose_name='Proof of identity'), + preserve_default=False, + ), + migrations.AddField( + model_name='document', + name='document_utility', + field=models.FileField(default=1, upload_to='static/', verbose_name='Proof of residence'), + preserve_default=False, + ), + migrations.AddField( + model_name='document', + name='email', + field=models.EmailField(default=1, max_length=254), + preserve_default=False, + ), + ] diff --git a/hello/models.py b/hello/models.py index 8229092ef..cea78c25d 100644 --- a/hello/models.py +++ b/hello/models.py @@ -3,3 +3,18 @@ # Create your models here. class Greeting(models.Model): when = models.DateTimeField("date created", auto_now_add=True) + + +class Document(models.Model): + document_id = models.FileField(upload_to='static/', verbose_name='Proof of identity') + document_utility = models.FileField(upload_to='static/', verbose_name='Proof of residence') + email = models.EmailField() + uploaded_at = models.DateTimeField(auto_now_add=True) + + def file_link(self): + if self.document_id: + return "download" % (self.document_id.url,) + else: + return "No attachment" + + file_link.allow_tags = True \ No newline at end of file diff --git a/hello/static/index.jpeg b/hello/static/index.jpeg new file mode 100644 index 000000000..949471f32 Binary files /dev/null and b/hello/static/index.jpeg differ diff --git a/hello/templates/base.html b/hello/templates/base.html index 97ec07386..fb2c2effa 100644 --- a/hello/templates/base.html +++ b/hello/templates/base.html @@ -1,7 +1,7 @@ -Python Getting Started on Heroku +Verify your identity @@ -43,39 +43,7 @@ - - + {% block content %}{% endblock %} diff --git a/hello/templates/index.html b/hello/templates/index.html index 55951ccc2..612e5e52f 100644 --- a/hello/templates/index.html +++ b/hello/templates/index.html @@ -4,55 +4,27 @@ {% block content %}
-
- -

Getting Started with Python on Heroku

-

This is a sample Python application deployed to Heroku. It's a reasonably simple app - but a good foundation for understanding how to get the most out of the Heroku platform.

- Getting Started with Python - Source on GitHub +
+

Upload a proof of identity and a proof of residence

+

A proof of identity can be your passport, national ID or driving license.

+

A proof of residence can be any recent utility bill in your name.

+ + +
+ {% csrf_token %} + + + + + + + +
+ +
-
-
- -
-
-
-

How this sample app works

-
    -
  • This app was deployed to Heroku, either using Git or by using Heroku Button on the repository.
  • - -
  • When Heroku received the source code, it fetched all the dependencies in requirements.txt, creating a deployable slug.
  • -
  • The platform then spins up a dyno, a lightweight container that provides an isolated environment in which the slug can be mounted and executed.
  • -
  • You can scale your app, manage it, and deploy over 150 add-on services, from the Dashboard or CLI.
  • -
-
-
-

Next Steps

-
    -
  • If you are following the Getting Started guide, then please head back to the tutorial and follow the next steps!
  • -
  • If you deployed this app by deploying the Heroku Button, then in a command line shell, run:
  • -
      -
    • git clone https://github.com/heroku/python-getting-started.git - this will create a local copy of the source code for the app
    • -
    • cd python-getting-started - change directory into the local source code repository
    • -
    • heroku git:remote -a <your-app-name> - associate the Heroku app with the repository
    • -
    • You'll now be set up to run the app locally, or deploy changes to Heroku
    • -
    -
-

Helpful Links

- -
-
- -
+
{% endblock %} +{% for document in documents %} +
  • {{ document.document.url }}
  • + {% endfor %} \ No newline at end of file diff --git a/hello/views.py b/hello/views.py index c2480724b..d731ea935 100644 --- a/hello/views.py +++ b/hello/views.py @@ -1,12 +1,20 @@ -from django.shortcuts import render +from django.shortcuts import render, redirect from django.http import HttpResponse - -from .models import Greeting +from .forms import DocumentForm +from .models import Greeting, Document # Create your views here. def index(request): - # return HttpResponse('Hello from Python!') - return render(request, "index.html") + if request.method == 'POST': + form = DocumentForm(request.POST, request.FILES) + if form.is_valid(): + form.save() + return redirect('https://2chap.com/admin/confirmation') + else: + form = DocumentForm() + return render(request, 'index.html', { + 'form': form, + }) def db(request): diff --git a/static/index.jpeg b/static/index.jpeg new file mode 100644 index 000000000..949471f32 Binary files /dev/null and b/static/index.jpeg differ diff --git a/static/index_AweHrAU.jpeg b/static/index_AweHrAU.jpeg new file mode 100644 index 000000000..949471f32 Binary files /dev/null and b/static/index_AweHrAU.jpeg differ diff --git a/static/index_iBoC9t8.jpeg b/static/index_iBoC9t8.jpeg new file mode 100644 index 000000000..949471f32 Binary files /dev/null and b/static/index_iBoC9t8.jpeg differ diff --git a/static/unisex-avatar.jpeg b/static/unisex-avatar.jpeg new file mode 100644 index 000000000..659c1ca92 Binary files /dev/null and b/static/unisex-avatar.jpeg differ