This commit is contained in:
Cyrille Stroesser 2021-11-18 15:04:25 +01:00
parent 5b2c70e4fb
commit deb8f865df

View File

@ -167,14 +167,17 @@ class LoginForm(AuthenticationForm):
try: try:
if account_code.match(data["username"]): if account_code.match(data["username"]):
user = ( user = (
Customer.objects.filter(account_id__iexact=data["username"]) Customer.objects.filter(
account_id__iexact=data["username"])
.first() .first()
.user .user
) )
elif "@" in data["username"]: elif "@" in data["username"]:
user = User.objects.filter(email__iexact=data["username"]).first() user = User.objects.filter(
email__iexact=data["username"]).first()
else: else:
user = User.objects.filter(username=data["username"]).first() user = User.objects.filter(
username=data["username"]).first()
data["username"] = user.username data["username"] = user.username
except: except:
pass pass
@ -279,7 +282,8 @@ class UserProfileForm(forms.ModelForm):
new_file = SithFile( new_file = SithFile(
parent=parent, parent=parent,
name=self.generate_name(field, f), name=self.generate_name(field, f),
file=resize_image(im, 400, f.content_type.split("/")[-1]), file=resize_image(
im, 400, f.content_type.split("/")[-1]),
owner=self.instance, owner=self.instance,
is_folder=False, is_folder=False,
mime_type=f.content_type, mime_type=f.content_type,
@ -346,7 +350,8 @@ class PagePropForm(forms.ModelForm):
class Meta: class Meta:
model = Page model = Page
fields = ["parent", "name", "owner_group", "edit_groups", "view_groups"] fields = ["parent", "name", "owner_group",
"edit_groups", "view_groups"]
edit_groups = make_ajax_field( edit_groups = make_ajax_field(
Page, "edit_groups", "groups", help_text="", label=_("edit groups") Page, "edit_groups", "groups", help_text="", label=_("edit groups")
@ -364,7 +369,8 @@ class PagePropForm(forms.ModelForm):
class PageForm(forms.ModelForm): class PageForm(forms.ModelForm):
class Meta: class Meta:
model = Page model = Page
fields = ["parent", "name", "owner_group", "edit_groups", "view_groups"] fields = ["parent", "name", "owner_group",
"edit_groups", "view_groups"]
edit_groups = make_ajax_field( edit_groups = make_ajax_field(
Page, "edit_groups", "groups", help_text="", label=_("edit groups") Page, "edit_groups", "groups", help_text="", label=_("edit groups")
@ -410,8 +416,9 @@ class TzAwareDateTimeField(forms.DateTimeField):
if isinstance(value, str): if isinstance(value, str):
# convert it into a naive datetime (no timezone attached) # convert it into a naive datetime (no timezone attached)
value = parse_datetime(value) value = parse_datetime(value)
# attach it to the UTC timezone (so that to_current_timezone() # attach it to the UTC timezone (so that to_current_timezone()) if not None
# converts it to the local timezone) # converts it to the local timezone)
if value is not None:
value = timezone.make_aware(value, timezone.utc) value = timezone.make_aware(value, timezone.utc)
if isinstance(value, datetime.datetime): if isinstance(value, datetime.datetime):