blob: c457f42a8333941fb8991ce7d0a1c0989ef9a038 [file] [log] [blame]
Mitja Nikolausa9017982018-11-21 12:14:45 +01001"""Permissions for accessing the stats API."""
2from django.core.exceptions import PermissionDenied
3
4from crashreports.permissions import user_is_hiccup_staff
5from hiccup.allauth_adapters import FP_STAFF_GROUP_NAME
6
7
8def check_user_is_hiccup_staff(user):
9 """Check if the user is part of the Hiccup staff.
10
11 Returns: True if the user is part of the Hiccup staff group.
12
13 Raises:
14 PermissionDenied: If the user is not part of the Hiccup staff group.
15
16 """
17 if not user_is_hiccup_staff(user):
18 raise PermissionDenied(
19 "User %s not part of the %s group" % (user, FP_STAFF_GROUP_NAME)
20 )
21 return True