Skip to content

Commit

Permalink
Merge pull request #341 from aiarena/staging
Browse files Browse the repository at this point in the history
Release v1.6.3
  • Loading branch information
lladdy authored Feb 14, 2022
2 parents 99397bf + faabc36 commit ebd1f90
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
3 changes: 3 additions & 0 deletions aiarena/frontend/templates/bots.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{% block content %}

<div class="divider"><span></span><span><h2>Bots</h2></span><span></span></div>
<h3 style="float: right; margin-right: 75px;">
<a href="{% url 'bots_downloadable'%}">Display only downloadable</a>
</h3>
<table summary="Table containing bots information" id="botsTable" class="row-hover-highlight">
<thead>
<td><strong>Name</strong></td>
Expand Down
55 changes: 55 additions & 0 deletions aiarena/frontend/templates/bots_downloadable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{% extends "base.html" %}
{% load i18n %}

{% block content %}

<div class="divider"><span></span><span><h2>Bots</h2></span><span></span></div>
<h3 style="float: right; margin-right: 75px;">
<a href="{% url 'bots'%}">Display all bots</a>
</h3>
<table summary="Table containing bots information" id="botsTable" class="row-hover-highlight">
<thead>
<td><strong>Name</strong></td>
<td><strong>Author</strong></td>
<td><strong>Race</strong></td>
<td><strong>Type</strong></td>
</thead>
<tbody>
{% for bot in bot_list %}
<tr>
<td>{{ bot.as_html_link }}</td>
<td>{{ bot.user.as_html_link }}</td>
<td>{{ bot.get_plays_race_display }}</td>
<td>{{ bot.type }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="pagination">
{% if is_paginated %}
<ul class="pagination">
{% if page_obj.has_previous %}
<li>
<a href="?page={{ bot_list.page_obj }}">&laquo;</a>
</li>
{% else %}
<li class="disabled"><span>&laquo;</span></li>
{% endif %}
{% for page_num in page_range %}
{% if page_obj.number == page_num %}
<li class="active"><span>{{ page_num }}</span></li>
{% else %}
<li><a href="?page={{ page_num }}">{{ page_num }}</a></li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li><a href="?page={{ page_obj.next_page_number }}">&raquo;</a>
</li>
{% else %}
<li class="disabled"><span>&raquo;</span></li>
{% endif %}
</ul>
{% endif %}
</div>

{% endblock %}
17 changes: 17 additions & 0 deletions aiarena/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions aiarena/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:pk>/', core_views.BotDetail.as_view(), name='bot'),
path('bots/<int:pk>/edit/', core_views.BotUpdate.as_view(), name='bot_edit'),
path('bots/<int:pk>/bot_zip', core_views.BotZipDownloadView.as_view()),
Expand Down
2 changes: 1 addition & 1 deletion doc/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ebd1f90

Please sign in to comment.