Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Small tweaks on messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
lvalics committed Jan 23, 2024
1 parent 4be4f23 commit ff4029d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
24 changes: 14 additions & 10 deletions dj_backend_server/web/templates/create_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Create a new user</h1>
<p style="margin-bottom: 2rem">Please note down the username and password to send to the user.
They will be required to change these credentials upon their first login.</p>

{% if error_message %}
<div class="bg-danger text-sm text-white p-3" role="alert">
<span class="font-bold">Error:</span> {{ error_message }}
</div>
{% endif %}

{% if error_messages %}
<div class="bg-danger text-sm text-white p-3" role="alert">
{% for message in error_messages %}
<div><span class="font-bold">Error:</span> {{ message }}</div>
{% endfor %}
</div>
{% endif %}



<!-- Form -->
Expand All @@ -31,7 +35,7 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Create a new user</h1>
<div>
<label class="block text-sm font-medium mb-1" for="Username">Username
<span class="text-rose-500">*</span></label>
<input type="text" id="simpleinput" class="form-input">
<input type="text" id="username" name="username" class="form-input">
</div>

</li>
Expand All @@ -40,7 +44,7 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Create a new user</h1>

<div>
<label class="block text-sm font-medium mb-1" for="first_name">First name
<span class="text-rose-500">*</span></label>
</label>
<input id="first_name" class="form-input w-full" type="text" name="first_name">
</div>

Expand All @@ -50,7 +54,7 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Create a new user</h1>

<div>
<label class="block text-sm font-medium mb-1" for="last_name">Last name
<span class="text-rose-500">*</span></label>
</label>
<input id="last_name" class="form-input w-full" type="text" name="last_name">

</div>
Expand All @@ -71,7 +75,7 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Create a new user</h1>
<div>
<label class="block text-sm font-medium mb-1" for="password">Password
<span class="text-rose-500">*</span></label>
<input id="password" class="form-input w-full" type="password" name="password">
<input id="password" class="form-input w-full" type="password" name="password" required>
<p>Suggested password (user will change) <strong>{{ SUGGESTEDPASS }}</strong></p>
</div>

Expand All @@ -82,7 +86,7 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Create a new user</h1>
<div>
<label class="block text-sm font-medium mb-1" for="check_password">Check password
<span class="text-rose-500">*</span></label>
<input id="check_password" class="form-input w-full" type="password" name="check_password">
<input id="check_password" class="form-input w-full" type="password" name="check_password" required>
</div>

</li>
Expand Down
7 changes: 5 additions & 2 deletions dj_backend_server/web/templates/modify_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Modify your user data</h1>

<div>
<label class="block text-sm font-medium mb-1" for="first_name">First name
<span class="text-rose-500">*</span></label>
</label>
<input id="first_name" class="form-input w-full" type="text" name="first_name" value="{{ user.first_name }}">
</div>

Expand All @@ -39,7 +39,7 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Modify your user data</h1>

<div>
<label class="block text-sm font-medium mb-1" for="last_name">Last name
<span class="text-rose-500">*</span></label>
</label>
<input id="last_name" class="form-input w-full" type="text" name="last_name" value="{{ user.last_name }}">
</div>

Expand Down Expand Up @@ -77,6 +77,9 @@ <h1 class="text-3xl text-slate-800 font-bold mb-6">Modify your user data</h1>
</li>
<!-- List item -->
</ul>
<div class="bg-secondary/25 text-secondary text-sm p-3" role="alert">
<span class="font-bold">Password and Check password</span> do not need to be sent if they are not changing.
</div>
</div>
<div class="flex items-center justify-between">
<button type="submit" class="btn bg-primary text-white py-2 px-3">Update user -&gt;</button>
Expand Down
4 changes: 4 additions & 0 deletions dj_backend_server/web/views/views_chatbot_createuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from django.utils.crypto import get_random_string
from django.urls import reverse
from django.contrib import messages
import logging
logger = logging.getLogger(__name__)


@login_required(login_url='/login/')
Expand All @@ -35,6 +37,7 @@ def createuser(request):
if not request.user.is_superuser:
return HttpResponseRedirect(reverse('index'))
if request.method == 'POST':
logger.debug("Processing POST request for user creation.")
username = request.POST.get('username')
first_name = request.POST.get('first_name')
last_name = request.POST.get('last_name')
Expand Down Expand Up @@ -95,6 +98,7 @@ def createuser(request):
is_active=True,
date_joined=now()
)
logger.info(f"User created successfully: {user.username} (ID: {user.id})")

# Redirect to a new URL:
request.session['created_username'] = username # Store the username in the session
Expand Down

0 comments on commit ff4029d

Please sign in to comment.