-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Upgrading api list_course_role_members ( 2nd api ) (#35105)
* feat: upgrading simple api to drf compatible.
- Loading branch information
Showing
3 changed files
with
65 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" Instructor apis serializers. """ | ||
|
||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user | ||
from django.core.exceptions import ValidationError | ||
from django.utils.translation import gettext as _ | ||
from rest_framework import serializers | ||
|
||
from lms.djangoapps.instructor.access import ROLES | ||
|
||
|
||
class RoleNameSerializer(serializers.Serializer): # pylint: disable=abstract-method | ||
""" | ||
Serializer that describes the response of the problem response report generation API. | ||
""" | ||
|
||
rolename = serializers.CharField(help_text=_("Role name")) | ||
|
||
def validate_rolename(self, value): | ||
""" | ||
Check that the rolename is valid. | ||
""" | ||
if value not in ROLES: | ||
raise ValidationError(_("Invalid role name.")) | ||
return value | ||
|
||
|
||
class UserSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = ['username', 'email', 'first_name', 'last_name'] |