csp roi calculator

This commit is contained in:
Tobias Brunner 2025-07-16 15:12:25 +02:00
parent a4ff21cc35
commit 545b49ecd2
Signed by: tobru
SSH key fingerprint: SHA256:kOXg1R6c11XW3/Pt9dbLdQvOJGFAy+B2K6v6PtRWBGQ
5 changed files with 1358 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,39 @@
{% extends 'base.html' %}
{% load static %}
{% block title %}Authentication Required{% endblock %}
{% block content %}
<div class="container my-5">
<div class="row justify-content-center">
<div class="col-md-6 col-lg-4">
<div class="card shadow">
<div class="card-body">
<div class="text-center mb-4">
<i class="bi bi-shield-lock text-primary" style="font-size: 3rem;"></i>
<h2 class="h4 mt-3">Authentication Required</h2>
<p class="text-muted">Please enter the password to access the CSP ROI Calculator</p>
</div>
{% if messages %}
{% for message in messages %}
<div class="alert alert-danger" role="alert">
{{ message }}
</div>
{% endfor %}
{% endif %}
<form method="post">
{% csrf_token %}
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary w-100">Access Calculator</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -29,4 +29,9 @@ urlpatterns = [
views.pricelist, views.pricelist,
name="pricelist", name="pricelist",
), ),
path(
"csp-roi-calculator/",
views.csp_roi_calculator,
name="csp_roi_calculator",
),
] ]

View file

@ -7,3 +7,4 @@ from .services import *
from .pages import * from .pages import *
from .subscriptions import * from .subscriptions import *
from .pricelist import * from .pricelist import *
from .calculator import *

View file

@ -0,0 +1,37 @@
from django.shortcuts import render, redirect
from django.contrib import messages
from django.views.decorators.http import require_http_methods
@require_http_methods(["GET", "POST"])
def csp_roi_calculator(request):
"""
CSP ROI Calculator - Protected view with password authentication
Provides a comprehensive ROI calculation tool for cloud provider investors
"""
# Handle logout
if request.method == "POST" and request.POST.get("logout"):
request.session.pop("csp_calculator_authenticated", None)
return redirect("services:csp_roi_calculator")
# Simple password protection - check if authenticated in session
if not request.session.get("csp_calculator_authenticated", False):
if request.method == "POST":
password = request.POST.get("password", "")
# Simple password check - in production, this should be more secure
if password == "servala2025": # TODO: Move to environment variable
request.session["csp_calculator_authenticated"] = True
return redirect("services:csp_roi_calculator")
else:
messages.error(request, "Invalid password. Please try again.")
# Show password form
return render(request, "calculator/password_form.html")
# User is authenticated, show the calculator
context = {
"page_title": "CSP ROI Calculator",
"page_description": "Calculate potential returns from investing in Servala platform",
}
return render(request, "calculator/csp_roi_calculator.html", context)