From 0766dab8306d24b22550e1a4a054ff3f2956a0b1 Mon Sep 17 00:00:00 2001 From: Hasan-Ahmad Date: Mon, 22 Oct 2018 11:22:48 +0100 Subject: Added special snakes api --- api/tests/test_models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'api/tests/test_models.py') diff --git a/api/tests/test_models.py b/api/tests/test_models.py index af2ef5d5..009e5bd4 100644 --- a/api/tests/test_models.py +++ b/api/tests/test_models.py @@ -4,7 +4,8 @@ from ..models import ( DocumentationLink, Member, ModelReprMixin, OffTopicChannelName, Role, SnakeFact, SnakeIdiom, - SnakeName, Tag + SnakeName, SpecialSnake, + Tag ) @@ -32,6 +33,7 @@ class StringDunderMethodTests(SimpleTestCase): SnakeFact(fact='snakes are cute'), SnakeIdiom(idiom='snake snacks'), SnakeName(name='python', scientific='3'), + SpecialSnake(name='Pythagoras Pythonista', info='The only python snake that is born a triangle'), Role( id=5, name='test role', colour=0x5, permissions=0 -- cgit v1.2.3 From 43df5d0fcfa66018fd0bb47bff848d42fcf1e76c Mon Sep 17 00:00:00 2001 From: Hasan-Ahmad Date: Thu, 25 Oct 2018 09:55:25 +0100 Subject: Fixed linting --- api/admin.py | 6 +++--- api/tests/test_models.py | 3 ++- api/urls.py | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'api/tests/test_models.py') diff --git a/api/admin.py b/api/admin.py index 13ba2db0..b06cc939 100644 --- a/api/admin.py +++ b/api/admin.py @@ -2,9 +2,9 @@ from django.contrib import admin from .models import ( DocumentationLink, Member, - OffTopicChannelName, Role, - SpecialSnake, SnakeFact, - SnakeIdiom, SnakeName, + OffTopicChannelName, Role, + SnakeFact, SnakeIdiom, + SnakeName, SpecialSnake, Tag ) diff --git a/api/tests/test_models.py b/api/tests/test_models.py index 009e5bd4..7dea68b5 100644 --- a/api/tests/test_models.py +++ b/api/tests/test_models.py @@ -33,7 +33,8 @@ class StringDunderMethodTests(SimpleTestCase): SnakeFact(fact='snakes are cute'), SnakeIdiom(idiom='snake snacks'), SnakeName(name='python', scientific='3'), - SpecialSnake(name='Pythagoras Pythonista', info='The only python snake that is born a triangle'), + SpecialSnake(name='Pythagoras Pythonista', + info='The only python snake that is born a triangle'), Role( id=5, name='test role', colour=0x5, permissions=0 diff --git a/api/urls.py b/api/urls.py index c90c1a14..63802858 100644 --- a/api/urls.py +++ b/api/urls.py @@ -4,9 +4,10 @@ from rest_framework.routers import DefaultRouter from .views import HealthcheckView from .viewsets import ( DocumentationLinkViewSet, MemberViewSet, - OffTopicChannelNameViewSet, SpecialSnakeViewSet, + OffTopicChannelNameViewSet, SnakeFactViewSet, SnakeIdiomViewSet, - SnakeNameViewSet, TagViewSet + SnakeNameViewSet, SpecialSnakeViewSet, + TagViewSet ) -- cgit v1.2.3 From aebf48cff6e41eb6d8dde695b10380da4e57d733 Mon Sep 17 00:00:00 2001 From: Hasan-Ahmad Date: Thu, 25 Oct 2018 21:02:42 +0100 Subject: code presentasion and help text on models --- api/migrations/0014_auto_20181025_1959.py | 23 +++++++++++++++++++++++ api/models.py | 12 ++++++++---- api/tests/test_models.py | 3 ++- api/viewsets.py | 11 ++++++----- 4 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 api/migrations/0014_auto_20181025_1959.py (limited to 'api/tests/test_models.py') 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 -- cgit v1.2.3 From f23a563218c9f03a19cb957d6769c730bfbecb4f Mon Sep 17 00:00:00 2001 From: Hasan-Ahmad Date: Thu, 25 Oct 2018 21:08:50 +0100 Subject: Fixed linting --- api/tests/test_models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'api/tests/test_models.py') diff --git a/api/tests/test_models.py b/api/tests/test_models.py index a1561a07..91db2def 100644 --- a/api/tests/test_models.py +++ b/api/tests/test_models.py @@ -33,8 +33,9 @@ class StringDunderMethodTests(SimpleTestCase): SnakeFact(fact='snakes are cute'), SnakeIdiom(idiom='snake snacks'), SnakeName(name='python', scientific='3'), - SpecialSnake(name='Pythagoras Pythonista', - info='The only python snake that is born a triangle' + SpecialSnake( + name='Pythagoras Pythonista', + info='The only python snake that is born a triangle' ), Role( id=5, name='test role', -- cgit v1.2.3