Add tests for #310
parent
c593b3fcfb
commit
b4900ebd6a
|
|
@ -20,6 +20,7 @@ class Article(models.Model):
|
|||
on_delete=models.PROTECT)
|
||||
original_group = models.ForeignKey('ArticleGroup', related_name='articles_as_original', blank=True, default=None,
|
||||
on_delete=models.PROTECT)
|
||||
read_only_nullable = models.CharField(max_length=20, null=True, blank=True)
|
||||
|
||||
|
||||
class ArticleGroup(models.Model):
|
||||
|
|
|
|||
|
|
@ -17,10 +17,9 @@ class ArticleSerializer(serializers.ModelSerializer):
|
|||
|
||||
class Meta:
|
||||
model = Article
|
||||
fields = ('title', 'author', 'body', 'slug', 'date_created', 'date_modified',
|
||||
fields = ('title', 'author', 'body', 'slug', 'date_created', 'date_modified', 'read_only_nullable',
|
||||
'references', 'uuid', 'cover', 'cover_name', 'article_type', 'group', 'original_group', )
|
||||
read_only_fields = ('date_created', 'date_modified',
|
||||
'references', 'uuid', 'cover_name')
|
||||
read_only_fields = ('date_created', 'date_modified', 'references', 'uuid', 'cover_name', 'read_only_nullable')
|
||||
lookup_field = 'slug'
|
||||
extra_kwargs = {
|
||||
'body': {'help_text': 'body serializer help_text'},
|
||||
|
|
@ -29,6 +28,7 @@ class ArticleSerializer(serializers.ModelSerializer):
|
|||
'help_text': _("The ID of the user that created this article; if none is provided, "
|
||||
"defaults to the currently logged in user.")
|
||||
},
|
||||
'read_only_nullable': {'allow_null': True},
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from snippets.models import LANGUAGE_CHOICES, STYLE_CHOICES, Snippet
|
|||
class LanguageSerializer(serializers.Serializer):
|
||||
name = serializers.ChoiceField(
|
||||
choices=LANGUAGE_CHOICES, default='python', help_text='The name of the programming language')
|
||||
read_only_nullable = serializers.CharField(read_only=True, allow_null=True)
|
||||
|
||||
class Meta:
|
||||
ref_name = None
|
||||
|
|
|
|||
|
|
@ -902,6 +902,11 @@ definitions:
|
|||
type: string
|
||||
format: date-time
|
||||
readOnly: true
|
||||
read_only_nullable:
|
||||
type: string
|
||||
readOnly: true
|
||||
minLength: 1
|
||||
x-nullable: true
|
||||
references:
|
||||
description: this is a really bad example
|
||||
type: object
|
||||
|
|
@ -1515,6 +1520,12 @@ definitions:
|
|||
- yaml+jinja
|
||||
- zephir
|
||||
default: python
|
||||
readOnlyNullable:
|
||||
title: Read only nullable
|
||||
type: string
|
||||
readOnly: true
|
||||
minLength: 1
|
||||
x-nullable: true
|
||||
styles:
|
||||
type: array
|
||||
items:
|
||||
|
|
|
|||
Loading…
Reference in New Issue