mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
fix #110
This commit is contained in:
parent
5b2c70e4fb
commit
deb8f865df
@ -167,14 +167,17 @@ class LoginForm(AuthenticationForm):
|
||||
try:
|
||||
if account_code.match(data["username"]):
|
||||
user = (
|
||||
Customer.objects.filter(account_id__iexact=data["username"])
|
||||
Customer.objects.filter(
|
||||
account_id__iexact=data["username"])
|
||||
.first()
|
||||
.user
|
||||
)
|
||||
elif "@" in data["username"]:
|
||||
user = User.objects.filter(email__iexact=data["username"]).first()
|
||||
user = User.objects.filter(
|
||||
email__iexact=data["username"]).first()
|
||||
else:
|
||||
user = User.objects.filter(username=data["username"]).first()
|
||||
user = User.objects.filter(
|
||||
username=data["username"]).first()
|
||||
data["username"] = user.username
|
||||
except:
|
||||
pass
|
||||
@ -279,7 +282,8 @@ class UserProfileForm(forms.ModelForm):
|
||||
new_file = SithFile(
|
||||
parent=parent,
|
||||
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,
|
||||
is_folder=False,
|
||||
mime_type=f.content_type,
|
||||
@ -346,7 +350,8 @@ class PagePropForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
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(
|
||||
Page, "edit_groups", "groups", help_text="", label=_("edit groups")
|
||||
@ -364,7 +369,8 @@ class PagePropForm(forms.ModelForm):
|
||||
class PageForm(forms.ModelForm):
|
||||
class Meta:
|
||||
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(
|
||||
Page, "edit_groups", "groups", help_text="", label=_("edit groups")
|
||||
@ -410,9 +416,10 @@ class TzAwareDateTimeField(forms.DateTimeField):
|
||||
if isinstance(value, str):
|
||||
# convert it into a naive datetime (no timezone attached)
|
||||
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)
|
||||
value = timezone.make_aware(value, timezone.utc)
|
||||
if value is not None:
|
||||
value = timezone.make_aware(value, timezone.utc)
|
||||
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = to_current_timezone(value)
|
||||
|
Loading…
Reference in New Issue
Block a user