feat(portfolio): add email contact

This commit is contained in:
2026-09-14 17:06:01 +02:00
parent 14118cf438
commit 00f6633ecf
13 changed files with 161 additions and 25 deletions
+28 -2
View File
@@ -1,17 +1,43 @@
from django.conf import settings
from django.http.response import HttpResponseBadRequest
from django.utils.translation import gettext as _
from django.views.generic import ListView, TemplateView
from post_office import mail
from portfolio import models
from portfolio import forms, models
class PortfolioView(TemplateView):
template_name = "index.html"
def get_context_data(self, **kwargs):
contact_form = forms.ContactForm()
return {
"job_experiences": models.JobExperience.objects.all().order_by("-start")
"job_experiences": models.JobExperience.objects.all().order_by("-start"),
"contact_form": contact_form,
}
class ProjectList(ListView):
template_name = "project_list.html"
model = models.Project
class ContactSend(TemplateView):
template_name = "contact_thanks.html"
def post(self, request, *args, **kwargs):
form = forms.ContactForm(request.POST)
if not form.is_valid():
return HttpResponseBadRequest(_("Invalid request"))
mail.send(
subject=form.cleaned_data["subject"],
message=form.cleaned_data["message"],
sender=settings.EMAIL_HOST_USER,
cc=form.cleaned_data["email"],
recipients=[settings.EMAIL_CONTACT],
)
return super().get(request, *args, **kwargs)