From fd74314a296cafee31aa2d5e3348d373a4c5f856 Mon Sep 17 00:00:00 2001 From: Brian Edelman Date: Mon, 2 Oct 2023 16:27:00 -0400 Subject: [PATCH] removing custom signup --- .../static_source/js/components.ts | 4 -- .../templates/account/signup_form.jinja | 15 ------ .../templates/account/signup_form.ts | 47 ------------------- .../{{cookiecutter.repo_name}}/user/forms.py | 3 +- 4 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.jinja delete mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.ts diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static_source/js/components.ts b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static_source/js/components.ts index f1410393..605aa032 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static_source/js/components.ts +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static_source/js/components.ts @@ -1,10 +1,6 @@ import.meta.glob("@/../templates/components/**/*.js", { eager: true }); import.meta.glob("@/../templates/components/**/*.ts", { eager: true }); -// account -import.meta.glob("@/../templates/account/**/*.js", { eager: true }); -import.meta.glob("@/../templates/account/**/*.ts", { eager: true }); - // forms import.meta.glob("@/../templates/forms/**/*.js", { eager: true }); import.meta.glob("@/../templates/forms/**/*.ts", { eager: true }); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.jinja b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.jinja deleted file mode 100644 index 8df3b947..00000000 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.jinja +++ /dev/null @@ -1,15 +0,0 @@ -{% from 'forms/field.jinja' import field as f %} -
- {{ errors }} - {% for field, errors in fields %} - {% if field.name == 'first_name' or field.name == 'last_name' %} - {{ f(field, errors, 'w-5/12') }} - {% else %} - {{ f(field, errors) }} - {% endif %} - {% endfor %} - {% for field in hidden_fields %}{{ field }}{% endfor %} -
diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.ts b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.ts deleted file mode 100644 index e7de7734..00000000 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/account/signup_form.ts +++ /dev/null @@ -1,47 +0,0 @@ -import AlpineInstance, { AlpineComponent } from "alpinejs"; - -const signup = (): AlpineComponent => ({ - password1: "", - password2: "", - pMatchError: "Passwords must match", - p2OriginalError: "", - get passwordMatch(): boolean { - return (this.password1 === "" || this.password2 === "") - || this.password1 === this.password2; - }, - toggleError() { - const p2 = this.$el.querySelector("#id_password2"); - const p2Field = p2?.closest(".field"); - const p2ErrorIcon = p2?.closest(".input-box")?.querySelector(".right-icon"); - const p2ErrorLabel = p2Field?.parentElement?.querySelector("div.text-error"); - - if (this.passwordMatch) { - if (p2ErrorLabel) { - p2ErrorLabel.innerHTML = this.p2OriginalError; - } - p2Field?.classList?.remove("error"); - p2ErrorIcon?.classList?.add("hidden"); - p2ErrorLabel?.classList?.add("hidden"); - } else { - if (p2ErrorLabel) { - p2ErrorLabel.innerHTML = this.pMatchError; - } - p2Field?.classList?.add("error"); - p2ErrorIcon?.classList?.remove("hidden"); - p2ErrorLabel?.classList?.remove("hidden"); - } - }, - init() { - this.$watch("passwordMatch", () => { - this.toggleError(); - }); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - this.p2OriginalError = this.$el.querySelector("#id_password2")! - .closest(".field")! - .parentElement! - .querySelector("div.text-error")! - .innerHTML; - }, -}); - -AlpineInstance.data("signup", signup); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/user/forms.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/user/forms.py index 4bc08e6b..94b1a962 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/user/forms.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/user/forms.py @@ -17,9 +17,8 @@ class LoginForm(AllAuthLoginForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) -class SignupForm(AllAuthSignupForm): - template_name = "account/signup_form.jinja" +class SignupForm(AllAuthSignupForm): first_name = forms.CharField( label=_("First Name"), min_length=1,