Skip to content

Commit

Permalink
Merge pull request #248 from mvaled/master
Browse files Browse the repository at this point in the history
Fix issue with custom user models.
  • Loading branch information
agusmakmun committed Apr 17, 2024
2 parents 4d9f07b + 8ebf098 commit dc18a8d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions martor/extensions/mention.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@

class MentionPattern(markdown.inlinepatterns.Pattern):
def handleMatch(self, m):
if MARTOR_ENABLE_CONFIGS["mention"] != "true":
return

username = self.unescape(m.group(2))
users = get_user_model().objects.filter(
username=username, is_active=True
User = get_user_model()
users = User.objects.filter(
is_active=True,
**{getattr(User, "USERNAME_FIELD", "username"): username},
) # noqa: E501

"""Makesure `username` is registered and activated."""
if MARTOR_ENABLE_CONFIGS["mention"] == "true" and users.exists():
if users.exists():
url = "{}{}/".format(
MARTOR_MARKDOWN_BASE_MENTION_URL, username
) # noqa: E501
Expand Down

0 comments on commit dc18a8d

Please sign in to comment.