mirror of https://github.com/zulip/zulip.git
models.py: Add get_role_name function in UserProfile class.
This function returns the name of the user role that we can use to display in error report emails.
This commit is contained in:
parent
51d4d210d4
commit
8b30e03d4b
|
@ -192,14 +192,7 @@ def sponsorship(request: HttpRequest, user: UserProfile,
|
||||||
realm = user.realm
|
realm = user.realm
|
||||||
|
|
||||||
requested_by = user.full_name
|
requested_by = user.full_name
|
||||||
|
user_role = user.get_role_name()
|
||||||
role_id_to_name_map = {
|
|
||||||
UserProfile.ROLE_REALM_OWNER: "Realm owner",
|
|
||||||
UserProfile.ROLE_REALM_ADMINISTRATOR: "Realm adminstrator",
|
|
||||||
UserProfile.ROLE_MEMBER: "Member",
|
|
||||||
UserProfile.ROLE_GUEST: "Guest"
|
|
||||||
}
|
|
||||||
user_role = role_id_to_name_map[user.role]
|
|
||||||
|
|
||||||
support_realm_uri = get_realm(settings.STAFF_SUBDOMAIN).uri
|
support_realm_uri = get_realm(settings.STAFF_SUBDOMAIN).uri
|
||||||
support_url = urljoin(support_realm_uri, urlunsplit(("", "", reverse('analytics.views.support'),
|
support_url = urljoin(support_realm_uri, urlunsplit(("", "", reverse('analytics.views.support'),
|
||||||
|
|
|
@ -1124,6 +1124,16 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
|
||||||
presence_enabled=bool,
|
presence_enabled=bool,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ROLE_ID_TO_NAME_MAP = {
|
||||||
|
ROLE_REALM_OWNER: "Realm owner",
|
||||||
|
ROLE_REALM_ADMINISTRATOR: "Realm adminstrator",
|
||||||
|
ROLE_MEMBER: "Member",
|
||||||
|
ROLE_GUEST: "Guest"
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_role_name(self) -> str:
|
||||||
|
return self.ROLE_ID_TO_NAME_MAP[self.role]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def profile_data(self) -> ProfileData:
|
def profile_data(self) -> ProfileData:
|
||||||
values = CustomProfileFieldValue.objects.filter(user_profile=self)
|
values = CustomProfileFieldValue.objects.filter(user_profile=self)
|
||||||
|
|
Loading…
Reference in New Issue