fix chatbot
This commit is contained in:
parent
c99a83fc67
commit
90ec729b40
Binary file not shown.
@ -145,6 +145,7 @@ def request(path: Optional[str], payload: Dict[str, Any], options: Optional[Dict
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
cfg["project_header"]: project_uuid,
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
}
|
||||
extra_headers = options.get("headers")
|
||||
if isinstance(extra_headers, Iterable):
|
||||
@ -180,6 +181,7 @@ def fetch_status(ai_request_id: Any, options: Optional[Dict[str, Any]] = None) -
|
||||
headers: Dict[str, str] = {
|
||||
"Accept": "application/json",
|
||||
cfg["project_header"]: project_uuid,
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
}
|
||||
extra_headers = options.get("headers")
|
||||
if isinstance(extra_headers, Iterable):
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ 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
|
||||
from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
|
||||
|
||||
class LoginForm(AuthenticationForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -11,6 +11,25 @@ class LoginForm(AuthenticationForm):
|
||||
for field in self.fields.values():
|
||||
field.widget.attrs.update({'class': 'form-control'})
|
||||
|
||||
class CustomPasswordResetForm(PasswordResetForm):
|
||||
def get_users(self, email):
|
||||
"""
|
||||
Custom version that returns only the first matching user to avoid
|
||||
sending multiple emails if multiple accounts share the same email.
|
||||
Returns the most recently active account.
|
||||
"""
|
||||
users = list(super().get_users(email))
|
||||
if users:
|
||||
# Sort by last login (descending) to get the most active account
|
||||
users.sort(key=lambda u: (u.last_login is not None, u.last_login, u.date_joined), reverse=True)
|
||||
return [users[0]]
|
||||
return []
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
for field in self.fields.values():
|
||||
field.widget.attrs.update({'class': 'form-control', 'placeholder': _('Your Email Address')})
|
||||
|
||||
class ContactForm(forms.Form):
|
||||
name = forms.CharField(max_length=100, label=_("Name"), widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('Your Name')}))
|
||||
email = forms.EmailField(label=_("Email"), widget=forms.EmailInput(attrs={'class': 'form-control', 'placeholder': _('Your Email')}))
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
|
||||
{% trans "You are receiving this email because you requested a password reset for your account at" %} {{ site_name }}.
|
||||
|
||||
{% trans "Please go to the following page and choose a new password:" %}
|
||||
{% trans "Please follow the link below to choose a new password:" %}
|
||||
|
||||
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
|
||||
|
||||
{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
|
||||
{% trans "Your username is:" %} {{ user.get_username }}
|
||||
|
||||
{% trans "If you did not request this, please ignore this email." %}
|
||||
|
||||
{% trans "Thanks," %}
|
||||
{% trans "The" %} {{ site_name }} {% trans "Team" %}
|
||||
|
||||
{% trans "If you did not request this, please ignore this email." %}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from django.contrib.auth import views as auth_views
|
||||
from . import views, api_views
|
||||
from .forms import CustomPasswordResetForm
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.index, name='index'),
|
||||
@ -36,7 +37,13 @@ urlpatterns = [
|
||||
path('rate-driver/<int:parcel_id>/', views.rate_driver, name='rate_driver'),
|
||||
|
||||
# Password Reset
|
||||
path('password-reset/', auth_views.PasswordResetView.as_view(template_name='core/password_reset_form.html', email_template_name='core/emails/password_reset_email.html', subject_template_name='core/emails/password_reset_subject.txt'), name='password_reset'),
|
||||
path('password-reset/', auth_views.PasswordResetView.as_view(
|
||||
template_name='core/password_reset_form.html',
|
||||
email_template_name='core/emails/password_reset_email.txt',
|
||||
html_email_template_name='core/emails/password_reset_email.html',
|
||||
subject_template_name='core/emails/password_reset_subject.txt',
|
||||
form_class=CustomPasswordResetForm
|
||||
), name='password_reset'),
|
||||
path('password-reset/done/', auth_views.PasswordResetDoneView.as_view(template_name='core/password_reset_done.html'), name='password_reset_done'),
|
||||
path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name='core/password_reset_confirm.html'), name='password_reset_confirm'),
|
||||
path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(template_name='core/password_reset_complete.html'), name='password_reset_complete'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user