From 1d25849f04b214b8f624ef381ad1745935400c9e Mon Sep 17 00:00:00 2001 From: zakarm Date: Thu, 25 Apr 2024 12:09:21 +0100 Subject: [PATCH] [Chore] Norm the backend code using pylint --- app/back-end/game/asgi.py | 6 ++--- app/back-end/game/consumers.py | 9 ++++--- app/back-end/game/routing.py | 2 +- app/back-end/game/tests.py | 3 +-- app/back-end/game/urls.py | 4 +-- app/back-end/game/views.py | 2 -- app/back-end/models.py | 46 +++++++++++----------------------- 7 files changed, 26 insertions(+), 46 deletions(-) diff --git a/app/back-end/game/asgi.py b/app/back-end/game/asgi.py index eab12922..8d5b6ba4 100644 --- a/app/back-end/game/asgi.py +++ b/app/back-end/game/asgi.py @@ -1,10 +1,10 @@ -import os +# import os from django.core.asgi import get_asgi_application from channels.routing import ProtocolTypeRouter -from game.routing import application, websocket_urlpatterns +from game.routing import websocket_urlpatterns application = ProtocolTypeRouter({ "http": get_asgi_application(), "websocket": websocket_urlpatterns, -}) \ No newline at end of file +}) diff --git a/app/back-end/game/consumers.py b/app/back-end/game/consumers.py index 325a815f..e59bde03 100644 --- a/app/back-end/game/consumers.py +++ b/app/back-end/game/consumers.py @@ -1,8 +1,9 @@ +# from rest_framework_simplejwt.exceptions import InvalidToken, TokenError +# from rest_framework_simplejwt.tokens import UntypedToken +# from urllib.parse import parse_qs +import sys +import json from channels.generic.websocket import AsyncWebsocketConsumer -from rest_framework_simplejwt.tokens import UntypedToken -from rest_framework_simplejwt.exceptions import InvalidToken, TokenError -import json, sys -from urllib.parse import parse_qs class AsyncConsumer(AsyncWebsocketConsumer): async def connect(self): diff --git a/app/back-end/game/routing.py b/app/back-end/game/routing.py index e1a6615e..8713d336 100644 --- a/app/back-end/game/routing.py +++ b/app/back-end/game/routing.py @@ -10,4 +10,4 @@ application = ProtocolTypeRouter({ "http": get_asgi_application(), "websocket": URLRouter(websocket_urlpatterns), -}) \ No newline at end of file +}) diff --git a/app/back-end/game/tests.py b/app/back-end/game/tests.py index 7ce503c2..601fc861 100644 --- a/app/back-end/game/tests.py +++ b/app/back-end/game/tests.py @@ -1,3 +1,2 @@ -from django.test import TestCase - +# from django.test import TestCase # Create your tests here. diff --git a/app/back-end/game/urls.py b/app/back-end/game/urls.py index 0c3c48b4..637600f5 100644 --- a/app/back-end/game/urls.py +++ b/app/back-end/game/urls.py @@ -1,3 +1 @@ -urlpatterns = [ - -] +urlpatterns = [] diff --git a/app/back-end/game/views.py b/app/back-end/game/views.py index 91ea44a2..60f00ef0 100644 --- a/app/back-end/game/views.py +++ b/app/back-end/game/views.py @@ -1,3 +1 @@ -from django.shortcuts import render - # Create your views here. diff --git a/app/back-end/models.py b/app/back-end/models.py index 0df96e87..5dc2fd39 100644 --- a/app/back-end/models.py +++ b/app/back-end/models.py @@ -12,8 +12,11 @@ class Meta: class Friendship(models.Model): freindship_id = models.AutoField(primary_key=True) - user_from = models.ForeignKey('Users', models.DO_NOTHING, db_column='user_from') - user_to = models.ForeignKey('Users', models.DO_NOTHING, db_column='user_to', related_name='friendship_user_to_set') + user_from = models.ForeignKey('Users', models.DO_NOTHING, + db_column='user_from') + user_to = models.ForeignKey('Users', models.DO_NOTHING, + db_column='user_to', + related_name='friendship_user_to_set') is_accepted = models.BooleanField() class Meta: managed = False @@ -23,7 +26,9 @@ class Meta: class Matches(models.Model): match_id = models.AutoField(primary_key=True) user_one = models.ForeignKey('Users', models.DO_NOTHING, db_column='user_one') - user_two = models.ForeignKey('Users', models.DO_NOTHING, db_column='user_two', related_name='matches_user_two_set') + user_two = models.ForeignKey('Users', models.DO_NOTHING, + db_column='user_two', + related_name='matches_user_two_set') score_user_one = models.IntegerField() score_user_two = models.IntegerField() match_start = models.DateField() @@ -37,8 +42,11 @@ class Meta: class Messages(models.Model): - user_one = models.OneToOneField('Users', models.DO_NOTHING, db_column='user_one', primary_key=True) # The composite primary key (user_one, user_two) found, that is not supported. The first column is selected. - user_two = models.ForeignKey('Users', models.DO_NOTHING, db_column='user_two', related_name='messages_user_two_set') + user_one = models.OneToOneField('Users', models.DO_NOTHING, + db_column='user_one', primary_key=True) + user_two = models.ForeignKey('Users', models.DO_NOTHING, + db_column='user_two', + related_name='messages_user_two_set') message_content = models.CharField(max_length=512) message_date = models.DateField() message_direction = models.CharField(max_length=20) @@ -48,34 +56,10 @@ class Meta: db_table = 'Messages' unique_together = (('user_one', 'user_two'),) - -class Tournaments(models.Model): - tournament_id = models.AutoField(primary_key=True) - tournament_name = models.CharField(max_length=30) - tournament_start = models.DateField() - tournament_end = models.DateField() - - class Meta: - managed = False - db_table = 'Tournaments' - - -class Tournamentsmatches(models.Model): - tournament = models.OneToOneField(Tournaments, models.DO_NOTHING, primary_key=True) # The composite primary key (tournament_id, match_id) found, that is not supported. The first column is selected. - match = models.ForeignKey(Matches, models.DO_NOTHING) - tournament_round = models.CharField(max_length=30) - - class Meta: - managed = False - db_table = 'TournamentsMatches' - unique_together = (('tournament', 'match'),) - - class Userachievements(models.Model): - user = models.OneToOneField('Users', models.DO_NOTHING, primary_key=True) # The composite primary key (user_id, achivement_id) found, that is not supported. The first column is selected. + user = models.OneToOneField('Users', models.DO_NOTHING, primary_key=True) achivement = models.ForeignKey(Achievements, models.DO_NOTHING) achive_date = models.DateField() - class Meta: managed = False db_table = 'UserAchievements' @@ -101,4 +85,4 @@ class Users(models.Model): class Meta: managed = False - db_table = 'Users' \ No newline at end of file + db_table = 'Users'