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

Add actions and external identifier for response users. #43

Merged
merged 1 commit into from
Jul 2, 2019

Conversation

adamlphillips
Copy link
Contributor

No description provided.

@adamlphillips adamlphillips added the wip Work in Progress label Jun 25, 2019
Copy link
Contributor

@evnsio evnsio left a comment

Choose a reason for hiding this comment

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

Minor general point, but we've generally used absolute paths for imports. Would be nice to be consistent, if only at the file level.

UserExternalID = apps.get_model('core', 'UserExternalID')

for inc in Incident.objects.all():
inc.reporter = UserExternalID.objects.get(external_id=inc.reporter_tmp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the UserExternalID's always exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point we can't create UserExtrnalID's it is the responsibility of the other apps. From core we don't know where each id came from and can't associate them. The slack app must do it from it's migration.

Copy link
Contributor

Choose a reason for hiding this comment

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

My question is: what happens here if the UserExternalID doesn't exist when we try to get it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would want it to fail or we would lose data. The alternative would be to create a placeholder user that would not be associated with an application.

from django.contrib.auth.models import User


class UserExternalID(models.Model):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this a little less formal? Maybe ExternalUser or ResponseUser?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used to associate the Django user to the identifier of another application. This should be a one to many 'user' to external application id. I added the display name since we don't link the users immediately or enforce that it must be linked. The username is a more friendly in the ui without needing to query somewhere else. I will make the change if you insist but it was not intended to be a "user".

Copy link
Contributor

Choose a reason for hiding this comment

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

I just think the name is a mouthful. LinkedUser or ExternalUser would be preferable.

incident.end_time = datetime.now()
incident.save()

comms_channel.post_in_channel(f"The incident has been closed! 📖 -> 📕")
Copy link
Contributor

Choose a reason for hiding this comment

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

Strong emoji game! 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't fix/Won't fix.

@adamlphillips adamlphillips force-pushed the actions-and-users branch 2 times, most recently from 75ea49a to 7ba0323 Compare June 27, 2019 13:59
UserExternalID = apps.get_model('core', 'UserExternalID')

for inc in Incident.objects.all():
inc.reporter = UserExternalID.objects.get(external_id=inc.reporter_tmp)
Copy link
Contributor

Choose a reason for hiding this comment

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

My question is: what happens here if the UserExternalID doesn't exist when we try to get it here?

from django.contrib.auth.models import User


class UserExternalID(models.Model):
Copy link
Contributor

Choose a reason for hiding this comment

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

I just think the name is a mouthful. LinkedUser or ExternalUser would be preferable.

severity = submission['severity']

name = get_user_profile(user_id)['name']
reporter = GetOrCreateSlackUserExternalID(external_id=user_id, display_name=name)[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

We never use anything but the zeroth return value from this function - can we just return that to avoid the [0] at the end?

@adamlphillips adamlphillips removed the wip Work in Progress label Jul 1, 2019
@adamlphillips adamlphillips merged commit 4e43343 into master Jul 2, 2019
@milesbxf milesbxf deleted the actions-and-users branch August 15, 2019 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants