-
-
Notifications
You must be signed in to change notification settings - Fork 223
[feature] Added API endpoint to manage RADIUS groups of users #676 #680
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
Changes from 9 commits
ae566dc
15b1d88
e167698
50572dc
93a8027
0aabd61
b6cf697
81714c6
33f5548
783bf35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -365,6 +365,42 @@ def validate(self, data): | |
| return data | ||
|
|
||
|
|
||
| class RadiusUserGroupSerializer(FilterSerializerByOrgManaged, ValidatedModelSerializer): | ||
| class Meta: | ||
| model = RadiusUserGroup | ||
| fields = ("id", "group", "priority", "created", "modified") | ||
| read_only_fields = ("id", "created", "modified") | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| view = self.context.get("view") | ||
| if ( | ||
| view | ||
| and getattr(view, "get_parent_queryset", None) | ||
| and not getattr(view, "swagger_fake_view", False) | ||
| ): | ||
| self._user = view.get_parent_queryset().first() | ||
| else: | ||
| self._user = None | ||
| if self._user and view and getattr(view.request, "user", None): | ||
| orgs = view.request.user.organizations_managed | ||
| self.fields["group"].queryset = ( | ||
| self.fields["group"] | ||
| .queryset.filter(organization__in=orgs) | ||
| .filter(organization__in=self._user.organizations_dict.keys()) | ||
|
||
| ) | ||
| else: | ||
| self.fields["group"].queryset = self.fields["group"].queryset.none() | ||
|
|
||
| def validate(self, data): | ||
| if self._user: | ||
| if "username" not in data: | ||
| data["username"] = self._user.username | ||
| if "user" not in data: | ||
| data["user"] = self._user | ||
nemesifier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return super().validate(data) | ||
|
|
||
|
|
||
| class GroupSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = Group | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.