Skip to content

Commit

Permalink
Merge pull request #40 from AUTGamecraft/refurbish
Browse files Browse the repository at this point in the history
Refurbish
  • Loading branch information
Javad-Ak authored Oct 16, 2024
2 parents 992e6f9 + b75396f commit af77123
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion game/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,23 @@ def export_games(self, request, queryset):
else:
return ExcelResponse(data=data, worksheet_name="games", output_filename="games")

actions = ['export_games']
def export_likes(self, request, queryset):
data = []
headers = ['game', 'liker name', 'liker phone No', 'liker email', 'timestamp']
data.append(headers)

for game in queryset.all():
for like in game.likes.all():
data.append([game.title, like.user.first_name, like.user.phone_number, like.user.email, like.timestamp])

if not data:
return JsonResponse({"message": "Nothing Found"})
else:
return ExcelResponse(data=data, worksheet_name="likes", output_filename="games")

actions = ['export_likes', 'export_games']
export_games.short_description = 'Export Games'
export_likes.short_description = 'Export Likes'
actions_on_top = True

search_fields = ("title", "team")
Expand Down

0 comments on commit af77123

Please sign in to comment.