mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
fix #110
This commit is contained in:
parent
5b2c70e4fb
commit
deb8f865df
@ -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,9 +416,10 @@ 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)
|
||||||
value = timezone.make_aware(value, timezone.utc)
|
if value is not None:
|
||||||
|
value = timezone.make_aware(value, timezone.utc)
|
||||||
|
|
||||||
if isinstance(value, datetime.datetime):
|
if isinstance(value, datetime.datetime):
|
||||||
value = to_current_timezone(value)
|
value = to_current_timezone(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user