diff options
author | 2018-10-25 21:02:42 +0100 | |
---|---|---|
committer | 2018-10-25 21:02:42 +0100 | |
commit | aebf48cff6e41eb6d8dde695b10380da4e57d733 (patch) | |
tree | a58f23912a501a09ce890e9a5983bebd48b545e0 /api | |
parent | Fixed linting (diff) |
code presentasion and help text on models
Diffstat (limited to 'api')
-rw-r--r-- | api/migrations/0014_auto_20181025_1959.py | 23 | ||||
-rw-r--r-- | api/models.py | 12 | ||||
-rw-r--r-- | api/tests/test_models.py | 3 | ||||
-rw-r--r-- | api/viewsets.py | 11 |
4 files changed, 39 insertions, 10 deletions
diff --git a/api/migrations/0014_auto_20181025_1959.py b/api/migrations/0014_auto_20181025_1959.py new file mode 100644 index 00000000..3599d2cd --- /dev/null +++ b/api/migrations/0014_auto_20181025_1959.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.2 on 2018-10-25 19:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0013_specialsnake_image'), + ] + + operations = [ + migrations.AlterField( + model_name='specialsnake', + name='info', + field=models.TextField(help_text='Info about a special snake.'), + ), + migrations.AlterField( + model_name='specialsnake', + name='name', + field=models.CharField(help_text='A special snake name.', max_length=140, primary_key=True, serialize=False), + ), + ] diff --git a/api/models.py b/api/models.py index 2ba50adf..eb9c2e16 100644 --- a/api/models.py +++ b/api/models.py @@ -104,12 +104,16 @@ class SnakeName(ModelReprMixin, models.Model): class SpecialSnake(ModelReprMixin, models.Model): - """A special snake used by the bot's snake cog.""" + """A special snake's name, info and image from our database used by the bot's snake cog.""" name = models.CharField( - max_length=140, primary_key=True - ) - info = models.TextField() + max_length=140, + primary_key=True, + help_text='A special snake name.' + ) + info = models.TextField( + help_text='Info about a special snake.' + ) image = models.URLField() def __str__(self): diff --git a/api/tests/test_models.py b/api/tests/test_models.py index 7dea68b5..a1561a07 100644 --- a/api/tests/test_models.py +++ b/api/tests/test_models.py @@ -34,7 +34,8 @@ class StringDunderMethodTests(SimpleTestCase): SnakeIdiom(idiom='snake snacks'), SnakeName(name='python', scientific='3'), SpecialSnake(name='Pythagoras Pythonista', - info='The only python snake that is born a triangle'), + info='The only python snake that is born a triangle' + ), Role( id=5, name='test role', colour=0x5, permissions=0 diff --git a/api/viewsets.py b/api/viewsets.py index 70fc96f8..08660810 100644 --- a/api/viewsets.py +++ b/api/viewsets.py @@ -20,7 +20,8 @@ from .serializers import ( DocumentationLinkSerializer, MemberSerializer, OffTopicChannelNameSerializer, SnakeFactSerializer, SnakeIdiomSerializer, - SnakeNameSerializer, SpecialSnakeSerializer, TagSerializer + SnakeNameSerializer, SpecialSnakeSerializer, + TagSerializer ) @@ -294,10 +295,10 @@ class SpecialSnakeViewSet(ListModelMixin, GenericViewSet): #### Response Format >>> [ ... { - ... 'name':'Snakky sneakatus', - ... 'info':'Scary snek', - ... 'image':'https://discordapp.com/assets/53ef346458017da2062aca5c7955946b.svg' - ... }, + ... 'name': 'Snakky sneakatus', + ... 'info': 'Scary snek', + ... 'image': 'https://discordapp.com/assets/53ef346458017da2062aca5c7955946b.svg' + ... } ... ] #### Status codes |