diff options
Diffstat (limited to 'pydis_site/apps/api')
| -rw-r--r-- | pydis_site/apps/api/migrations/0052_remove_user_avatar_hash.py | 17 | ||||
| -rw-r--r-- | pydis_site/apps/api/models/bot/user.py | 8 | ||||
| -rw-r--r-- | pydis_site/apps/api/serializers.py | 2 | ||||
| -rw-r--r-- | pydis_site/apps/api/tests/test_deleted_messages.py | 2 | ||||
| -rw-r--r-- | pydis_site/apps/api/tests/test_infractions.py | 7 | ||||
| -rw-r--r-- | pydis_site/apps/api/tests/test_models.py | 53 | ||||
| -rw-r--r-- | pydis_site/apps/api/tests/test_nominations.py | 2 | ||||
| -rw-r--r-- | pydis_site/apps/api/tests/test_reminders.py | 4 | ||||
| -rw-r--r-- | pydis_site/apps/api/tests/test_users.py | 8 | ||||
| -rw-r--r-- | pydis_site/apps/api/viewsets/bot/user.py | 5 | 
10 files changed, 52 insertions, 56 deletions
| diff --git a/pydis_site/apps/api/migrations/0052_remove_user_avatar_hash.py b/pydis_site/apps/api/migrations/0052_remove_user_avatar_hash.py new file mode 100644 index 00000000..26b3b954 --- /dev/null +++ b/pydis_site/apps/api/migrations/0052_remove_user_avatar_hash.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.11 on 2020-05-27 07:17 + +from django.db import migrations + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('api', '0051_create_news_setting'), +    ] + +    operations = [ +        migrations.RemoveField( +            model_name='user', +            name='avatar_hash', +        ), +    ] diff --git a/pydis_site/apps/api/models/bot/user.py b/pydis_site/apps/api/models/bot/user.py index 5140d2bf..65e8751e 100644 --- a/pydis_site/apps/api/models/bot/user.py +++ b/pydis_site/apps/api/models/bot/user.py @@ -31,14 +31,6 @@ class User(ModelReprMixin, models.Model):          ),          help_text="The discriminator of this user, taken from Discord."      ) -    avatar_hash = models.CharField( -        max_length=100, -        help_text=( -            "The user's avatar hash, taken from Discord. " -            "Null if the user does not have any custom avatar." -        ), -        null=True -    )      roles = models.ManyToManyField(          Role,          help_text="Any roles this user has on our server." diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py index e11c4af2..cc3f167d 100644 --- a/pydis_site/apps/api/serializers.py +++ b/pydis_site/apps/api/serializers.py @@ -235,7 +235,7 @@ class UserSerializer(BulkSerializerMixin, ModelSerializer):          """Metadata defined for the Django REST Framework."""          model = User -        fields = ('id', 'avatar_hash', 'name', 'discriminator', 'roles', 'in_guild') +        fields = ('id', 'name', 'discriminator', 'roles', 'in_guild')          depth = 1 diff --git a/pydis_site/apps/api/tests/test_deleted_messages.py b/pydis_site/apps/api/tests/test_deleted_messages.py index fb93cae6..f079a8dd 100644 --- a/pydis_site/apps/api/tests/test_deleted_messages.py +++ b/pydis_site/apps/api/tests/test_deleted_messages.py @@ -13,7 +13,6 @@ class DeletedMessagesWithoutActorTests(APISubdomainTestCase):              id=55,              name='Robbie Rotten',              discriminator=55, -            avatar_hash=None          )          cls.data = { @@ -54,7 +53,6 @@ class DeletedMessagesWithActorTests(APISubdomainTestCase):              id=12904,              name='Joe Armstrong',              discriminator=1245, -            avatar_hash=None          )          cls.data = { diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py index bc258b77..93ef8171 100644 --- a/pydis_site/apps/api/tests/test_infractions.py +++ b/pydis_site/apps/api/tests/test_infractions.py @@ -47,7 +47,6 @@ class InfractionTests(APISubdomainTestCase):              id=5,              name='james',              discriminator=1, -            avatar_hash=None          )          cls.ban_hidden = Infraction.objects.create(              user_id=cls.user.id, @@ -169,13 +168,11 @@ class CreationTests(APISubdomainTestCase):              id=5,              name='james',              discriminator=1, -            avatar_hash=None          )          cls.second_user = User.objects.create(              id=6,              name='carl',              discriminator=2, -            avatar_hash=None          )      def test_accepts_valid_data(self): @@ -522,7 +519,6 @@ class ExpandedTests(APISubdomainTestCase):              id=5,              name='james',              discriminator=1, -            avatar_hash=None          )          cls.kick = Infraction.objects.create(              user_id=cls.user.id, @@ -540,7 +536,7 @@ class ExpandedTests(APISubdomainTestCase):      def check_expanded_fields(self, infraction):          for key in ('user', 'actor'):              obj = infraction[key] -            for field in ('id', 'name', 'discriminator', 'avatar_hash', 'roles', 'in_guild'): +            for field in ('id', 'name', 'discriminator', 'roles', 'in_guild'):                  self.assertTrue(field in obj, msg=f'field "{field}" missing from {key}')      def test_list_expanded(self): @@ -599,7 +595,6 @@ class SerializerTests(APISubdomainTestCase):              id=5,              name='james',              discriminator=1, -            avatar_hash=None          )      def create_infraction(self, _type: str, active: bool): diff --git a/pydis_site/apps/api/tests/test_models.py b/pydis_site/apps/api/tests/test_models.py index a97d3251..b4754484 100644 --- a/pydis_site/apps/api/tests/test_models.py +++ b/pydis_site/apps/api/tests/test_models.py @@ -39,12 +39,14 @@ class StringDunderMethodTests(SimpleTestCase):          self.nomination = Nomination(              id=123,              actor=User( -                id=9876, name='Mr. Hemlock', -                discriminator=6666, avatar_hash=None +                id=9876, +                name='Mr. Hemlock', +                discriminator=6666,              ),              user=User( -                id=9876, name="Hemlock's Cat", -                discriminator=7777, avatar_hash=None +                id=9876, +                name="Hemlock's Cat", +                discriminator=7777,              ),              reason="He purrrrs like the best!",          ) @@ -53,15 +55,17 @@ class StringDunderMethodTests(SimpleTestCase):              DeletedMessage(                  id=45,                  author=User( -                    id=444, name='bill', -                    discriminator=5, avatar_hash=None +                    id=444, +                    name='bill', +                    discriminator=5,                  ),                  channel_id=666,                  content="wooey",                  deletion_context=MessageDeletionContext(                      actor=User( -                        id=5555, name='shawn', -                        discriminator=555, avatar_hash=None +                        id=5555, +                        name='shawn', +                        discriminator=555,                      ),                      creation=dt.utcnow()                  ), @@ -84,8 +88,9 @@ class StringDunderMethodTests(SimpleTestCase):              Message(                  id=45,                  author=User( -                    id=444, name='bill', -                    discriminator=5, avatar_hash=None +                    id=444, +                    name='bill', +                    discriminator=5,                  ),                  channel_id=666,                  content="wooey", @@ -93,8 +98,9 @@ class StringDunderMethodTests(SimpleTestCase):              ),              MessageDeletionContext(                  actor=User( -                    id=5555, name='shawn', -                    discriminator=555, avatar_hash=None +                    id=5555, +                    name='shawn', +                    discriminator=555,                  ),                  creation=dt.utcnow()              ), @@ -103,22 +109,29 @@ class StringDunderMethodTests(SimpleTestCase):                  embed={'content': "the builder"}              ),              User( -                id=5, name='bob', -                discriminator=1, avatar_hash=None +                id=5, +                name='bob', +                discriminator=1,              ),              Infraction( -                user_id=5, actor_id=5, -                type='kick', reason='He terk my jerb!' +                user_id=5, +                actor_id=5, +                type='kick', +                reason='He terk my jerb!'              ),              Infraction( -                user_id=5, actor_id=5, hidden=True, -                type='kick', reason='He terk my jerb!', +                user_id=5, +                actor_id=5, +                hidden=True, +                type='kick', +                reason='He terk my jerb!',                  expires_at=dt(5018, 11, 20, 15, 52, tzinfo=timezone.utc)              ),              Reminder(                  author=User( -                    id=452, name='billy', -                    discriminator=5, avatar_hash=None +                    id=452, +                    name='billy', +                    discriminator=5,                  ),                  channel_id=555,                  jump_url=( diff --git a/pydis_site/apps/api/tests/test_nominations.py b/pydis_site/apps/api/tests/test_nominations.py index 76cb4112..92c62c87 100644 --- a/pydis_site/apps/api/tests/test_nominations.py +++ b/pydis_site/apps/api/tests/test_nominations.py @@ -13,7 +13,6 @@ class CreationTests(APISubdomainTestCase):              id=1234,              name='joe dart',              discriminator=1111, -            avatar_hash=None          )      def test_accepts_valid_data(self): @@ -190,7 +189,6 @@ class NominationTests(APISubdomainTestCase):              id=1234,              name='joe dart',              discriminator=1111, -            avatar_hash=None          )          cls.active_nomination = Nomination.objects.create( diff --git a/pydis_site/apps/api/tests/test_reminders.py b/pydis_site/apps/api/tests/test_reminders.py index 3441e0cc..c7fa07c9 100644 --- a/pydis_site/apps/api/tests/test_reminders.py +++ b/pydis_site/apps/api/tests/test_reminders.py @@ -53,7 +53,6 @@ class ReminderCreationTests(APISubdomainTestCase):              id=1234,              name='Mermaid Man',              discriminator=1234, -            avatar_hash=None,          )      def test_accepts_valid_data(self): @@ -86,7 +85,6 @@ class ReminderDeletionTests(APISubdomainTestCase):              id=6789,              name='Barnacle Boy',              discriminator=6789, -            avatar_hash=None,          )          cls.reminder = Reminder.objects.create( @@ -118,7 +116,6 @@ class ReminderListTests(APISubdomainTestCase):              id=6789,              name='Patrick Star',              discriminator=6789, -            avatar_hash=None,          )          cls.reminder_one = Reminder.objects.create( @@ -172,7 +169,6 @@ class ReminderUpdateTests(APISubdomainTestCase):              id=666,              name='Man Ray',              discriminator=666, -            avatar_hash=None,          )          cls.reminder = Reminder.objects.create( diff --git a/pydis_site/apps/api/tests/test_users.py b/pydis_site/apps/api/tests/test_users.py index 86799f19..4f563dc6 100644 --- a/pydis_site/apps/api/tests/test_users.py +++ b/pydis_site/apps/api/tests/test_users.py @@ -49,7 +49,6 @@ class CreationTests(APISubdomainTestCase):          url = reverse('bot:user-list', host='api')          data = {              'id': 42, -            'avatar_hash': "validavatarhashiswear",              'name': "Test",              'discriminator': 42,              'roles': [ @@ -63,7 +62,6 @@ class CreationTests(APISubdomainTestCase):          self.assertEqual(response.json(), data)          user = User.objects.get(id=42) -        self.assertEqual(user.avatar_hash, data['avatar_hash'])          self.assertEqual(user.name, data['name'])          self.assertEqual(user.discriminator, data['discriminator'])          self.assertEqual(user.in_guild, data['in_guild']) @@ -73,7 +71,6 @@ class CreationTests(APISubdomainTestCase):          data = [              {                  'id': 5, -                'avatar_hash': "hahayes",                  'name': "test man",                  'discriminator': 42,                  'roles': [ @@ -83,7 +80,6 @@ class CreationTests(APISubdomainTestCase):              },              {                  'id': 8, -                'avatar_hash': "maybenot",                  'name': "another test man",                  'discriminator': 555,                  'roles': [], @@ -99,7 +95,6 @@ class CreationTests(APISubdomainTestCase):          url = reverse('bot:user-list', host='api')          data = {              'id': 5, -            'avatar_hash': "hahayes",              'name': "test man",              'discriminator': 42,              'roles': [ @@ -114,7 +109,6 @@ class CreationTests(APISubdomainTestCase):          url = reverse('bot:user-list', host='api')          data = {              'id': True, -            'avatar_hash': 1902831,              'discriminator': "totally!"          } @@ -148,7 +142,6 @@ class UserModelTests(APISubdomainTestCase):          )          cls.user_with_roles = User.objects.create(              id=1, -            avatar_hash="coolavatarhash",              name="Test User with two roles",              discriminator=1111,              in_guild=True, @@ -157,7 +150,6 @@ class UserModelTests(APISubdomainTestCase):          cls.user_without_roles = User.objects.create(              id=2, -            avatar_hash="coolavatarhash",              name="Test User without roles",              discriminator=2222,              in_guild=True, diff --git a/pydis_site/apps/api/viewsets/bot/user.py b/pydis_site/apps/api/viewsets/bot/user.py index a407787e..8f5bccfa 100644 --- a/pydis_site/apps/api/viewsets/bot/user.py +++ b/pydis_site/apps/api/viewsets/bot/user.py @@ -17,7 +17,6 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet):      >>> [      ...     {      ...         'id': 409107086526644234, -    ...         'avatar': "3ba3c1acce584c20b1e96fc04bbe80eb",      ...         'name': "Python",      ...         'discriminator': 4329,      ...         'roles': [ @@ -39,7 +38,6 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet):      #### Response format      >>> {      ...     'id': 409107086526644234, -    ...     'avatar': "3ba3c1acce584c20b1e96fc04bbe80eb",      ...     'name': "Python",      ...     'discriminator': 4329,      ...     'roles': [ @@ -62,7 +60,6 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet):      #### Request body      >>> {      ...     'id': int, -    ...     'avatar': str,      ...     'name': str,      ...     'discriminator': int,      ...     'roles': List[int], @@ -83,7 +80,6 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet):      #### Request body      >>> {      ...     'id': int, -    ...     'avatar': str,      ...     'name': str,      ...     'discriminator': int,      ...     'roles': List[int], @@ -102,7 +98,6 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet):      #### Request body      >>> {      ...     'id': int, -    ...     'avatar': str,      ...     'name': str,      ...     'discriminator': int,      ...     'roles': List[int], | 
