|
4 | 4 |
|
5 | 5 | from django.db import IntegrityError, transaction |
6 | 6 | from django.db.models import Q |
| 7 | +from django.utils.translation import ugettext_lazy as _ |
7 | 8 | from rest_framework import serializers, status |
8 | 9 | from rest_framework.response import Response |
9 | 10 |
|
@@ -46,7 +47,15 @@ def __init__(self): |
46 | 47 |
|
47 | 48 | class TeamSerializer(serializers.Serializer): |
48 | 49 | name = serializers.CharField(max_length=64, required=False) |
49 | | - slug = serializers.RegexField(r'^[a-z0-9_\-]+$', max_length=50, required=False) |
| 50 | + slug = serializers.RegexField( |
| 51 | + r'^[a-z0-9_\-]+$', |
| 52 | + max_length=50, |
| 53 | + required=False, |
| 54 | + error_messages={ |
| 55 | + 'invalid': _('Enter a valid slug consisting of lowercase letters, ' |
| 56 | + 'numbers, underscores or hyphens.'), |
| 57 | + }, |
| 58 | + ) |
50 | 59 |
|
51 | 60 | def validate(self, attrs): |
52 | 61 | if not (attrs.get('name') or attrs.get('slug')): |
@@ -109,8 +118,8 @@ def post(self, request, organization): |
109 | 118 |
|
110 | 119 | :pparam string organization_slug: the slug of the organization the |
111 | 120 | team should be created for. |
112 | | - :param string name: the name of the organization. |
113 | | - :param string slug: the optional slug for this organization. If |
| 121 | + :param string name: the optional name of the team. |
| 122 | + :param string slug: the optional slug for this team. If |
114 | 123 | not provided it will be auto generated from the |
115 | 124 | name. |
116 | 125 | :auth: required |
|
0 commit comments