148 lines
7.9 KiB
HTML
148 lines
7.9 KiB
HTML
{% extends "base.html" %}
|
|
{% load i18n %}
|
|
|
|
{% block content %}
|
|
<section class="py-5">
|
|
<div class="container">
|
|
<div class="mb-4">
|
|
<a href="/" class="btn btn-outline-secondary btn-sm">
|
|
<i class="fa-solid fa-arrow-left me-1"></i> {% trans "Back to Home" %}
|
|
</a>
|
|
</div>
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-6">
|
|
<div class="card shadow">
|
|
<div class="card-body p-5">
|
|
<h2 class="text-center mb-4">{% trans "Create your account" %}</h2>
|
|
|
|
<form method="post" novalidate id="registrationForm">
|
|
{% csrf_token %}
|
|
|
|
{% if form.non_field_errors %}
|
|
<div class="alert alert-danger">
|
|
{% for error in form.non_field_errors %}
|
|
{{ error }}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% for field in form %}
|
|
{% if field.name == 'country_code' %}
|
|
<div class="mb-3">
|
|
<label class="form-label">{% trans "Phone Number" %}</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text">+</span>
|
|
<div class="flex-grow-0" style="min-width: 150px;">
|
|
{{ form.country_code }}
|
|
</div>
|
|
{{ form.phone_number }}
|
|
</div>
|
|
{% if form.phone_number.errors or form.country_code.errors %}
|
|
<div class="text-danger small">
|
|
{% for error in form.country_code.errors %}{{ error }} {% endfor %}
|
|
{% for error in form.phone_number.errors %}{{ error }} {% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
<div class="form-text text-muted small">{% trans "Select country and enter phone number." %}</div>
|
|
</div>
|
|
{% elif field.name == 'phone_number' %}
|
|
{# Handled above #}
|
|
{% elif field.name == 'subscription_plan' %}
|
|
{% if subscription_enabled %}
|
|
<div class="mb-3">
|
|
<label class="form-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
|
|
{{ field }}
|
|
{% if field.errors %}
|
|
{% for error in field.errors %}
|
|
<div class="text-danger small">{{ error }}</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
{% elif field.name == 'accept_terms' %}
|
|
<div class="mb-3 form-check">
|
|
{{ field }}
|
|
<label class="form-check-label small" for="{{ field.id_for_label }}">
|
|
{% trans "I have read and agree to the" %}
|
|
<a href="{% url 'terms_of_service' %}" target="_blank">{% trans "Terms of Service" %}</a>
|
|
{% trans "and" %}
|
|
<a href="{% url 'privacy_policy' %}" target="_blank">{% trans "Privacy Policy" %}</a>
|
|
</label>
|
|
{% if field.errors %}
|
|
{% for error in field.errors %}
|
|
<div class="text-danger small">{{ error }}</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
</div>
|
|
{% else %}
|
|
<div class="mb-3">
|
|
<label class="form-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
|
|
{{ field }}
|
|
{% if field.help_text %}
|
|
<div class="form-text text-muted small">{{ field.help_text|safe }}</div>
|
|
{% endif %}
|
|
{% if field.errors %}
|
|
{% for error in field.errors %}
|
|
<div class="text-danger small">{{ error }}</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
<button type="submit" class="btn btn-primary w-100 py-2 mt-3">{% trans "Register" %}</button>
|
|
</form>
|
|
<div class="text-center mt-3">
|
|
<p>{% trans "Already have an account?" %} <a href="{% url 'login' %}">{% trans "Login" %}</a></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
{% if subscription_enabled %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const fees = {{ fees_json|safe }};
|
|
const monthlyLabel = "{% trans 'Monthly Plan' %}";
|
|
const annualLabel = "{% trans 'Annual Plan' %}";
|
|
|
|
function updateFees() {
|
|
// Try multiple ways to find the elements to be extremely robust
|
|
const roleSelect = document.getElementById('id_role') || document.querySelector('[name="role"]');
|
|
const planSelect = document.getElementById('id_subscription_plan') || document.querySelector('[name="subscription_plan"]');
|
|
|
|
if (!roleSelect || !planSelect) return;
|
|
|
|
const role = roleSelect.value;
|
|
// Use case-insensitive match just in case
|
|
const roleKey = Object.keys(fees).find(k => k.toUpperCase() === role.toUpperCase());
|
|
const roleFees = fees[roleKey];
|
|
|
|
if (roleFees) {
|
|
for (let i = 0; i < planSelect.options.length; i++) {
|
|
const option = planSelect.options[i];
|
|
if (option.value === 'MONTHLY') {
|
|
option.text = monthlyLabel + " (" + roleFees.MONTHLY + ")";
|
|
} else if (option.value === 'ANNUAL') {
|
|
option.text = annualLabel + " (" + roleFees.ANNUAL + ")";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const roleField = document.getElementById('id_role') || document.querySelector('[name="role"]');
|
|
if (roleField) {
|
|
roleField.addEventListener('change', updateFees);
|
|
updateFees(); // Run once on load
|
|
}
|
|
|
|
// As a final fallback, try to run after a small delay in case of dynamic rendering issues
|
|
setTimeout(updateFees, 500);
|
|
});
|
|
</script>
|
|
{% endif %}
|
|
|
|
{% endblock %} |