added contact page

This commit is contained in:
2025-09-10 21:42:15 +02:00
parent c536a9f327
commit d0b3ee9923
6 changed files with 97 additions and 2 deletions

View File

@@ -51,3 +51,9 @@ class OrganizationForm(forms.ModelForm):
class GenerateCodesForm(forms.Form):
count = forms.IntegerField(label="How many codes to generate?", min_value=1, max_value=1000)
class ContactForm(forms.Form):
name = forms.CharField(label="Name", max_length=100)
email = forms.EmailField(label="Email")
message = forms.CharField(label="Message", widget=forms.Textarea(attrs={"rows": 6}), max_length=5000)

View File

@@ -10,7 +10,7 @@
<div>
<h3 class="text-sm font-semibold text-gray-400 tracking-wider uppercase mb-4">Company</h3>
<ul class="space-y-3">
<li><a href="/#" class="text-sm text-blue-200 hover:text-accent transition-colors no-underline">Contact</a></li>
<li><a href="/contact/" class="text-sm text-blue-200 hover:text-accent transition-colors no-underline">Contact</a></li>
</ul>
</div>
<div>

View File

@@ -0,0 +1,19 @@
{% extends "base.html" %}
{% block content %}
<section class="py-16 bg-secondary sm:py-24 p-body-full">
<div class="max-w-lg w-full mx-auto text-center shadow-lg border border-success rounded-xl p-8 bg-white">
<h2 class="text-3xl font-extrabold mb-4 text-success">Thank you for contacting us.</h2>
<p class="mb-8 text-gray-700 text-lg">
We received your message and will reach you soon.
</p>
<a href="{% url 'core:index' %}" class="bg-transparent border-2 border-accent text-accent hover:bg-accent hover:text-primary font-semibold py-3 px-8 rounded-lg text-lg transition-all duration-300 ease-in-out">
Go back to Homepage
</a>
</div>
</section>
{% endblock content %}
{% block bottom %}
<script src="/static/js/formHandling.js"></script>
{% endblock bottom %}

View File

@@ -0,0 +1,48 @@
{% extends "base.html" %}
{% load static widget_tweaks %}
{% block content %}
<section class="py-16 bg-secondary sm:py-24 p-body-full">
<div class="max-w-2xl w-full mx-auto shadow-2xl border-2 border-accent rounded-2xl p-8 bg-white">
<h1 class="text-3xl font-extrabold mb-3 text-primary">Contact Us</h1>
<p class="mb-8 text-gray-700">Have a question or need help? Send us a message and we'll get back to you.</p>
<form method="post" class="space-y-6">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="bg-red-50 border border-red-400 text-red-700 px-4 py-3 rounded-lg">
{{ form.non_field_errors }}
</div>
{% endif %}
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="id_name">Name</label>
{% render_field form.name class+="w-full bg-white border-2 border-accent rounded-lg px-4 py-3 text-gray-900 focus:outline-none focus:ring-2 focus:ring-accent focus:border-accent" %}
{% if form.name.errors %}
<p class="text-red-600 text-sm mt-1">{{ form.name.errors|striptags }}</p>
{% endif %}
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="id_email">Email</label>
{% render_field form.email class+="w-full bg-white border-2 border-accent rounded-lg px-4 py-3 text-gray-900 focus:outline-none focus:ring-2 focus:ring-accent focus:border-accent" %}
{% if form.email.errors %}
<p class="text-red-600 text-sm mt-1">{{ form.email.errors|striptags }}</p>
{% endif %}
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="id_message">Message</label>
{% render_field form.message class+="w-full bg-white border-2 border-accent rounded-lg px-4 py-3 text-gray-900 focus:outline-none focus:ring-2 focus:ring-accent focus:border-accent" %}
{% if form.message.errors %}
<p class="text-red-600 text-sm mt-1">{{ form.message.errors|striptags }}</p>
{% endif %}
</div>
<button type="submit" class="w-full nav-link-desktop bg-primary border-2 border-accent text-accent hover:bg-accent hover:text-primary font-semibold py-3 px-8 rounded-lg text-lg transition-all duration-300 ease-in-out">Send Message</button>
</form>
</div>
</section>
{% endblock %}

View File

@@ -19,6 +19,7 @@ urlpatterns = [
path('terms-and-conditions/', v.terms_and_conditions, name='terms_and_conditions'),
path('refund-policy/', v.refund_policy, name='refund_policy'),
path('privacy-policy/', v.privacy_policy, name='privacy_policy'),
path('contact/', v.contact, name='contact'),
#admin urls
path('admin/demo-codes-pdf/', v.demo_codes_pdf_view, name='demo_codes_pdf'),

View File

@@ -5,7 +5,7 @@ import json
import time
from django.shortcuts import render, redirect , get_object_or_404
from .forms import OrganizationForm
from .forms import OrganizationForm, ContactForm
from .models import Organization,Document, DocumentTemplate, DemoCode, DocumentRiskControl, Risk, Control
from backend.accounts.utils import send_confirmation_email, send_document_email, send_documet_to_expert, send_document_to_reviewer
from django.contrib.admin.views.decorators import staff_member_required
@@ -21,6 +21,7 @@ from weasyprint import HTML
from django.template.loader import render_to_string
from django.views.decorators.csrf import csrf_exempt
from backend.accounts.models import ExpertAnalysisEmails
from django.core.mail import send_mail
# @login_required
@@ -181,6 +182,26 @@ def privacy_policy(request):
def refund_policy(request):
return render(request, "refund_policy.html")
def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
email = form.cleaned_data['email']
message = form.cleaned_data['message']
subject = f"New contact message from {name}"
body = f"From: {name} <{email}>\n\n{message}"
try:
recipients = [e for _, e in settings.ADMINS] if getattr(settings, 'ADMINS', None) else [settings.DEFAULT_FROM_EMAIL]
send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, recipients, fail_silently=False)
return render(request, 'contact-success.html', {"email": email})
except Exception:
logger.exception("Failed to send contact email")
form.add_error(None, "We couldn't send your message right now. Please try again later.")
else:
form = ContactForm()
return render(request, 'contact.html', {"form": form})
@staff_member_required
def demo_codes_pdf_view(request):
filter_by = request.GET.get('filter_by', 'all')