Skip to content

Commit

Permalink
added emails via dynamodb
Browse files Browse the repository at this point in the history
Signed-off-by: Trey <[email protected]>
  • Loading branch information
TreyWW committed Sep 29, 2024
1 parent c5f6b2f commit af2da17
Show file tree
Hide file tree
Showing 8 changed files with 584 additions and 467 deletions.
32 changes: 32 additions & 0 deletions backend/api/landing_page/email_waitlist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from textwrap import dedent

from django.contrib import messages
from login_required import login_not_required

from backend.models import InvoiceProduct
from backend.service import BOTO3_HANDLER
from backend.types.requests import WebRequest

from django.http import HttpResponse


@login_not_required
def join_waitlist_endpoint(request: WebRequest):
email_address = request.POST.get("email", "")
name = request.POST.get("name", "")

if not email_address:
return HttpResponse(status=400)

if not BOTO3_HANDLER.initiated:
return HttpResponse(status=500)

BOTO3_HANDLER.dynamodb_client.put_item(TableName="myfinances-emails", Item={"email": {"S": email_address}, "name": {"S": name}})

content = """
<div class='text-success'>
Successfully registered! Expect some discounts and updates as we progress in our journey :)
</div>
"""

return HttpResponse(status=200, content=dedent(content).strip())
8 changes: 8 additions & 0 deletions backend/api/landing_page/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path
from . import email_waitlist

urlpatterns = [
path("join_waitlist/", email_waitlist.join_waitlist_endpoint, name="join_waitlist"),
]

app_name = "landing_page"
1 change: 1 addition & 0 deletions backend/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
path("emails/", include("backend.api.emails.urls")),
path("reports/", include("backend.api.reports.urls")),
path("hc/", include("backend.api.healthcheck.urls")),
path("landing_page/", include("backend.api.landing_page.urls")),
path("public/", include("backend.api.public.urls")),
]

Expand Down
9 changes: 8 additions & 1 deletion backend/service/boto3/handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
import botocore.client
from botocore.config import Config
from botocore.exceptions import NoCredentialsError, PartialCredentialsError

Expand All @@ -22,6 +22,8 @@ def __init__(self):
self.scheduler_lambda_arn: str = get_var("SCHEDULER_LAMBDA_ARN")
self.scheduler_lambda_access_role_arn: str = get_var("SCHEDULER_LAMBDA_ACCESS_ROLE_ARN")
self.scheduler_invoices_group_name: str = get_var("SCHEDULER_INVOICES_GROUP_NAME")
self.dynamodb_client = None
self.scheduler_client = None

print(f"Region: {self.region_name}")
print("| has aws access key id" if self.aws_access_key_id else "X no aws access key id")
Expand Down Expand Up @@ -68,7 +70,12 @@ def _initiate_clients(self):
return None

self._schedule_client = self._boto3_session.client("scheduler")
self.schedule_client = self._schedule_client
self._dynamodb_client = self._boto3_session.client("dynamodb")
self.dynamodb_client = self._dynamodb_client

self.SCHEDULE_EXCEPTIONS = self._schedule_client.exceptions
self.DYNAMO_EXCEPTIONS = self._dynamodb_client.exceptions
self.initiated = True

logger.info("Boto3Handler has been initiated!")
Expand Down
10 changes: 5 additions & 5 deletions billing/templates/pages/billing/dashboard/growth_usages.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
</tr>
<tr>
<td>Next 400 invocations</td>
<td>£0.08/invocation</td>
<td>£0.07/invocation</td>
</tr>
<tr>
<td>Greater than 300 invocations</td>
<td>Greater than 500 invocations</td>
<td>£0.04/invocation</td>
</tr>
</tbody>
Expand Down Expand Up @@ -119,15 +119,15 @@
<tbody>
<tr>
<td>First 5 customers</td>
<td>£0.00/customer</td>
<td>Included for free</td>
</tr>
<tr>
<td>Next 20 customers</td>
<td>£0.08/customer</td>
<td>£0.10/customer</td>
</tr>
<tr>
<td>Greater than 25 customers</td>
<td>£0.05/customer</td>
<td>£0.08/customer</td>
</tr>
</tbody>
</table>
Expand Down
18 changes: 16 additions & 2 deletions frontend/templates/pages/landing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,23 @@ <h1 class="max-w-2xl mb-4 text-3xl font-extrabold leading-none tracking-tight md
<p class="max-w-2xl mb-6 font-light lg:mb-8 md:text-lg lg:text-xl">
Automate invoicing, streamline customer onboarding, and manage your documents — all in one place.
</p>
<p class="mb-3">Join the early access club for free!</p>
<div class="space-y-4 sm:flex sm:space-y-0 sm:space-x-4">
<a class="btn btn-primary"
href="{% url 'auth:login create_account manual' %}">Start Today – Free for 30 Days</a>
{# <a class="btn btn-primary"#}
{# href="{% url 'auth:login create_account manual' %}">Start Today – Free for 30 Days</a>#}
<form class="join" hx-post="{% url 'api:landing_page:join_waitlist' %}">
{% csrf_token %}
<input type="text"
name="name"
placeholder="Name"
class="input input-bordered join-item">
<input type="email"
name="email"
placeholder="Email Address"
required
class="input input-bordered join-item">
<button class="btn btn-primary join-item">Join the Hype</button>
</form>
</div>
</div>
<div class="hidden lg:mt-0 lg:col-span-5 lg:flex">
Expand Down
972 changes: 513 additions & 459 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ boto3-stubs = { extras = [
"sesv2",
"events",
"scheduler",
"dynamodb",
"iam",
"stepfunctions",
], version = "^1.34.76" }
Expand Down

0 comments on commit af2da17

Please sign in to comment.