From 65ac133ea9b9843c229afff8e14dd37606cfb5cc Mon Sep 17 00:00:00 2001 From: beck <bekban2020@gmail.com> Date: Thu, 4 Jul 2024 10:49:00 +0300 Subject: [PATCH] message --- eaii_startup/settings.py | 51 +++++++++++++-------------- main/forms.py | 2 +- main/models.py | 8 ++--- main/views.py | 4 ++- templates/forms/startupForm.html | 17 --------- templates/main/login.html | 59 ++++++++++++++++---------------- 6 files changed, 64 insertions(+), 77 deletions(-) diff --git a/eaii_startup/settings.py b/eaii_startup/settings.py index bd7fc4a..7489195 100644 --- a/eaii_startup/settings.py +++ b/eaii_startup/settings.py @@ -25,7 +25,8 @@ SECRET_KEY = 'django-insecure-v(2z)mj6tp1g*ej-c*my!y3bb7eyz!yp@)4gp-^b$z@1d7p77j # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True CRISPY_TEMPLATE_PACK = "bootstrap5" -ALLOWED_HOSTS = ["192.168.1.174","*"] +ALLOWED_HOSTS = ["*"] +# ALLOWED_HOSTS = ["192.168.1.174","*"] #SESSION_ENGINE = 'django.contrib.sessions.backends.db' #SESSION_COOKIE_AGE = 1209600 # Session duration in seconds (default: 1209600 seconds or 2 weeks) # SESSION_SAVE_EVERY_REQUEST = True @@ -88,47 +89,47 @@ ASGI_APPLICATION = "eaii_startup.asgi.application" -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'startup', - 'USER': 'postgres', - 'PASSWORD': 'admin', - 'HOST': '192.168.1.200', - 'PORT': '5432', - } -} - - -CHANNEL_LAYERS = { - "default": { - "BACKEND": "channels_redis.core.RedisChannelLayer", - "CONFIG": { - "hosts": [("192.168.1.200", 6379)], - }, - }, -} - # DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.postgresql_psycopg2', # 'NAME': 'startup', # 'USER': 'postgres', -# 'PASSWORD': 'postgres', -# 'HOST': 'localhost', +# 'PASSWORD': 'admin', +# 'HOST': '192.168.1.200', # 'PORT': '5432', # } # } + # CHANNEL_LAYERS = { # "default": { # "BACKEND": "channels_redis.core.RedisChannelLayer", # "CONFIG": { -# "hosts": [("localhost", 6379)], +# "hosts": [("192.168.1.200", 6379)], # }, # }, # } +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'startup', + 'USER': 'postgres', + 'PASSWORD': 'postgres', + 'HOST': 'localhost', + 'PORT': '5432', + } +} + +CHANNEL_LAYERS = { + "default": { + "BACKEND": "channels_redis.core.RedisChannelLayer", + "CONFIG": { + "hosts": [("localhost", 6379)], + }, + }, +} + # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators diff --git a/main/forms.py b/main/forms.py index ca2a02c..cec52c4 100644 --- a/main/forms.py +++ b/main/forms.py @@ -26,7 +26,7 @@ class UserEditForm(ModelForm): # exclude = ('username',) class UserForm(ModelForm): - password2 = forms.CharField(widget=forms.PasswordInput) + password2 = forms.CharField(widget=forms.PasswordInput,label='Confirm Password') username = forms.CharField( max_length=30, help_text="", diff --git a/main/models.py b/main/models.py index f3b50c3..4798070 100644 --- a/main/models.py +++ b/main/models.py @@ -96,8 +96,8 @@ class Address(models.Model): website = models.CharField( verbose_name='Website', max_length=50, - null=False, - blank=False + null=True, + blank=True ) def __str__(self): @@ -148,9 +148,9 @@ class Profile(models.Model): validators=[validate_image] ) contact = models.CharField( - verbose_name='Contact', max_length=50, null=False, blank=False) + verbose_name='Contact', max_length=50, null=True, blank=True) secondary_email = models.EmailField( - verbose_name='Alternative Email', max_length=150, null=False, blank=False) + verbose_name='Alternative Email', max_length=150, null=True, blank=True) gender = models.IntegerField( verbose_name='Sex/Gender', default=0, choices=GENDER_CHOICES) # 2. CharField Choices modified = models.DateTimeField(auto_now=True) diff --git a/main/views.py b/main/views.py index ed3ce86..35599cf 100644 --- a/main/views.py +++ b/main/views.py @@ -775,7 +775,9 @@ def loginUser(request): # Increment login attempts on failed login cache.set(login_attempts_key, login_attempts + 1, timeout=300) # Lockout for 5 minutes - return HttpResponse("Invalid credentials or StartupProjectUser account is not active. Please try again.") + messages.error(request,"Invalid credentials or Startup Project User account is not active. Please try again.") + return render(request, 'main/login.html', context) + # return HttpResponse("Invalid credentials or Startup Project User account is not active. Please try again.") else: print(False) return render(request, 'main/login.html', context) diff --git a/templates/forms/startupForm.html b/templates/forms/startupForm.html index fb516d8..91573c8 100644 --- a/templates/forms/startupForm.html +++ b/templates/forms/startupForm.html @@ -76,23 +76,6 @@ <button type="submit" class="btn btn-primary">Register</button> </form> -<div class="spinner-grow" id="spinner" style="display: none; width: 3rem; height: 3rem;" role="status" > - <span class="sr-only">Loading...</span> - </div> - <div id="overlay" class="overlay" style="display: none;"></div> - <script> - document.addEventListener("DOMContentLoaded", function() { - const form = document.getElementById("startup_"); - const spinner = document.getElementById("spinner"); - const overlay = document.getElementById("overlay"); - - form.addEventListener("submit", function() { - spinner.style.display = "block"; - overlay.style.display = "block"; - }); - }); - -</script> <script> $(document).ready(function() { diff --git a/templates/main/login.html b/templates/main/login.html index 90fdd8a..4f29180 100644 --- a/templates/main/login.html +++ b/templates/main/login.html @@ -236,37 +236,38 @@ body{ </div> <div class="forms"> <div class="form-content"> - <div class="login-form"> - <div class="title"> - Login - </div> - <!-- <p class="text-end"><a href="/">Back to Home</a></p> --> - <form id="loginForm" method="POST" action="{% url 'main:login' %}"> - {% csrf_token %} - <div class="input-boxes"> - <div class="input-box"> - <i class="bi bi-envelope"></i> - {{ login_form.username }} - </div> - <div class="input-box"> - <i class="bi bi-lock"></i> - {{ login_form.password }} - </div> - <br> - <div class="input-box"> - {{ login_form.recaptcha }} + <div class="login-form"> + <div class="title"> + Login </div> - <div class="button input-box"> - <input type="submit" value="Submit" /> - </div> - <div class="text sign-up-text"> - Don't have an account? <a href="{% url 'main:register'%}"><label>Signup now</label></a> - </div> - </div> - </form> - </div> + + <form id="loginForm" method="POST" action="{% url 'main:login' %}"> + {% csrf_token %} + <div class="input-boxes"> + <div class="input-box"> + <i class="bi bi-envelope"></i> + {{ login_form.username }} + </div> + <div class="input-box"> + <i class="bi bi-lock"></i> + {{ login_form.password }} + </div> + <br> + <div class="input-box"> + {{ login_form.recaptcha }} + </div> + <div class="button input-box"> + <input type="submit" value="Submit" /> + </div> + <div class="text sign-up-text"> + Don't have an account? <a href="{% url 'main:register'%}"><label>Signup now</label></a> + </div> + </div> + </form> + </div> </div> - </div> +</div> + </div> -- GitLab