Skip to content

Commit

Permalink
fix: Fix empty name bug in Game (#1550)
Browse files Browse the repository at this point in the history
* fix: Fix empty name bug in Game model

* Merge branch 'development' into fix_admin_pages

* Merge branch 'development' into fix_admin_pages
  • Loading branch information
faucomte97 committed Jul 7, 2021
1 parent 500fc00 commit a57db88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions aimmo/admin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from __future__ import absolute_import

import uuid

from django.contrib import admin

from .models import Avatar, Game, User, Worksheet
from .models import Avatar, Game, Worksheet


class GameDataAdmin(admin.ModelAdmin):
search_fields = ["id", "name", "owner__username", "owner__email"]
list_display = ["id", "name", "owner"]
search_fields = ["id", "owner__username", "owner__email"]
list_display = ["id", "owner", "game_class", "school", "worksheet", "status"]
raw_id_fields = ["owner", "main_user", "can_play", "game_class"]
readonly_fields = ["players", "auth_token"]

Expand All @@ -20,17 +18,20 @@ def players(self, obj):
players = players.join(obj.game_class.teacher.new_user.first_name)
return players

def school(self, obj):
return obj.game_class.teacher.school


class AvatarDataAdmin(admin.ModelAdmin):
search_fields = ["owner__username", "owner__email"]
list_display = ["id", "owner_name", "game_name"]
list_display = ["id", "owner_name", "game_id"]
raw_id_fields = ["game"]
readonly_fields = ["owner", "auth_token"]

def owner_name(self, obj):
return obj.owner

def game_name(self, obj):
def game_id(self, obj):
return obj.game


Expand Down
2 changes: 1 addition & 1 deletion aimmo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def is_active(self):
return not self.completed

def __str__(self):
return self.name
return str(self.id)

def can_user_play(self, user: User) -> bool:
"""Checks whether the given user has permission to play the game.
Expand Down

0 comments on commit a57db88

Please sign in to comment.