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

Hd staff mentions #17

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open

Hd staff mentions #17

wants to merge 12 commits into from

Conversation

awwang0628
Copy link
Collaborator

Adds ability for Helpdesk Users to @ other Helpdesk Users in followup comments

Copy link
Collaborator

@ebeers-png ebeers-png left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played around with it, it's working really well!

formatted_mention = f'<span style="color:blue">@{user.first_name} {user.last_name}</span>'

return formatted_mention
except User.DoesNotExist:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible for two users to have the same first and last name, so I would also catch User.MultipleObjectsReturned as well as User.DoesNotExist

mention_pattern = re.compile(r'@\"(.*?)\"')

for match in mention_pattern.findall(comment):
first_name, last_name = match.split()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the code where you check for the email address as well as the first name / last name

user=user,
ticket=ticket,
organization=ticket.ticket_form.organization,
message = "You have been mentioned in ticket " + str(ticket.id),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the message to "<request user's name/email> mentioned you on ticket <ticket id>"?


mention_pattern = re.compile(r'@\"(.*?)\"')

for match in mention_pattern.findall(comment):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only staff users are allowed to use Markdown, so check that request.user is HD staff first


for match in mention_pattern.findall(comment):
first_name, last_name = match.split()
user = User.objects.get(first_name=first_name, last_name=last_name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Staff shouldn't be able to @ users who aren't staff, so after finding user, check that it's staff


try:
if '@' in mention:
user = User.objects.get(email=mention)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Staff shouldn't be able to @ users who aren't staff, so after finding user, check that it's staff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants