ready to deploy
This commit is contained in:
@@ -41,6 +41,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'phonenumber_field',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -129,3 +130,14 @@ STATICFILES_DIRS = (os.path.join(APP_DIR, 'static'),APP_DIR)
|
|||||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
# Recapcha Stuff
|
||||||
|
RECAPTCHA_PUBLIC_KEY = '6LdXRbopAAAAAL9NT7C2J3Fuu_b6rvhhsPyxTd9Z'
|
||||||
|
RECAPTCHA_PRIVATE_KEY = '6LdXRbopAAAAAPt31zdQJaOwLseognmZHZEHmWlt'
|
||||||
|
|
||||||
|
# SMTP2GO
|
||||||
|
EMAIL_HOST = 'mail.smtp2go.com'
|
||||||
|
EMAIL_HOST_USER = 'info.aimloperations.com'
|
||||||
|
EMAIL_HOST_PASSWORD = 'ZDErIII2sipNNVMz'
|
||||||
|
EMAIL_PORT = 2525
|
||||||
|
EMAIL_USE_TLS = True
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from .models import Contact
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
@admin.register(Contact, site=admin.site)
|
||||||
|
class ContactAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ("email", "name", "contacted")
|
||||||
|
list_filter = ("email", "name", "contacted")
|
||||||
|
search_fields = ("email", "name")
|
||||||
@@ -2,5 +2,5 @@ from django.apps import AppConfig
|
|||||||
|
|
||||||
|
|
||||||
class WebpageConfig(AppConfig):
|
class WebpageConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = 'webpage'
|
name = "webpage"
|
||||||
|
|||||||
16
refundom/webpage/forms.py
Normal file
16
refundom/webpage/forms.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from django import forms
|
||||||
|
from django_recaptcha.fields import ReCaptchaField
|
||||||
|
from django_recaptcha.widgets import ReCaptchaV3
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class FormWithCaptcha(forms.Form):
|
||||||
|
captcha = ReCaptchaField(
|
||||||
|
widget=ReCaptchaV3(
|
||||||
|
attrs={
|
||||||
|
"required_score": 0.85,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
public_key=settings.RECAPTCHA_PUBLIC_KEY,
|
||||||
|
private_key=settings.RECAPTCHA_PRIVATE_KEY,
|
||||||
|
)
|
||||||
50
refundom/webpage/migrations/0001_initial.py
Normal file
50
refundom/webpage/migrations/0001_initial.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-03-25 01:32
|
||||||
|
|
||||||
|
import django.utils.timezone
|
||||||
|
import phonenumber_field.modelfields
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Contact",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("created", models.DateTimeField(default=django.utils.timezone.now)),
|
||||||
|
(
|
||||||
|
"last_modified",
|
||||||
|
models.DateTimeField(default=django.utils.timezone.now),
|
||||||
|
),
|
||||||
|
("email", models.EmailField(max_length=128)),
|
||||||
|
("name", models.CharField(max_length=128)),
|
||||||
|
("contacted", models.BooleanField(default=False)),
|
||||||
|
(
|
||||||
|
"phone_number",
|
||||||
|
phonenumber_field.modelfields.PhoneNumberField(
|
||||||
|
max_length=128, region=None
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("street", models.CharField(max_length=128)),
|
||||||
|
("zip_code", models.CharField(max_length=9)),
|
||||||
|
("state", models.CharField(max_length=25)),
|
||||||
|
("city", models.CharField(max_length=128)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"abstract": False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,3 +1,34 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
|
from django.utils import timezone
|
||||||
|
from phonenumber_field.modelfields import PhoneNumberField
|
||||||
|
|
||||||
|
class TimeInfoBase(models.Model):
|
||||||
|
|
||||||
|
created = models.DateTimeField(default=timezone.now)
|
||||||
|
last_modified = models.DateTimeField(default=timezone.now)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if not kwargs.pop("skip_last_modified", False) and not hasattr(self, "skip_last_modified"):
|
||||||
|
self.last_modified = timezone.now()
|
||||||
|
if kwargs.get("update_fields") is not None:
|
||||||
|
kwargs["update_fields"] = list({*kwargs["update_fields"], "last_modified"})
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class Contact(TimeInfoBase):
|
||||||
|
email = models.EmailField(max_length=128)
|
||||||
|
name = models.CharField(max_length=128)
|
||||||
|
contacted = models.BooleanField(default=False)
|
||||||
|
phone_number = PhoneNumberField()
|
||||||
|
|
||||||
|
street = models.CharField(max_length=128)
|
||||||
|
zip_code = models.CharField(max_length=9)
|
||||||
|
state = models.CharField(max_length=25)
|
||||||
|
city = models.CharField(max_length=128)
|
||||||
@@ -13,24 +13,105 @@
|
|||||||
<!-- Contact Form -->
|
<!-- Contact Form -->
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="contact-form">
|
<div class="contact-form">
|
||||||
<form>
|
<form action="{% url 'contact' %}" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Full Name</label>
|
<label for="name">Full Name</label>
|
||||||
<input type="text" class="form-control" id="name" placeholder="Enter your full name" required>
|
<input type="text" class="form-control" id="name" name="name" placeholder="Enter your full name" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email">Email Address</label>
|
<label for="email">Email Address</label>
|
||||||
<input type="email" class="form-control" id="email" placeholder="Enter your email" required>
|
<input type="email" class="form-control" id="email" name="email" placeholder="Enter your email" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="phone">Phone Number</label>
|
<label for="phone_number">Phone Number</label>
|
||||||
<input type="tel" class="form-control" id="phone" placeholder="Enter your phone number">
|
<input type="tel" class="form-control" id="phone_number" name="phone_number" placeholder="Enter your phone number" required>
|
||||||
|
</div>
|
||||||
|
<!-- Address Fields -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="street">Street Address</label>
|
||||||
|
<input type="text" class="form-control" id="street" name="street" placeholder="123 Main St" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="city">City</label>
|
||||||
|
<input type="text" class="form-control" id="city" name="city" placeholder="City" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="state">State</label>
|
||||||
|
<select class="form-control" id="state" name="state" required>
|
||||||
|
<option value="" disabled selected>Select</option>
|
||||||
|
<option value="AL">Alabama</option>
|
||||||
|
<option value="AK">Alaska</option>
|
||||||
|
<option value="AZ">Arizona</option>
|
||||||
|
<option value="AR">Arkansas</option>
|
||||||
|
<option value="CA">California</option>
|
||||||
|
<option value="CO">Colorado</option>
|
||||||
|
<option value="CT">Connecticut</option>
|
||||||
|
<option value="DE">Delaware</option>
|
||||||
|
<option value="DC">District Of Columbia</option>
|
||||||
|
<option value="FL">Florida</option>
|
||||||
|
<option value="GA">Georgia</option>
|
||||||
|
<option value="HI">Hawaii</option>
|
||||||
|
<option value="ID">Idaho</option>
|
||||||
|
<option value="IL">Illinois</option>
|
||||||
|
<option value="IN">Indiana</option>
|
||||||
|
<option value="IA">Iowa</option>
|
||||||
|
<option value="KS">Kansas</option>
|
||||||
|
<option value="KY">Kentucky</option>
|
||||||
|
<option value="LA">Louisiana</option>
|
||||||
|
<option value="ME">Maine</option>
|
||||||
|
<option value="MD">Maryland</option>
|
||||||
|
<option value="MA">Massachusetts</option>
|
||||||
|
<option value="MI">Michigan</option>
|
||||||
|
<option value="MN">Minnesota</option>
|
||||||
|
<option value="MS">Mississippi</option>
|
||||||
|
<option value="MO">Missouri</option>
|
||||||
|
<option value="MT">Montana</option>
|
||||||
|
<option value="NE">Nebraska</option>
|
||||||
|
<option value="NV">Nevada</option>
|
||||||
|
<option value="NH">New Hampshire</option>
|
||||||
|
<option value="NJ">New Jersey</option>
|
||||||
|
<option value="NM">New Mexico</option>
|
||||||
|
<option value="NY">New York</option>
|
||||||
|
<option value="NC">North Carolina</option>
|
||||||
|
<option value="ND">North Dakota</option>
|
||||||
|
<option value="OH">Ohio</option>
|
||||||
|
<option value="OK">Oklahoma</option>
|
||||||
|
<option value="OR">Oregon</option>
|
||||||
|
<option value="PA">Pennsylvania</option>
|
||||||
|
<option value="RI">Rhode Island</option>
|
||||||
|
<option value="SC">South Carolina</option>
|
||||||
|
<option value="SD">South Dakota</option>
|
||||||
|
<option value="TN">Tennessee</option>
|
||||||
|
<option value="TX">Texas</option>
|
||||||
|
<option value="UT">Utah</option>
|
||||||
|
<option value="VT">Vermont</option>
|
||||||
|
<option value="VA">Virginia</option>
|
||||||
|
<option value="WA">Washington</option>
|
||||||
|
<option value="WV">West Virginia</option>
|
||||||
|
<option value="WI">Wisconsin</option>
|
||||||
|
<option value="WY">Wyoming</option>
|
||||||
|
<!-- Add all other states as needed -->
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="zip">ZIP Code</label>
|
||||||
|
<input type="text" class="form-control" id="zip" name="zip" placeholder="12345" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="message">Message</label>
|
{% if capchaForm %}
|
||||||
<textarea class="form-control" id="message" rows="5" placeholder="How can we help you?" required></textarea>
|
{{ capchaForm }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary btn-block">Submit</button>
|
<button type="submit" value="Send" class="btn btn-primary btn-block">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,35 +1,63 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.conf import settings
|
||||||
import requests
|
import requests
|
||||||
|
from .models import Contact
|
||||||
|
from .forms import FormWithCaptcha
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
def index(request):
|
|
||||||
|
def index(request):
|
||||||
return render(request, "webpage/index.html", {})
|
return render(request, "webpage/index.html", {})
|
||||||
|
|
||||||
def contact(request):
|
|
||||||
|
def contact(request):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
name: str = request.data.get("name")
|
name: str = request.POST.get("name")
|
||||||
email: str = request.data.get("email")
|
email: str = request.POST.get("email")
|
||||||
address: str = request.data.get("address")
|
phone_number: str = request.POST.get("phone_number")
|
||||||
phone_number: str = request.data.get("phone_number")
|
|
||||||
|
street: str = request.POST.get("street")
|
||||||
|
city: str = request.POST.get("city")
|
||||||
|
state: str = request.POST.get("state")
|
||||||
|
zip_code: str = request.POST.get("zip")
|
||||||
|
capchaForm = FormWithCaptcha(request.POST)
|
||||||
|
|
||||||
|
|
||||||
url = "https://api.example-reverse-search-service.com/v1/search"
|
url = "https://api.example-reverse-search-service.com/v1/search"
|
||||||
params = {
|
params = {
|
||||||
'name': name,
|
"name": name,
|
||||||
'email': email,
|
"email": email,
|
||||||
'address': address,
|
"phone": phone_number,
|
||||||
'phone': phone,
|
|
||||||
'api_key': api_key
|
"street": street,
|
||||||
}
|
"city": city,
|
||||||
|
"state": state,
|
||||||
# Send a GET request to the API
|
"zip_code": zip_code,
|
||||||
response = requests.get(url, params=params)
|
"api_key": 'some_key',
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
contact_obj = Contact.objects.get_or_create(
|
||||||
|
name=name,
|
||||||
|
email=email,
|
||||||
|
phone_number=phone_number,
|
||||||
|
street=street,
|
||||||
|
city=city,
|
||||||
|
state=state,
|
||||||
|
zip_code=zip_code
|
||||||
|
)
|
||||||
|
capcha = None if settings.DEBUG else FormWithCaptcha()
|
||||||
|
return render(request, "webpage/contact.html", {'capchaForm':capcha})
|
||||||
|
except:
|
||||||
|
return render(request, "webpage/contact.html", {'capchaForm':capchaForm, 'error':'There was an error. Try again later' })
|
||||||
|
|
||||||
|
capcha = None if settings.DEBUG else FormWithCaptcha()
|
||||||
|
return render(request, "webpage/contact.html", {'capchaForm':capcha})
|
||||||
|
|
||||||
else:
|
|
||||||
return render(request, "webpage/contact.html", {})
|
|
||||||
|
|
||||||
def process(request):
|
def process(request):
|
||||||
return render(request, "webpage/process.html", {})
|
return render(request, "webpage/process.html", {})
|
||||||
|
|
||||||
|
|
||||||
def about_us(request):
|
def about_us(request):
|
||||||
return render(request, "webpage/about_us.html", {})
|
return render(request, "webpage/about_us.html", {})
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
asgiref==3.7.2
|
asgiref==3.7.2
|
||||||
|
certifi==2025.1.31
|
||||||
|
charset-normalizer==3.4.1
|
||||||
Django==5.0
|
Django==5.0
|
||||||
django-enum==2.1.0
|
django-enum==2.1.0
|
||||||
django-phonenumber-field==8.0.0
|
django-phonenumber-field==8.0.0
|
||||||
django-recaptcha==4.0.0
|
django-recaptcha==4.0.0
|
||||||
|
idna==3.10
|
||||||
phonenumbers==9.0.0
|
phonenumbers==9.0.0
|
||||||
|
requests==2.32.3
|
||||||
sqlparse==0.4.4
|
sqlparse==0.4.4
|
||||||
typing_extensions==4.8.0
|
typing_extensions==4.8.0
|
||||||
|
urllib3==2.3.0
|
||||||
|
|||||||
Reference in New Issue
Block a user