diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index 7baa1a3..eb6fa69 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index f72d1f9..3c22c03 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/forms.py b/core/forms.py index f971caf..556b2da 100644 --- a/core/forms.py +++ b/core/forms.py @@ -3,6 +3,13 @@ from django.contrib.auth.models import User from django.utils.translation import gettext_lazy as _ from django.utils.translation import get_language from .models import Profile, Parcel, Country, Governate, City, DriverRating, DriverReport, ParcelType +from django.contrib.auth.forms import AuthenticationForm + +class LoginForm(AuthenticationForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + for field in self.fields.values(): + field.widget.attrs.update({'class': 'form-control'}) class ContactForm(forms.Form): name = forms.CharField(max_length=100, label=_("Name"), widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('Your Name')})) @@ -412,4 +419,4 @@ class DriverReportForm(forms.ModelForm): labels = { 'reason': _('Reason for Reporting'), 'description': _('Details'), - } \ No newline at end of file + } diff --git a/core/templates/core/login.html b/core/templates/core/login.html index 03b6c07..24ad5c0 100644 --- a/core/templates/core/login.html +++ b/core/templates/core/login.html @@ -22,17 +22,40 @@

{% trans "Please login with your username and password" %}

+ {% if form.non_field_errors %} +
+ + {% for error in form.non_field_errors %} + {{ error }} + {% endfor %} +
+ {% endif %} +
{% csrf_token %} - {% for field in form %} -
- - {{ field }} - {% if field.errors %} -
{{ field.errors }}
- {% endif %} + + +
+ + {{ form.username }} + {% if form.username.errors %} +
{{ form.username.errors }}
+ {% endif %} +
+ + +
+ +
+ {{ form.password }} +
- {% endfor %} + {% if form.password.errors %} +
{{ form.password.errors }}
+ {% endif %} +
@@ -67,6 +90,12 @@ .form-control:focus { border-color: var(--accent-orange); box-shadow: 0 0 0 0.25rem rgba(255, 126, 21, 0.15); + z-index: 3; + } + /* Fix for input-group with rounded corners */ + .input-group > .form-control:not(:last-child) { + border-top-right-radius: 0; + border-bottom-right-radius: 0; } .btn-masarx-primary { background-color: var(--accent-orange); @@ -86,5 +115,33 @@ .hover-orange:hover { color: var(--accent-orange) !important; } + /* RTL adjustments for password toggle */ + [dir="rtl"] #togglePassword { + border-radius: 8px 0 0 8px !important; + border-right-width: 0 !important; + border-left-width: 1px !important; + } + [dir="rtl"] .input-group > .form-control:not(:last-child) { + border-radius: 0 8px 8px 0 !important; + } + + {% endblock %} diff --git a/core/views.py b/core/views.py index ed99b8a..fc93cfa 100644 --- a/core/views.py +++ b/core/views.py @@ -5,7 +5,7 @@ from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from .models import Parcel, Profile, Country, Governate, City, OTPVerification, PlatformProfile, Testimonial, DriverRating, DriverRejection -from .forms import UserRegistrationForm, ParcelForm, ContactForm, UserProfileForm, DriverRatingForm, ShipperRegistrationForm, DriverRegistrationForm, DriverReportForm +from .forms import LoginForm, UserRegistrationForm, ParcelForm, ContactForm, UserProfileForm, DriverRatingForm, ShipperRegistrationForm, DriverRegistrationForm, DriverReportForm from django.utils.translation import gettext_lazy as _ from django.utils.translation import get_language @@ -1110,6 +1110,7 @@ def cancel_parcel(request, parcel_id): return redirect('dashboard') class CustomLoginView(LoginView): + authentication_form = LoginForm template_name = 'core/login.html' def form_valid(self, form):