From 04e490c0b0b65a21c531ac50a5ba321c79e14fa2 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 26 Nov 2024 17:03:16 +0000 Subject: Got the basic form anbd privacy policy in place --- alphabetlearning/payments/admin.py | 5 + .../0009_emailsignup_alter_price_resource.py | 28 ++ alphabetlearning/payments/models.py | 7 + alphabetlearning/payments/urls.py | 4 + alphabetlearning/payments/views.py | 54 +++- alphabetlearning/templates/base.html | 85 +---- alphabetlearning/templates/pages/home.html | 356 ++------------------- .../templates/pages/privacy_policy.html | 17 + .../templates/payments/success_email_signup.html | 11 + 9 files changed, 135 insertions(+), 432 deletions(-) create mode 100644 alphabetlearning/payments/migrations/0009_emailsignup_alter_price_resource.py create mode 100644 alphabetlearning/templates/pages/privacy_policy.html create mode 100644 alphabetlearning/templates/payments/success_email_signup.html (limited to 'alphabetlearning') diff --git a/alphabetlearning/payments/admin.py b/alphabetlearning/payments/admin.py index 685af63..e9b70db 100644 --- a/alphabetlearning/payments/admin.py +++ b/alphabetlearning/payments/admin.py @@ -6,6 +6,7 @@ from .models import Product from .models import ShoppingCart from .models import Subscription from .models import SubscriptionPlan +from .models import EmailSignup from alphabetlearning.resources.models import Resource @@ -16,6 +17,9 @@ from alphabetlearning.resources.models import Resource # inlines = [PriceInlineAdmin] +class SuccessEmailSignupAdmin(admin.ModelAdmin): + list_display = ("email", "date_added") + class SubscriptionPlanAdmin(admin.ModelAdmin): list_display = ("name", "price", "description", "allowed_downloads") @@ -42,3 +46,4 @@ admin.site.register(Price) admin.site.register(ShoppingCart, ShoppingCartAdmin) admin.site.register(CartItem) admin.site.register(Subscription, SubscriptionAdmin) +admin.site.register(EmailSignup, SuccessEmailSignupAdmin) \ No newline at end of file diff --git a/alphabetlearning/payments/migrations/0009_emailsignup_alter_price_resource.py b/alphabetlearning/payments/migrations/0009_emailsignup_alter_price_resource.py new file mode 100644 index 0000000..4be05a2 --- /dev/null +++ b/alphabetlearning/payments/migrations/0009_emailsignup_alter_price_resource.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.4 on 2024-11-25 11:32 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('payments', '0008_remove_price_product_price_resource'), + ('resources', '0020_remove_resource_price_resource_stripe_product_id'), + ] + + operations = [ + migrations.CreateModel( + name='EmailSignup', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('email', models.EmailField(max_length=254, unique=True)), + ('date_added', models.DateTimeField(auto_now_add=True)), + ], + ), + migrations.AlterField( + model_name='price', + name='resource', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='price_obj', to='resources.resource'), + ), + ] diff --git a/alphabetlearning/payments/models.py b/alphabetlearning/payments/models.py index 7bf4164..7a8c7bb 100644 --- a/alphabetlearning/payments/models.py +++ b/alphabetlearning/payments/models.py @@ -5,6 +5,13 @@ from django.db import models from alphabetlearning.resources.models import Resource +class EmailSignup(models.Model): + email = models.EmailField(unique=True) + date_added = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return self.email + class Product(models.Model): name = models.CharField(max_length=255) stripe_product_id = models.CharField(max_length=100) diff --git a/alphabetlearning/payments/urls.py b/alphabetlearning/payments/urls.py index 9bedaf7..12f445d 100644 --- a/alphabetlearning/payments/urls.py +++ b/alphabetlearning/payments/urls.py @@ -3,6 +3,7 @@ from django.urls import path from . import views from .views import CancelView from .views import SuccessView +from .views import privacy_policy # Import the new view app_name = "payments" @@ -20,4 +21,7 @@ urlpatterns = [ path("landing/", views.ProductLandingPageView.as_view(), name="landing"), path("delete-cart-item/", views. DeleteCartItem.as_view(), name="delete_cart_item"), path("webhooks/stripe/", views.stripe_webhook, name="stripe-webhook"), + path("email_signup/", views.email_signup, name="email_signup"), + path("success_email_signup/", views.SuccessEmailSignupView.as_view(), name="success_email_signup"), + path('privacy-policy/', privacy_policy, name='privacy_policy'), # Add this line ] diff --git a/alphabetlearning/payments/views.py b/alphabetlearning/payments/views.py index 92751c9..e9f2ded 100644 --- a/alphabetlearning/payments/views.py +++ b/alphabetlearning/payments/views.py @@ -1,23 +1,20 @@ -import stripe -from django.http import HttpResponse, HttpResponseBadRequest -from django.core.mail import send_mail -from django.urls import reverse_lazy from django.conf import settings from django.contrib.auth.decorators import login_required -from django.shortcuts import get_object_or_404 -from django.shortcuts import redirect -from django.shortcuts import render +from django.core.mail import send_mail +from django.http import HttpResponse, HttpResponseBadRequest +from django.shortcuts import get_object_or_404, render, redirect +from django.urls import reverse, reverse_lazy from django.views import View -from django.views.generic import TemplateView, DeleteView from django.views.decorators.csrf import csrf_exempt +from django.views.generic import TemplateView, DeleteView +from alphabetlearning.payments.models import EmailSignup from alphabetlearning.resources.models import Resource from alphabetlearning.users.models import User -from .models import CartItem -from .models import Price -from .models import Product -from .models import ShoppingCart +from .models import CartItem, Price, Product, ShoppingCart + +import stripe # TODO get the cart integrated with Stripe # Steps to convert our Cart into something that can be used with Stripe: @@ -40,6 +37,34 @@ from .models import ShoppingCart stripe.api_key = settings.STRIPE_SECRET_KEY +class SuccessEmailSignupView(TemplateView): + template_name = "payments/success_email_signup.html" + +def email_signup(request): + if request.method == 'POST': + email = request.POST.get('email') + if email: + EmailSignup.objects.get_or_create(email=email) + # Send email to user + send_mail( + "Thank you for signing up", + "You have successfully signed up for our newsletter.", + settings.DEFAULT_FROM_EMAIL, + [email], + fail_silently=False, + ) + # Send email to admin + admin_email = "admin@example.com" # Replace with actual admin email + send_mail( + "New Email Signup", + f"A new user has signed up with the email: {email}", + settings.DEFAULT_FROM_EMAIL, + [admin_email], + fail_silently=False, + ) + return redirect(reverse('payments:success_email_signup')) # Redirect to a success page or similar + return render(request, 'pages/home.html') # Adjust as necessary + def create_line_items(resources): price_objs = [r.price_obj.first() for r in resources] stripe_price_ids = [p.stripe_price_id for p in price_objs] @@ -89,7 +114,7 @@ def add_to_cart(request, resource_id): resource = get_object_or_404(Resource, id=resource_id) if not resource.price_obj.first(): return HttpResponseBadRequest( - f"There is no price assigned to this resource. Please contact Alphabet Learning Support." + "There is no price assigned to this resource. Please contact Alphabet Learning Support." ) cart, created = ShoppingCart.objects.get_or_create(user=request.user) cart_item, created = CartItem.objects.get_or_create(cart=cart, resource=resource) @@ -183,5 +208,8 @@ class DeleteCartItem(DeleteView): request.user.shoppingcart.delete() return redirect("resources:resource_list") +def privacy_policy(request): + return render(request, 'pages/privacy_policy.html') + diff --git a/alphabetlearning/templates/base.html b/alphabetlearning/templates/base.html index 8bc9416..e6531ab 100644 --- a/alphabetlearning/templates/base.html +++ b/alphabetlearning/templates/base.html @@ -93,7 +93,7 @@
  • @@ -109,37 +109,6 @@ Log out {% endif %}
  • - @@ -163,56 +132,6 @@
    {% block content %} {% endblock content %} - -
    {% endblock main %} {% endblock body %} diff --git a/alphabetlearning/templates/pages/home.html b/alphabetlearning/templates/pages/home.html index aa206f3..633c607 100644 --- a/alphabetlearning/templates/pages/home.html +++ b/alphabetlearning/templates/pages/home.html @@ -3,348 +3,32 @@ {% load static %} {% block content %} - - - Check - - - - Bootstrap - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    High quality educational resources

    -

    I am very good at making resources for young children and here I am, selling - them to you. - You will find that these are some of the best educational resoures on the internet.

    -
    - - -
    -
    -
    -
    - - - {# Image section#} -
    -
    -
    -

    Sample Resources

    -
    - Sample Resource -
    -

    This is a sample of the high-quality educational resources you can - access with our membership plans. Our resources are carefully crafted by experienced educators - to engage and inspire young learners.

    -
    -
    -
    - - -
    - -
    - -
    -
    -
    -
    - - - -
    -
    -

    First benefit

    -

    Some nice descriptive text about the feature here. Sell it and make - it really exciting!

    - - Call to action - - - - -
    -
    -
    -
    - - - -
    -
    -

    Featured title

    -

    Some nice descriptive text about the feature here. Sell it and make - it really exciting!

    - - Call to action - - - - -
    -
    -
    -
    - - - -
    -
    -

    Featured title

    -

    Some nice descriptive text about the feature here. Sell it and make - it really exciting!

    - - - Call to action - - - - -
    -
    -
    -
    -
    -
    - -
    - -
    -

    Pricing

    -

    Quickly build an effective pricing table for your potential customers with this - Bootstrap example. It’s built with default Bootstrap components and utilities with little customization.

    -
    - - -
    -
    -
    -
    -

    Starter

    -
    -
    -

    £0/mo

    -
      -
    • 20 resources included
    • -
    • Something else that is basic
    • -
    • Email support
    • -
    • Help center access
    • -
    - -
    -
    -
    -
    -
    -
    -

    Learner

    -
    -
    -

    £4.99/mo

    -
      -
    • 100 resources included
    • -
    • Something else that is pro
    • -
    • Email support
    • -
    • Help center access
    • -
    - +

    + Alphabet Learning is a brand new platform selling high quality educational resources. + As of November 2024, the site is currently in active development and will be launched soon. +

    +

    To be kept informed about the site launch and to receive 50% off your first purchase, please submit your email address + to join our new-customer mailing list.

    +
    + {% csrf_token %} +
    + + +
    + +
    +

    + By clicking 'Submit' you agree to us retaining your email address in accordance with our Privacy and Legal Notice. +

    +

    + +

    -
    -
    -
    -

    Member

    -
    -
    -

    £8.99/mo

    -
      -
    • All resources included
    • -
    • Something else that is really good
    • -
    • Email support
    • -
    • Help center access
    • -
    - -
    -
    -
    -
    - -

    Compare plans

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    StarterLearnerMember
    Public - - - - - - - - - - - -
    Private - - - - - - - -
    Permissions - - - - - - - - - - - -
    Sharing - - - - - - - -
    Unlimited members - - - - - - - -
    Extra security - - - -
    -
    - - - {% endblock content %} diff --git a/alphabetlearning/templates/pages/privacy_policy.html b/alphabetlearning/templates/pages/privacy_policy.html new file mode 100644 index 0000000..df8544d --- /dev/null +++ b/alphabetlearning/templates/pages/privacy_policy.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} + +{% block content %} +
    +

    Privacy and Data Policy

    +

    Your privacy is important to us. This policy explains how we collect, use, and protect your information.

    +

    Information We Collect

    +

    We collect information that you provide to us directly, such as your email address when you sign up for our newsletter.

    +

    How We Use Your Information

    +

    Your information is used to send you updates about our services and promotions.

    +

    Data Protection

    +

    We take appropriate security measures to protect your personal information.

    +

    Contact Us

    +

    If you have any questions about this policy, please contact us.

    +

    Additionally, if you would like to have your email removed from our database, please email us at help@alphabetlearning.online with your request.

    +
    +{% endblock content %} \ No newline at end of file diff --git a/alphabetlearning/templates/payments/success_email_signup.html b/alphabetlearning/templates/payments/success_email_signup.html new file mode 100644 index 0000000..f953beb --- /dev/null +++ b/alphabetlearning/templates/payments/success_email_signup.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% load static %} + +{% block content %} +
    +
    +

    Thanks for signing up!

    +

    When we go live, we will be in touch with a 50% off discount code for your first purchase and other exclusive offers.

    +
    +{% endblock content %} \ No newline at end of file -- cgit v1.2.3