diff --git a/TealCode/TealCode/settings.py b/TealCode/TealCode/settings.py index cb59c68..e3ae54b 100644 --- a/TealCode/TealCode/settings.py +++ b/TealCode/TealCode/settings.py @@ -41,6 +41,9 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'main.apps.MainConfig', + 'contact.apps.ContactConfig', + 'crispy_forms', + 'crispy_bootstrap5', ] MIDDLEWARE = [ @@ -129,6 +132,10 @@ USE_L10N = True USE_TZ = True +# Cripsy Forms +CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5" +CRISPY_TEMPLATE_PACK = "bootstrap5" + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ diff --git a/TealCode/TealCode/urls.py b/TealCode/TealCode/urls.py index f0e7848..afc4986 100644 --- a/TealCode/TealCode/urls.py +++ b/TealCode/TealCode/urls.py @@ -19,6 +19,7 @@ from django.views.generic.base import TemplateView urlpatterns = [ path('', include('main.urls')), + path('contact/', include('contact.urls')), path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")), path('AD/SDGFOLKJASDNVASDFASDFSLAKDF/', admin.site.urls), ] diff --git a/TealCode/contact/__init__.py b/TealCode/contact/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/TealCode/contact/admin.py b/TealCode/contact/admin.py new file mode 100644 index 0000000..10fab72 --- /dev/null +++ b/TealCode/contact/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin + +from contact.models import Entry + +admin.site.register(Entry) diff --git a/TealCode/contact/apps.py b/TealCode/contact/apps.py new file mode 100644 index 0000000..002d6c2 --- /dev/null +++ b/TealCode/contact/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ContactConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'contact' diff --git a/TealCode/contact/forms.py b/TealCode/contact/forms.py new file mode 100644 index 0000000..2ae1a46 --- /dev/null +++ b/TealCode/contact/forms.py @@ -0,0 +1,7 @@ +from django.forms import ModelForm,HiddenInput +from .models import Entry + +class EntryForm(ModelForm): + class Meta: + model = Entry + fields = [ 'email', 'subject', 'message'] \ No newline at end of file diff --git a/TealCode/contact/migrations/0001_initial.py b/TealCode/contact/migrations/0001_initial.py new file mode 100644 index 0000000..814b102 --- /dev/null +++ b/TealCode/contact/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 3.2.9 on 2021-11-25 08:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Entry', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('ip', models.CharField(max_length=80)), + ('email', models.EmailField(max_length=200)), + ('subject', models.CharField(max_length=80)), + ('message', models.TextField(max_length=4000)), + ], + ), + ] diff --git a/TealCode/contact/migrations/0002_entry_date_created.py b/TealCode/contact/migrations/0002_entry_date_created.py new file mode 100644 index 0000000..b1b9ec0 --- /dev/null +++ b/TealCode/contact/migrations/0002_entry_date_created.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.9 on 2021-11-25 08:14 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('contact', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='entry', + name='date_created', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + ] diff --git a/TealCode/contact/migrations/__init__.py b/TealCode/contact/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/TealCode/contact/models.py b/TealCode/contact/models.py new file mode 100644 index 0000000..f7f6c78 --- /dev/null +++ b/TealCode/contact/models.py @@ -0,0 +1,15 @@ +from django.db import models +from django.utils import timezone + +class Entry(models.Model): + ip = models.CharField(max_length=80) + email = models.EmailField(max_length=200) + subject = models.CharField(max_length=80) + message = models.TextField(max_length=4000) + date_created = models.DateTimeField(default=timezone.now) + + + def __str__(self): + return self.email + " - " + self.subject + + diff --git a/TealCode/contact/templates/contact/index.html b/TealCode/contact/templates/contact/index.html new file mode 100644 index 0000000..bc8eb8d --- /dev/null +++ b/TealCode/contact/templates/contact/index.html @@ -0,0 +1,35 @@ +{% extends "base.html" %} +{% load crispy_forms_tags %} +{% block content %} +