1
This commit is contained in:
2023-12-14 18:27:56 +02:00
parent d9407e221b
commit ddcb33e20d
16 changed files with 78 additions and 34 deletions

0
app/signup/__init__.py Normal file
View File

5
app/signup/admin.py Normal file
View File

@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Signup
admin.site.register(Signup)

6
app/signup/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class SignupConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'signup'

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.0 on 2023-12-14 20:13
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Signup',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(max_length=254)),
('created_at', models.DateTimeField(auto_now_add=True)),
('anonymized_ip', models.GenericIPAddressField()),
('user_agent', models.CharField(max_length=255)),
],
),
migrations.AddConstraint(
model_name='signup',
constraint=models.UniqueConstraint(fields=('email',), name='unique_email'),
),
]

View File

15
app/signup/models.py Normal file
View File

@@ -0,0 +1,15 @@
from django.db import models
class Signup(models.Model):
email = models.EmailField()
created_at = models.DateTimeField(auto_now_add = True)
anonymized_ip = models.GenericIPAddressField()
user_agent = models.CharField(max_length = 255)
class Meta:
constraints = [
models.UniqueConstraint(name = "unique_email", fields = ["email"]),
]
def __str__(self):
return self.email

3
app/signup/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
app/signup/urls.py Normal file
View File

@@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
]

4
app/signup/views.py Normal file
View File

@@ -0,0 +1,4 @@
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello. You're at the signup index.")