minetest: Show domain information for users to connect to minetest

Signed-off-by: Hanisha P <hanishap@thoughtworks.com>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
hanisha 2017-12-06 16:56:15 +05:30 committed by Joseph Nuthalapati
parent 2d17f19ae2
commit 9adc777ae9
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,50 @@
{% extends "service.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% block status %}
{{ block.super }}
{% if domains %}
<div class="row">
<div class="col-sm-6">
<table class="table table-bordered table-condensed table-striped">
<thead>
<tr>
<th>{% trans "Address" %}</th>
<th>{% trans "Port" %}</th>
</tr>
</thead>
<tbody>
{% for domain in domains %}
<tr>
<td>
{{ domain }}
</td>
<td>{{ 30000 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
{% endblock %}

View File

@ -27,6 +27,7 @@ from plinth.views import ServiceView
from . import description, managed_services, get_configuration
from .forms import MinetestForm
from plinth.modules import names
class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors
@ -35,6 +36,7 @@ class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors
diagnostics_module_name = "minetest"
description = description
show_status_block = True
template_name = 'minetest.html'
form_class = MinetestForm
clients = minetest.clients
@ -44,6 +46,15 @@ class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors
initial.update(get_configuration())
return initial
def get_context_data(self, *args, **kwargs):
"""Add service to the context data."""
context = super().get_context_data(*args, **kwargs)
domains = [domain
for domains in names.domains.values()
for domain in domains]
context['domains'] = domains
return context
def form_valid(self, form):
"""Change the configurations of Minetest service."""
data = form.cleaned_data