Skip to content

Commit

Permalink
[Chore] Norm the backend code using pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarm committed Apr 25, 2024
1 parent d94094c commit 1d25849
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 46 deletions.
6 changes: 3 additions & 3 deletions app/back-end/game/asgi.py
Original file line number Diff line number Diff line change
@@ -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,
})
})
9 changes: 5 additions & 4 deletions app/back-end/game/consumers.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion app/back-end/game/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
application = ProtocolTypeRouter({
"http": get_asgi_application(),
"websocket": URLRouter(websocket_urlpatterns),
})
})
3 changes: 1 addition & 2 deletions app/back-end/game/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from django.test import TestCase

# from django.test import TestCase
# Create your tests here.
4 changes: 1 addition & 3 deletions app/back-end/game/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
urlpatterns = [

]
urlpatterns = []
2 changes: 0 additions & 2 deletions app/back-end/game/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.shortcuts import render

# Create your views here.
46 changes: 15 additions & 31 deletions app/back-end/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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'
Expand All @@ -101,4 +85,4 @@ class Users(models.Model):

class Meta:
managed = False
db_table = 'Users'
db_table = 'Users'

0 comments on commit 1d25849

Please sign in to comment.