Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12700 dummy fields #12872

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions weblate/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
return author
if author.is_active and not author.is_bot and not author.is_anonymous:
return author
return fallback

Check failure on line 328 in weblate/auth/models.py

View workflow job for this annotation

GitHub Actions / mypy

Incompatible return value type (got "User | None", expected "User")


@functools_cache
Expand Down Expand Up @@ -368,7 +368,7 @@
class GroupManyToManyField(models.ManyToManyField):
"""Customized field to accept Django Groups objects as well."""

def contribute_to_class(self, cls, name, **kwargs) -> None:

Check failure on line 371 in weblate/auth/models.py

View workflow job for this annotation

GitHub Actions / mypy

Signature of "contribute_to_class" incompatible with supertype "Field"
super().contribute_to_class(cls, name, **kwargs)

# Get related descriptor
Expand Down Expand Up @@ -496,7 +496,7 @@
):
AuditLog.objects.create(
user=self,
request=None,

Check failure on line 499 in weblate/auth/models.py

View workflow job for this annotation

GitHub Actions / mypy

Argument "request" to "create" of "AuditLogManager" has incompatible type "None"; expected "AuthenticatedHttpRequest"
activity="enabled" if self.is_active else "disabled",
)

Expand Down Expand Up @@ -551,8 +551,12 @@

def __setattr__(self, name, value) -> None:
"""Mimic first/last name for third-party auth and ignore is_staff flag."""
if name in self.DUMMY_FIELDS:
self.extra_data[name] = value
if name in "first_name" and "full_name" in self.extra_data:
self.extra_data["full_name"] = f'{value} {self.extra_data["full_name"]}'

Check warning on line 555 in weblate/auth/models.py

View check run for this annotation

Codecov / codecov/patch

weblate/auth/models.py#L555

Added line #L555 was not covered by tests
elif name in "last_name" and "full_name" in self.extra_data:
self.extra_data["full_name"] = f'{self.extra_data["full_name"]} {value}'

Check warning on line 557 in weblate/auth/models.py

View check run for this annotation

Codecov / codecov/patch

weblate/auth/models.py#L557

Added line #L557 was not covered by tests
elif "first_name" in name or "last_name" in name:
self.extra_data["full_name"] = value

Check warning on line 559 in weblate/auth/models.py

View check run for this annotation

Codecov / codecov/patch

weblate/auth/models.py#L559

Added line #L559 was not covered by tests
else:
super().__setattr__(name, value)

Expand Down Expand Up @@ -854,7 +858,7 @@
self.groups.add(team)
AuditLog.objects.create(
user=self,
request=request if request is not None and request.user == self else None,

Check failure on line 861 in weblate/auth/models.py

View workflow job for this annotation

GitHub Actions / mypy

Argument "request" to "create" of "AuditLogManager" has incompatible type "AuthenticatedHttpRequest | None"; expected "AuthenticatedHttpRequest"
activity="team-add",
username=request.user.username
if request is not None and request.user
Expand All @@ -870,7 +874,7 @@
self.groups.remove(team)
AuditLog.objects.create(
user=self,
request=request if request is not None and request.user == self else None,

Check failure on line 877 in weblate/auth/models.py

View workflow job for this annotation

GitHub Actions / mypy

Argument "request" to "create" of "AuditLogManager" has incompatible type "AuthenticatedHttpRequest | None"; expected "AuthenticatedHttpRequest"
activity="team-remove",
username=request.user.username
if request is not None and request.user
Expand Down Expand Up @@ -1182,7 +1186,7 @@
class WeblateAuthConf(AppConf):
"""Authentication settings."""

AUTH_RESTRICT_ADMINS = {}

Check failure on line 1189 in weblate/auth/models.py

View workflow job for this annotation

GitHub Actions / mypy

Need type annotation for "AUTH_RESTRICT_ADMINS" (hint: "AUTH_RESTRICT_ADMINS: dict[<type>, <type>] = ...")

# Anonymous user name
ANONYMOUS_USER_NAME = "anonymous"
Expand Down
Loading