From f7ae5cb8a807918a1d3fcd10c77bd97f57b922bb Mon Sep 17 00:00:00 2001 From: lladdy Date: Mon, 14 Feb 2022 19:59:33 +1030 Subject: [PATCH 1/2] Fix typo in README --- doc/INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/INSTALL.md b/doc/INSTALL.md index bfa66cfd..5bfbb7a6 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -33,7 +33,7 @@ 5. Modify the Website config to use your Database. - If you are using a standard mysql setup at localhost:3306 and step 2's SQL script, then you can skip this step - + If you are using a standard mysql setup at localhost:3306 and step 3's SQL script, then you can skip this step - the credentials will already be configured. If you need to configure different credentials, make a copy of the `/aiarena/example-dev-env.py` file as `/aiarena/env.py` and update the relevant details From faabc368c5c07fb9be95d4970b0c5951a7ebe13e Mon Sep 17 00:00:00 2001 From: lladdy Date: Mon, 14 Feb 2022 21:02:19 +1030 Subject: [PATCH 2/2] Add page for displaying downloadable bots. --- aiarena/frontend/templates/bots.html | 3 + .../frontend/templates/bots_downloadable.html | 55 +++++++++++++++++++ aiarena/frontend/views.py | 17 ++++++ aiarena/urls.py | 1 + 4 files changed, 76 insertions(+) create mode 100644 aiarena/frontend/templates/bots_downloadable.html diff --git a/aiarena/frontend/templates/bots.html b/aiarena/frontend/templates/bots.html index 1fb97568..1fc5e01a 100644 --- a/aiarena/frontend/templates/bots.html +++ b/aiarena/frontend/templates/bots.html @@ -4,6 +4,9 @@ {% block content %}

Bots

+

+ Display only downloadable +

diff --git a/aiarena/frontend/templates/bots_downloadable.html b/aiarena/frontend/templates/bots_downloadable.html new file mode 100644 index 00000000..a7906bcc --- /dev/null +++ b/aiarena/frontend/templates/bots_downloadable.html @@ -0,0 +1,55 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} + +

Bots

+

+ Display all bots +

+
Name
+ + + + + + + + {% for bot in bot_list %} + + + + + + + {% endfor %} + +
NameAuthorRaceType
{{ bot.as_html_link }}{{ bot.user.as_html_link }}{{ bot.get_plays_race_display }}{{ bot.type }}
+ + +{% endblock %} diff --git a/aiarena/frontend/views.py b/aiarena/frontend/views.py index 4d54b73e..5fa233ec 100644 --- a/aiarena/frontend/views.py +++ b/aiarena/frontend/views.py @@ -229,6 +229,23 @@ def get_context_data(self, **kwargs): return context +class BotDownloadableList(ListView): + queryset = Bot.objects.filter(bot_zip_publicly_downloadable=True)\ + .only('name', 'plays_race', 'type', 'user__username', 'user__type')\ + .select_related('user').order_by('name') + template_name = 'bots_downloadable.html' + paginate_by = 50 + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + + # add the page ranges + page_obj = context['page_obj'] + context['page_range'] = restrict_page_range(page_obj.paginator.num_pages, page_obj.number) + + return context + + class FileURLColumn(tables.URLColumn): """File URLs are incorrect without this""" def get_url(self, value): diff --git a/aiarena/urls.py b/aiarena/urls.py index 50d7c7c5..3f929d7c 100644 --- a/aiarena/urls.py +++ b/aiarena/urls.py @@ -63,6 +63,7 @@ path('stream/', TemplateView.as_view(template_name='stream.html'), name='stream'), path('bots/', core_views.BotList.as_view(), name='bots'), + path('bots/downloadable/', core_views.BotDownloadableList.as_view(), name='bots_downloadable'), path('bots//', core_views.BotDetail.as_view(), name='bot'), path('bots//edit/', core_views.BotUpdate.as_view(), name='bot_edit'), path('bots//bot_zip', core_views.BotZipDownloadView.as_view()),