Prod live updates
This commit is contained in:
@@ -53,7 +53,7 @@ MIDDLEWARE = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = "scha.urls"
|
ROOT_URLCONF = "scha.urls"
|
||||||
|
CSRF_TRUSTED_ORIGINS = ["https://schawheaton.aimloperations.com","https://www.schawheaton.aimloperations.com", "https://www.schawheaton.com", "https://schawheaton.com"]
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from django.conf import settings
|
|||||||
from schasite.views import stripe_cancelled, stripe_success, stripe_webhook
|
from schasite.views import stripe_cancelled, stripe_success, stripe_webhook
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path("schasite/", include("schasite.urls")),
|
||||||
path("", include("schasite.urls")),
|
path("", include("schasite.urls")),
|
||||||
path("success/", stripe_success),
|
path("success/", stripe_success),
|
||||||
path("cancelled/", stripe_cancelled),
|
path("cancelled/", stripe_cancelled),
|
||||||
|
|||||||
@@ -11,21 +11,20 @@ from .models import (
|
|||||||
from phonenumber_field.formfields import PhoneNumberField
|
from phonenumber_field.formfields import PhoneNumberField
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
# from django_recaptcha.fields import ReCaptchaField
|
from django_recaptcha.fields import ReCaptchaField
|
||||||
# from django.conf import settings
|
from django.conf import settings
|
||||||
# from django_recaptcha.widgets import ReCaptchaV3
|
from django_recaptcha.widgets import ReCaptchaV3
|
||||||
|
|
||||||
# class CaptchaForm(forms.Form):
|
class CaptchaForm(forms.Form):
|
||||||
# captcha = ReCaptchaField(
|
captcha = ReCaptchaField(
|
||||||
# public_key=settings.RECAPTCHA_PUBLIC_KEY,
|
public_key=settings.RECAPTCHA_PUBLIC_KEY,
|
||||||
# private_key=settings.RECAPTCHA_PRIVATE_KEY,
|
private_key=settings.RECAPTCHA_PRIVATE_KEY,
|
||||||
# widget=ReCaptchaV3(
|
widget=ReCaptchaV3(
|
||||||
# attrs={
|
attrs={
|
||||||
# 'required_score':0.85,
|
'required_score':0.85,
|
||||||
# }
|
}
|
||||||
# ),
|
),
|
||||||
|
)
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
class ChildrenForm(ModelForm):
|
class ChildrenForm(ModelForm):
|
||||||
|
|||||||
@@ -109,9 +109,8 @@
|
|||||||
<i class="bi bi-credit-card text-success display-4 mb-3"></i>
|
<i class="bi bi-credit-card text-success display-4 mb-3"></i>
|
||||||
<h4 class="text-success">Credit/Debit Card</h4>
|
<h4 class="text-success">Credit/Debit Card</h4>
|
||||||
<p class="card-text">Pay securely with Visa, Mastercard, American Express, or Discover.</p>
|
<p class="card-text">Pay securely with Visa, Mastercard, American Express, or Discover.</p>
|
||||||
<a href="https://buy.stripe.com/test_14k6rE7jD3hQ2SQ144" class="btn btn-success mt-3" target="_blank" id="submitBtn">
|
|
||||||
Pay with Card
|
<button class="btn btn-success mt-3" id="submitBtn">Pay Dues</button>
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -192,39 +191,6 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
||||||
<!-- Stripe Integration Script (example) -->
|
<!-- Stripe Integration Script (example) -->
|
||||||
<script>
|
<script src="https://js.stripe.com/v3/"></script>
|
||||||
// This would be replaced with your actual Stripe integration code
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
// Example: Track outbound links to Stripe
|
|
||||||
const stripeLinks = document.querySelectorAll('a[href*="stripe.com"]');
|
|
||||||
stripeLinks.forEach(link => {
|
|
||||||
link.addEventListener('click', function(e) {
|
|
||||||
// You could add analytics tracking here
|
|
||||||
console.log('Redirecting to Stripe payment');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Example: Dynamic balance loading (would connect to your backend)
|
|
||||||
function loadAccountBalance() {
|
|
||||||
// In a real implementation, this would fetch from your database
|
|
||||||
// This is just a placeholder example
|
|
||||||
return {
|
|
||||||
member: "John Doe (Lot #42)",
|
|
||||||
balance: "$600.00",
|
|
||||||
dueDate: "January 15, 2024",
|
|
||||||
lastPayment: "$600.00 on January 10, 2023"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the account info section (example)
|
|
||||||
const accountInfo = loadAccountBalance();
|
|
||||||
document.querySelector('.bg-light p:nth-child(1)').innerHTML =
|
|
||||||
`<strong>Member:</strong> ${accountInfo.member}`;
|
|
||||||
document.querySelector('.bg-light p:nth-child(2)').innerHTML =
|
|
||||||
`<strong>Current Balance:</strong> ${accountInfo.balance} (Due ${accountInfo.dueDate})`;
|
|
||||||
document.querySelector('.bg-light p:nth-child(3)').innerHTML =
|
|
||||||
`<strong>Last Payment:</strong> ${accountInfo.lastPayment}`;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script src="{% static 'main.js' %}"></script>
|
<script src="{% static 'main.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
<h4 class="mb-0">{{ officer.position }}</h4>
|
<h4 class="mb-0">{{ officer.position }}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body text-center">
|
<div class="card-body text-center">
|
||||||
<img src="../images/board/john-smith.jpg" alt="John Smith" class="rounded-circle mb-3" width="150" height="150">
|
<!--<img src="../images/board/john-smith.jpg" alt="John Smith" class="rounded-circle mb-3" width="150" height="150">-->
|
||||||
<h5 class="card-title">{{ officer.name }}</h5>
|
<h5 class="card-title">{{ officer.name }}</h5>
|
||||||
<!-- <p class="text-muted">Term: 2022-2024</p>
|
<!-- <p class="text-muted">Term: 2022-2024</p>
|
||||||
<p class="card-text">John has lived in Greenwood Estates since 2015 and brings 20 years of financial management experience to the board.</p> -->
|
<p class="card-text">John has lived in Greenwood Estates since 2015 and brings 20 years of financial management experience to the board.</p> -->
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
<h4 class="mb-0">TBD</h4>
|
<h4 class="mb-0">TBD</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body text-center">
|
<div class="card-body text-center">
|
||||||
<img src="../images/board/john-smith.jpg" alt="John Smith" class="rounded-circle mb-3" width="150" height="150">
|
<!--<img src="../images/board/john-smith.jpg" alt="John Smith" class="rounded-circle mb-3" width="150" height="150">-->
|
||||||
<h5 class="card-title">TBD</h5>
|
<h5 class="card-title">TBD</h5>
|
||||||
<p class="text-muted">TBD</p>
|
<p class="text-muted">TBD</p>
|
||||||
<p class="card-text">TBD</p>
|
<p class="card-text">TBD</p>
|
||||||
@@ -99,4 +99,4 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from .models import UsefulLinks, CalendarEvent, MembershipPerson, Payments, SCHAOfficer, Membership, CommunityPost
|
from .models import UsefulLinks, CalendarEvent, MembershipPerson, Payments, SCHAOfficer, Membership
|
||||||
from .forms import (
|
from .forms import (
|
||||||
ChildrenForm,
|
ChildrenForm,
|
||||||
CommunityPostForm,
|
CommunityPostForm,
|
||||||
@@ -7,8 +7,8 @@ from .forms import (
|
|||||||
PeopleForm,
|
PeopleForm,
|
||||||
CommitteeForm,
|
CommitteeForm,
|
||||||
ServicesForm,
|
ServicesForm,
|
||||||
|
CaptchaForm
|
||||||
) # , CaptchaForm
|
)
|
||||||
from django.db import transaction, IntegrityError
|
from django.db import transaction, IntegrityError
|
||||||
|
|
||||||
# Stripe required imports
|
# Stripe required imports
|
||||||
@@ -36,28 +36,27 @@ def stripe_config(request):
|
|||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def create_checkout_session(request):
|
def create_checkout_session(request):
|
||||||
if request.method == "GET":
|
if request.method == 'GET':
|
||||||
domain_url = "http://localhost:8000/"
|
domain_url ="https://www.schawheaton.com/"
|
||||||
stripe.api_key = settings.STRIPE_SECRET_KEY
|
stripe.api_key = settings.STRIPE_SECRET_KEY
|
||||||
try:
|
try:
|
||||||
checkout_session = stripe.checkout.Session.create(
|
checkout_session = stripe.checkout.Session.create(
|
||||||
success_url=domain_url + "success?session_id={CHECKOUT_SESSION_ID}",
|
success_url = domain_url+'success?session_id={CHECKOUT_SESSION_ID}',
|
||||||
cancel_url=domain_url + "cancelled/",
|
cancel_url = domain_url+'cancelled/',
|
||||||
payment_method_types=["card"],
|
payment_method_types=['card'],
|
||||||
mode="payment",
|
mode="payment",
|
||||||
line_items=[
|
line_items = [{
|
||||||
{
|
# 'name':'SCHA Dues',
|
||||||
# 'name':'SCHA Dues',
|
'quantity': 1,
|
||||||
"quantity": 1,
|
# 'currency': 'usd',
|
||||||
# 'currency': 'usd',
|
'price':'price_1P5KBtIbGKYTLTtMJ0Rh1jMu',
|
||||||
"price": "price_1OxZLfDV0RPXOyxG5ipjhUXk",
|
#'price_1P5K7uIbGKYTLTtMFNxbkA8X'
|
||||||
}
|
#'price_1OxZLfDV0RPXOyxG5ipjhUXk',
|
||||||
],
|
}]
|
||||||
)
|
)
|
||||||
return JsonResponse({"sessionId": checkout_session["id"]})
|
return JsonResponse({'sessionId': checkout_session['id']})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return JsonResponse({"error": str(e)})
|
return JsonResponse({'error': str(e)})
|
||||||
|
|
||||||
|
|
||||||
def stripe_success(request):
|
def stripe_success(request):
|
||||||
return render(request, "schasite/dues_success.html", {})
|
return render(request, "schasite/dues_success.html", {})
|
||||||
@@ -72,11 +71,13 @@ def stripe_webhook(request):
|
|||||||
stripe.api_key = settings.STRIPE_SECRET_KEY
|
stripe.api_key = settings.STRIPE_SECRET_KEY
|
||||||
endpoint_secret = settings.STRIPE_ENDPOINT_SECRET
|
endpoint_secret = settings.STRIPE_ENDPOINT_SECRET
|
||||||
payload = request.body
|
payload = request.body
|
||||||
sig_header = request.META["HTTP_STRIPE_SIGNATURE"]
|
sig_header = request.META['HTTP_STRIPE_SIGNATURE']
|
||||||
event = None
|
event = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
event = stripe.Webhook.construct_event(payload, sig_header, endpoint_secret)
|
event = stripe.Webhook.construct_event(
|
||||||
|
payload, sig_header, endpoint_secret
|
||||||
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
# Invalid payload
|
# Invalid payload
|
||||||
return HttpResponse(status=400)
|
return HttpResponse(status=400)
|
||||||
@@ -85,17 +86,18 @@ def stripe_webhook(request):
|
|||||||
return HttpResponse(status=400)
|
return HttpResponse(status=400)
|
||||||
|
|
||||||
# Handle the checkout.session.completed event
|
# Handle the checkout.session.completed event
|
||||||
if event["type"] == "checkout.session.completed":
|
if event['type'] == 'checkout.session.completed':
|
||||||
email = None
|
email = None
|
||||||
try:
|
try:
|
||||||
email = event["data"]["object"]["customer_details"]["email"]
|
email = event['data']['object']['customer_details']['email']
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
person = MembershipPerson.objects.filter(
|
person = MembershipPerson.objects.filter(email=email).first() # just take the first
|
||||||
email=email
|
|
||||||
).first() # just take the first
|
|
||||||
|
|
||||||
payment = Payments.objects.create(email=email, person=person)
|
payment = Payments.objects.create(
|
||||||
|
email=email,
|
||||||
|
person = person
|
||||||
|
)
|
||||||
# try to link to a member
|
# try to link to a member
|
||||||
payment.save()
|
payment.save()
|
||||||
# TODO: run some custom code here
|
# TODO: run some custom code here
|
||||||
@@ -170,8 +172,6 @@ def dues2(request):
|
|||||||
|
|
||||||
|
|
||||||
def membership_form2(request):
|
def membership_form2(request):
|
||||||
print(request)
|
|
||||||
print(request.POST)
|
|
||||||
def sanitize_phone_number(data):
|
def sanitize_phone_number(data):
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
data = data.replace("-", "")
|
data = data.replace("-", "")
|
||||||
@@ -241,51 +241,61 @@ def membership_form2(request):
|
|||||||
|
|
||||||
peopleForm1 = PeopleForm(person1_data)
|
peopleForm1 = PeopleForm(person1_data)
|
||||||
peopleForm2 = PeopleForm(person2_data)
|
peopleForm2 = PeopleForm(person2_data)
|
||||||
print(peopleForm1)
|
|
||||||
breakpoint()
|
|
||||||
|
|
||||||
|
|
||||||
for form in [addressForm, servicesForm, committeeForm, peopleForm1, peopleForm2]:
|
print("Validating the captcha form")
|
||||||
print(f"is form valid: {form.is_valid()}")
|
print(request.POST.get("captcha",""))
|
||||||
if not form.is_valid():
|
captchaForm = CaptchaForm({
|
||||||
print(f"form Errors: {form.errors}")
|
"captcha": request.POST.get("captcha","")
|
||||||
|
})
|
||||||
|
print(f"Captch form is: {captchaForm.is_valid()}")
|
||||||
|
|
||||||
|
|
||||||
|
print(f"peopleForm1 form is: {peopleForm1.is_valid()}")
|
||||||
|
print(f"peopleForm2 form is: {peopleForm2.is_valid()}")
|
||||||
|
print(f"servicesForm form is: {servicesForm.is_valid()}")
|
||||||
|
|
||||||
# captchaForm = CaptchaForm(post_data)
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
addressForm.is_valid()
|
addressForm.is_valid()
|
||||||
and committeeForm.is_valid()
|
and committeeForm.is_valid()
|
||||||
and (peopleForm1.is_valid() or peopleForm2.is_valid())
|
and (peopleForm1.is_valid() or peopleForm2.is_valid())
|
||||||
and servicesForm.is_valid()
|
and servicesForm.is_valid()
|
||||||
): # and captchaForm.is_valid():
|
and captchaForm.is_valid()
|
||||||
|
):
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
membership = Membership.objects.create()
|
print("starting to save")
|
||||||
|
try:
|
||||||
|
membership = Membership.objects.create()
|
||||||
|
|
||||||
if peopleForm1.is_valid():
|
if peopleForm1.is_valid():
|
||||||
people1_obj = peopleForm1.save(commit=False)
|
people1_obj = peopleForm1.save(commit=False)
|
||||||
people1_obj.membership = membership
|
people1_obj.membership = membership
|
||||||
people1_obj.save()
|
people1_obj.save()
|
||||||
|
|
||||||
if peopleForm2.is_valid():
|
if peopleForm2.is_valid():
|
||||||
people2_obj = peopleForm2.save(commit=False)
|
people2_obj = peopleForm2.save(commit=False)
|
||||||
people2_obj.membership = membership
|
people2_obj.membership = membership
|
||||||
people2_obj.save()
|
people2_obj.save()
|
||||||
|
|
||||||
committee_obj = committeeForm.save(commit=False)
|
committee_obj = committeeForm.save(commit=False)
|
||||||
committee_obj.membership = membership
|
committee_obj.membership = membership
|
||||||
committee_obj.save()
|
committee_obj.save()
|
||||||
|
|
||||||
services_obj = servicesForm.save(commit=False)
|
services_obj = servicesForm.save(commit=False)
|
||||||
services_obj.membership = membership
|
services_obj.membership = membership
|
||||||
services_obj.save()
|
services_obj.save()
|
||||||
|
|
||||||
address_obj = addressForm.save(commit=False)
|
address_obj = addressForm.save(commit=False)
|
||||||
address_obj.membership = membership
|
address_obj.membership = membership
|
||||||
address_obj.save()
|
address_obj.save()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
return redirect("index2")
|
return redirect("index2")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
print("Some field is not valid")
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"schasite/membership_form2.html",
|
"schasite/membership_form2.html",
|
||||||
@@ -295,7 +305,7 @@ def membership_form2(request):
|
|||||||
"addressForm": addressForm,
|
"addressForm": addressForm,
|
||||||
"committeeForm": committeeForm,
|
"committeeForm": committeeForm,
|
||||||
"servicesForm": servicesForm,
|
"servicesForm": servicesForm,
|
||||||
# 'captchaForm': captchaForm,
|
'captchaForm': captchaForm,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -307,7 +317,7 @@ def membership_form2(request):
|
|||||||
"peopleForm2": PeopleForm(prefix="person2"),
|
"peopleForm2": PeopleForm(prefix="person2"),
|
||||||
"committeeForm": CommitteeForm(),
|
"committeeForm": CommitteeForm(),
|
||||||
"servicesForm": ServicesForm(),
|
"servicesForm": ServicesForm(),
|
||||||
# 'captchaForm': CaptchaForm(),
|
'captchaForm': CaptchaForm(),
|
||||||
"addressForm": AddressForm(
|
"addressForm": AddressForm(
|
||||||
initial={
|
initial={
|
||||||
"city": "Wheaton",
|
"city": "Wheaton",
|
||||||
@@ -523,4 +533,4 @@ def profile(request):
|
|||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
else:
|
else:
|
||||||
return render(request, "schasite/profile.html",{})
|
return render(request, "schasite/profile.html",{})
|
||||||
|
|||||||
Reference in New Issue
Block a user