make linter happy
This commit is contained in:
parent
79cde0f78c
commit
b732d52f65
21 changed files with 82 additions and 75 deletions
5
loadproduction.old.sh
Executable file
5
loadproduction.old.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
export C3NAV_CONFIG=/home/laura/Projekte/c3nav/data/c3nav.cfg
|
||||||
|
ssh root@34c3.c3nav.de "c3nav-manage 34c3 dumpdata mapdata --format json | gzip" | gunzip > production.json
|
||||||
|
python src/manage.py loaddata --app mapdata production.json
|
||||||
|
# rm production.json
|
|
@ -9,8 +9,8 @@ from itertools import chain
|
||||||
import pytz
|
import pytz
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models import Prefetch
|
from django.db.models import Prefetch
|
||||||
from django.forms import ChoiceField, Form, IntegerField, ModelForm, Select, MultipleChoiceField, \
|
from django.forms import (ChoiceField, Form, IntegerField, ModelForm, ModelMultipleChoiceField, MultipleChoiceField,
|
||||||
ModelMultipleChoiceField
|
Select)
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.utils.translation import ngettext_lazy
|
from django.utils.translation import ngettext_lazy
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
{% if request.user_permissions.manage_map_updates %}
|
{% if request.user_permissions.manage_map_updates %}
|
||||||
<a href="{% url 'control.map_updates' %}">{% trans 'Map Updates' %}</a> ·
|
<a href="{% url 'control.map_updates' %}">{% trans 'Map Updates' %}</a> ·
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{% url 'control.mesh_nodes' %}">{% trans 'Mesh' %}</a> ·
|
<a href="{% url 'control.mesh.nodes' %}">{% trans 'Mesh' %}</a> ·
|
||||||
<a href="{% url 'control.users.detail' user=request.user.pk %}">{{ request.user.username }}</a>
|
<a href="{% url 'control.users.detail' user=request.user.pk %}">{{ request.user.username }}</a>
|
||||||
</p>
|
</p>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
{% block subcontent %}
|
{% block subcontent %}
|
||||||
<p><a class="button" href="{{ success_url }}">Go back</a></p>
|
<p><a class="button" href="{{ success_url }}">Go back</a></p>
|
||||||
{% if msg_type == "MESH_ROUTE_REQUEST" %}
|
{% if msg_type == "MESH_ROUTE_REQUEST" %}
|
||||||
<p>Route to <a href="{% url "control.mesh_node.detail" pk=msg_data.address %}">{{ msg_data.address }} {% if node_name %} ({{ node_name }}){% endif %}</a></p>
|
<p>Route to <a href="{% url "control.mesh.node.detail" pk=msg_data.address %}">{{ msg_data.address }} {% if node_name %} ({{ node_name }}){% endif %}</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div>
|
<div>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
{% for address, name in recipients %}
|
{% for address, name in recipients %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{% if address != "ff:ff:ff:ff:ff:ff" %}<a href="{% url "control.mesh_node.detail" pk=address %}">{% endif %}
|
{% if address != "ff:ff:ff:ff:ff:ff" %}<a href="{% url "control.mesh.node.detail" pk=address %}">{% endif %}
|
||||||
{{ address }}{% if name %} ({{ name }}){% endif %}
|
{{ address }}{% if name %} ({{ name }}){% endif %}
|
||||||
{% if address != "ff:ff:ff:ff:ff:ff" %}</a>{% endif %}
|
{% if address != "ff:ff:ff:ff:ff:ff" %}</a>{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
{% for msg in mesh_messages %}
|
{% for msg in mesh_messages %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ msg.datetime.date }} {{ msg.datetime.time|date:"H:i:s" }}</td>
|
<td>{{ msg.datetime.date }} {{ msg.datetime.time|date:"H:i:s" }}</td>
|
||||||
<td><a href="{% url "control.mesh_node.detail" pk=msg.src_node.address %}">{{ msg.src_node }}</a></td>
|
<td><a href="{% url "control.mesh.node.detail" pk=msg.src_node.address %}">{{ msg.src_node }}</a></td>
|
||||||
<td>{{ msg.get_message_type_display }}</td>
|
<td>{{ msg.get_message_type_display }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if msg.get_message_type_display == "CONFIG_FIRMWARE" %}
|
{% if msg.get_message_type_display == "CONFIG_FIRMWARE" %}
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td><a href="{% url "control.mesh_node.detail" pk=msg.uplink_node.address %}">{{ msg.uplink_node }}</a></td>
|
<td><a href="{% url "control.mesh.node.detail" pk=msg.uplink_node.address %}">{{ msg.uplink_node }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<strong>Name:</strong> {% if node.name %}{{ node.name }}{% else %}<em>{% trans '(no name)' %}</em>{% endif %}
|
<strong>Name:</strong> {% if node.name %}{{ node.name }}{% else %}<em>{% trans '(no name)' %}</em>{% endif %}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>Uplink:</strong> <a href="{% url "control.mesh_node.detail" pk=node.uplink.address %}">{{ node.uplink }}</a><br>
|
<strong>Uplink:</strong> <a href="{% url "control.mesh.node.detail" pk=node.uplink.address %}">{{ node.uplink }}</a><br>
|
||||||
|
|
||||||
<strong>Last signin:</strong>
|
<strong>Last signin:</strong>
|
||||||
{{ node.last_signin.date }} {{ node.last_signin.time|date:"H:i:s" }}
|
{{ node.last_signin.date }} {{ node.last_signin.time|date:"H:i:s" }}
|
||||||
|
@ -29,10 +29,10 @@
|
||||||
<br>
|
<br>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a class="button" href="{% url "control.mesh_node.edit" pk=node.pk %}">
|
<a class="button" href="{% url "control.mesh.node.edit" pk=node.pk %}">
|
||||||
{% trans 'Edit' %}
|
{% trans 'Edit' %}
|
||||||
</a>
|
</a>
|
||||||
<a class="button" href="{% url "control.mesh_messages" %}?src_nodes={{ node.address }}">
|
<a class="button" href="{% url "control.mesh.messages" %}?src_nodes={{ node.address }}">
|
||||||
{% trans 'View messages' %}
|
{% trans 'View messages' %}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
<strong>SSL:</strong> {{ node.last_messages.CONFIG_UPLINK.parsed.ssl }}<br>
|
<strong>SSL:</strong> {{ node.last_messages.CONFIG_UPLINK.parsed.ssl }}<br>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a class="button" href="{% url "control.mesh_message.send" recipient=node.address msg_type="CONFIG_UPLINK" %}">
|
<a class="button" href="{% url "control.mesh.send" recipient=node.address msg_type="CONFIG_UPLINK" %}">
|
||||||
{% trans 'Change' %}
|
{% trans 'Change' %}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
<strong>X=</strong>{{ node.last_messages.CONFIG_POSITION.parsed.x_pos }}, <strong>Y=</strong>{{ node.last_messages.CONFIG_POSITION.parsed.y_pos }}, <strong>Z=</strong>{{ node.last_messages.CONFIG_POSITION.parsed.z_pos }}
|
<strong>X=</strong>{{ node.last_messages.CONFIG_POSITION.parsed.x_pos }}, <strong>Y=</strong>{{ node.last_messages.CONFIG_POSITION.parsed.y_pos }}, <strong>Z=</strong>{{ node.last_messages.CONFIG_POSITION.parsed.z_pos }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a class="button" href="{% url "control.mesh_message.send" recipient=node.address msg_type="CONFIG_POSITION" %}">
|
<a class="button" href="{% url "control.mesh.send" recipient=node.address msg_type="CONFIG_POSITION" %}">
|
||||||
{% trans 'Change' %}
|
{% trans 'Change' %}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
{{ node.last_messages.CONFIG_LED.parsed.led_config }}
|
{{ node.last_messages.CONFIG_LED.parsed.led_config }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a class="button" href="{% url "control.mesh_message.send" recipient=node.address msg_type="CONFIG_LED" %}">
|
<a class="button" href="{% url "control.mesh.send" recipient=node.address msg_type="CONFIG_LED" %}">
|
||||||
{% trans 'Change' %}
|
{% trans 'Change' %}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div>
|
<div>
|
||||||
<h4>View messages</h4>
|
<h4>View messages</h4>
|
||||||
<a class="button" href="{% url "control.mesh_messages" %}">
|
<a class="button" href="{% url "control.mesh.messages" %}">
|
||||||
{% trans 'View received messages' %}
|
{% trans 'View received messages' %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4>Logs</h4>
|
<h4>Logs</h4>
|
||||||
<a class="button" href="{% url "control.mesh_log" %}">
|
<a class="button" href="{% url "control.mesh.log" %}">
|
||||||
{% trans 'View log' %}
|
{% trans 'View log' %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% for node in nodes %}
|
{% for node in nodes %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{% url "control.mesh_node.detail" pk=node.address %}">{{ node }}</a></td>
|
<td><a href="{% url "control.mesh.node.detail" pk=node.address %}">{{ node }}</a></td>
|
||||||
<td>
|
<td>
|
||||||
{{ node.last_messages.CONFIG_FIRMWARE.parsed.get_chip_display }}
|
{{ node.last_messages.CONFIG_FIRMWARE.parsed.get_chip_display }}
|
||||||
<small>rev{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_minor }}</small>
|
<small>rev{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_major }}.{{ node.last_messages.CONFIG_FIRMWARE.parsed.revision_minor }}</small>
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
{{ timesince }} ago
|
{{ timesince }} ago
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</td>
|
</td>
|
||||||
<td><a href="{% url "control.mesh_node.detail" pk=node.uplink.address %}">{{ node.uplink }}</a></td>
|
<td><a href="{% url "control.mesh.node.detail" pk=node.uplink.address %}">{{ node.uplink }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from c3nav.control.views.mesh import MeshNodeListView, MeshMessageListView, MeshNodeDetailView, MeshMessageSendView, \
|
|
||||||
MeshNodeEditView, MeshLogView, MeshMessageSendingView
|
|
||||||
from c3nav.control.views.mapupdates import map_updates
|
|
||||||
from c3nav.control.views.announcements import announcement_list, announcement_detail
|
|
||||||
from c3nav.control.views.access import grant_access, grant_access_qr
|
from c3nav.control.views.access import grant_access, grant_access_qr
|
||||||
from c3nav.control.views.users import UserListView, user_detail
|
from c3nav.control.views.announcements import announcement_detail, announcement_list
|
||||||
from c3nav.control.views.base import ControlPanelIndexView
|
from c3nav.control.views.base import ControlPanelIndexView
|
||||||
|
from c3nav.control.views.mapupdates import map_updates
|
||||||
|
from c3nav.control.views.mesh import (MeshLogView, MeshMessageListView, MeshMessageSendingView, MeshMessageSendView,
|
||||||
|
MeshNodeDetailView, MeshNodeEditView, MeshNodeListView)
|
||||||
|
from c3nav.control.views.users import UserListView, user_detail
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('users/', UserListView.as_view(), name='control.users'),
|
path('users/', UserListView.as_view(), name='control.users'),
|
||||||
|
@ -16,13 +16,13 @@ urlpatterns = [
|
||||||
path('announcements/', announcement_list, name='control.announcements'),
|
path('announcements/', announcement_list, name='control.announcements'),
|
||||||
path('announcements/<int:annoucement>/', announcement_detail, name='control.announcements.detail'),
|
path('announcements/<int:annoucement>/', announcement_detail, name='control.announcements.detail'),
|
||||||
path('mapupdates/', map_updates, name='control.map_updates'),
|
path('mapupdates/', map_updates, name='control.map_updates'),
|
||||||
path('mesh/', MeshNodeListView.as_view(), name='control.mesh_nodes'),
|
path('mesh/', MeshNodeListView.as_view(), name='control.mesh.nodes'),
|
||||||
path('mesh/logs/', MeshLogView.as_view(), name='control.mesh_log'),
|
path('mesh/logs/', MeshLogView.as_view(), name='control.mesh.log'),
|
||||||
path('mesh/messages/', MeshMessageListView.as_view(), name='control.mesh_messages'),
|
path('mesh/messages/', MeshMessageListView.as_view(), name='control.mesh.messages'),
|
||||||
path('mesh/<str:pk>/', MeshNodeDetailView.as_view(), name='control.mesh_node.detail'),
|
path('mesh/<str:pk>/', MeshNodeDetailView.as_view(), name='control.mesh.node.detail'),
|
||||||
path('mesh/<str:pk>/edit/', MeshNodeEditView.as_view(), name='control.mesh_node.edit'),
|
path('mesh/<str:pk>/edit/', MeshNodeEditView.as_view(), name='control.mesh.node.edit'),
|
||||||
path('mesh/message/sending/<uuid:uuid>/', MeshMessageSendingView.as_view(), name='control.mesh_message.sending'),
|
path('mesh/message/sending/<uuid:uuid>/', MeshMessageSendingView.as_view(), name='control.mesh.sending'),
|
||||||
path('mesh/message/<str:recipient>/<str:msg_type>/', MeshMessageSendView.as_view(), name='control.mesh_message.send'),
|
path('mesh/message/<str:recipient>/<str:msg_type>/', MeshMessageSendView.as_view(), name='control.mesh.send'),
|
||||||
path('mesh/message/<str:msg_type>/', MeshMessageSendView.as_view(), name='control.mesh_message.send'),
|
path('mesh/message/<str:msg_type>/', MeshMessageSendView.as_view(), name='control.mesh.send'),
|
||||||
path('', ControlPanelIndexView.as_view(), name='control.index'),
|
path('', ControlPanelIndexView.as_view(), name='control.index'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.shortcuts import redirect, render, get_object_or_404
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
|
|
||||||
from c3nav.control.forms import AnnouncementForm
|
from c3nav.control.forms import AnnouncementForm
|
||||||
from c3nav.control.views.base import control_panel_view
|
from c3nav.control.views.base import control_panel_view
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from django.shortcuts import redirect, render
|
||||||
from django.utils.timezone import make_aware
|
from django.utils.timezone import make_aware
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from c3nav.control.forms import MapUpdateForm, MapUpdateFilterForm
|
from c3nav.control.forms import MapUpdateFilterForm, MapUpdateForm
|
||||||
from c3nav.control.views.base import control_panel_view
|
from c3nav.control.views.base import control_panel_view
|
||||||
from c3nav.mapdata.models import MapUpdate
|
from c3nav.mapdata.models import MapUpdate
|
||||||
from c3nav.mapdata.tasks import process_map_updates
|
from c3nav.mapdata.tasks import process_map_updates
|
||||||
|
|
|
@ -8,12 +8,12 @@ from django.http import Http404
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import ListView, DetailView, FormView, UpdateView, TemplateView
|
from django.views.generic import DetailView, FormView, ListView, TemplateView, UpdateView
|
||||||
|
|
||||||
from c3nav.control.forms import MeshMessageFilterForm
|
from c3nav.control.forms import MeshMessageFilterForm
|
||||||
from c3nav.control.views.base import ControlPanelMixin
|
from c3nav.control.views.base import ControlPanelMixin
|
||||||
from c3nav.mesh.forms import MeshMessageForm, MeshNodeForm
|
from c3nav.mesh.forms import MeshMessageForm, MeshNodeForm
|
||||||
from c3nav.mesh.messages import MeshMessageType, MeshMessage
|
from c3nav.mesh.messages import MeshMessage, MeshMessageType
|
||||||
from c3nav.mesh.models import MeshNode, NodeMessage
|
from c3nav.mesh.models import MeshNode, NodeMessage
|
||||||
from c3nav.mesh.utils import get_node_names
|
from c3nav.mesh.utils import get_node_names
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class MeshNodeListView(ControlPanelMixin, ListView):
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
return redirect(
|
return redirect(
|
||||||
reverse("control.mesh_message.send", kwargs={"msg_type": request.POST.get("send_msg_type", "")})
|
reverse("control.mesh.send", kwargs={"msg_type": request.POST.get("send_msg_type", "")})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class MeshNodeEditView(ControlPanelMixin, SuccessMessageMixin, UpdateView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse('control.mesh_node.detail', kwargs={'pk': self.get_object().pk})
|
return reverse('control.mesh.node.detail', kwargs={'pk': self.get_object().pk})
|
||||||
|
|
||||||
|
|
||||||
class MeshMessageListView(ControlPanelMixin, ListView):
|
class MeshMessageListView(ControlPanelMixin, ListView):
|
||||||
|
@ -130,7 +130,7 @@ class MeshMessageSendView(ControlPanelMixin, FormView):
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
if 'recipient' in self.kwargs and False:
|
if 'recipient' in self.kwargs and False:
|
||||||
return reverse('control.mesh_node.detail', kwargs={'pk': self.kwargs['recipient']})
|
return reverse('control.mesh.node.detail', kwargs={'pk': self.kwargs['recipient']})
|
||||||
else:
|
else:
|
||||||
return self.request.path
|
return self.request.path
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class MeshMessageSendView(ControlPanelMixin, FormView):
|
||||||
"recipients": form.get_recipients(),
|
"recipients": form.get_recipients(),
|
||||||
"msg_data": form.get_msg_data(),
|
"msg_data": form.get_msg_data(),
|
||||||
}
|
}
|
||||||
return redirect(reverse('control.mesh_message.sending', kwargs={'uuid': uuid}))
|
return redirect(reverse('control.mesh.sending', kwargs={'uuid': uuid}))
|
||||||
|
|
||||||
|
|
||||||
class MeshMessageSendingView(ControlPanelMixin, TemplateView):
|
class MeshMessageSendingView(ControlPanelMixin, TemplateView):
|
||||||
|
|
|
@ -3,7 +3,7 @@ import string
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import transaction, IntegrityError
|
from django.db import IntegrityError, transaction
|
||||||
from django.db.models import Prefetch
|
from django.db.models import Prefetch
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -11,8 +11,8 @@ from django.utils.crypto import get_random_string
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
|
|
||||||
from c3nav.control.forms import UserPermissionsForm, AccessPermissionForm, UserSpaceAccessForm
|
from c3nav.control.forms import AccessPermissionForm, UserPermissionsForm, UserSpaceAccessForm
|
||||||
from c3nav.control.models import UserSpaceAccess, UserPermissions
|
from c3nav.control.models import UserPermissions, UserSpaceAccess
|
||||||
from c3nav.control.views.base import ControlPanelMixin, control_panel_view
|
from c3nav.control.views.base import ControlPanelMixin, control_panel_view
|
||||||
from c3nav.mapdata.models import AccessRestriction
|
from c3nav.mapdata.models import AccessRestriction
|
||||||
from c3nav.mapdata.models.access import AccessPermission
|
from c3nav.mapdata.models.access import AccessPermission
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
def editor_get_object_or_404(model, *q):
|
|
||||||
return get_object_or_404()
|
|
|
@ -1,8 +1,8 @@
|
||||||
import re
|
import re
|
||||||
import struct
|
import struct
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from dataclasses import dataclass, fields, field, Field
|
from dataclasses import Field, dataclass, fields
|
||||||
from typing import Any, Sequence, Self
|
from typing import Any, Self, Sequence
|
||||||
|
|
||||||
from c3nav.mesh.utils import indent_c
|
from c3nav.mesh.utils import indent_c
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from asgiref.sync import async_to_sync
|
from asgiref.sync import async_to_sync
|
||||||
from channels.generic.websocket import WebsocketConsumer, JsonWebsocketConsumer
|
from channels.generic.websocket import JsonWebsocketConsumer, WebsocketConsumer
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from c3nav.mesh.utils import get_mesh_comm_group
|
|
||||||
from c3nav.mesh import messages
|
from c3nav.mesh import messages
|
||||||
from c3nav.mesh.messages import MeshMessage, MESH_BROADCAST_ADDRESS, MeshMessageType, MESH_ROOT_ADDRESS, \
|
from c3nav.mesh.messages import (MESH_BROADCAST_ADDRESS, MESH_NONE_ADDRESS, MESH_ROOT_ADDRESS, MeshMessage,
|
||||||
MESH_NONE_ADDRESS
|
MeshMessageType)
|
||||||
from c3nav.mesh.models import MeshNode, NodeMessage
|
from c3nav.mesh.models import MeshNode, NodeMessage
|
||||||
from c3nav.mesh.tasks import send_channel_msg
|
from c3nav.mesh.tasks import send_channel_msg
|
||||||
|
from c3nav.mesh.utils import get_mesh_comm_group
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyAttributeOutsideInit
|
# noinspection PyAttributeOutsideInit
|
||||||
|
@ -34,8 +34,8 @@ class MeshConsumer(WebsocketConsumer):
|
||||||
self.remove_dst_nodes(self.dst_nodes)
|
self.remove_dst_nodes(self.dst_nodes)
|
||||||
|
|
||||||
def send_msg(self, msg, sender=None, exclude_uplink_address=None):
|
def send_msg(self, msg, sender=None, exclude_uplink_address=None):
|
||||||
#print("sending", msg, MeshMessage.encode(msg).hex(' ', 1))
|
# print("sending", msg, MeshMessage.encode(msg).hex(' ', 1))
|
||||||
#self.log_text(msg.dst, "sending %s" % msg)
|
# self.log_text(msg.dst, "sending %s" % msg)
|
||||||
self.send(bytes_data=MeshMessage.encode(msg))
|
self.send(bytes_data=MeshMessage.encode(msg))
|
||||||
async_to_sync(self.channel_layer.group_send)("mesh_msg_sent", {
|
async_to_sync(self.channel_layer.group_send)("mesh_msg_sent", {
|
||||||
"type": "mesh.msg_sent",
|
"type": "mesh.msg_sent",
|
||||||
|
@ -44,7 +44,7 @@ class MeshConsumer(WebsocketConsumer):
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
"uplink": self.uplink_node.address if self.uplink_node else None,
|
"uplink": self.uplink_node.address if self.uplink_node else None,
|
||||||
"recipient": msg.dst,
|
"recipient": msg.dst,
|
||||||
#"msg": msg.tojson(), # not doing this part for privacy reasons
|
# "msg": msg.tojson(), # not doing this part for privacy reasons
|
||||||
})
|
})
|
||||||
|
|
||||||
def receive(self, text_data=None, bytes_data=None):
|
def receive(self, text_data=None, bytes_data=None):
|
||||||
|
@ -81,7 +81,7 @@ class MeshConsumer(WebsocketConsumer):
|
||||||
print('it\'s a broadcast so it\'s also for us')
|
print('it\'s a broadcast so it\'s also for us')
|
||||||
self.log_text(MESH_ROOT_ADDRESS, "received broadcast message, forwarding and handling...")
|
self.log_text(MESH_ROOT_ADDRESS, "received broadcast message, forwarding and handling...")
|
||||||
|
|
||||||
#print('Received message:', msg)
|
# print('Received message:', msg)
|
||||||
|
|
||||||
src_node, created = MeshNode.objects.get_or_create(address=msg.src)
|
src_node, created = MeshNode.objects.get_or_create(address=msg.src)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import IntEnum, unique
|
from enum import IntEnum, unique
|
||||||
|
|
||||||
from c3nav.mesh.baseformats import FixedHexFormat, VarArrayFormat, StructType, SimpleFormat, FixedStrFormat
|
from c3nav.mesh.baseformats import FixedHexFormat, FixedStrFormat, SimpleFormat, StructType, VarArrayFormat
|
||||||
|
|
||||||
|
|
||||||
class MacAddressFormat(FixedHexFormat):
|
class MacAddressFormat(FixedHexFormat):
|
||||||
|
@ -14,7 +14,6 @@ class MacAddressesListFormat(VarArrayFormat):
|
||||||
super().__init__(child_type=MacAddressFormat())
|
super().__init__(child_type=MacAddressFormat())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class LedType(IntEnum):
|
class LedType(IntEnum):
|
||||||
SERIAL = 1
|
SERIAL = 1
|
||||||
|
|
|
@ -7,7 +7,7 @@ from django.http import Http404
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from c3nav.mesh.dataformats import LedConfig
|
from c3nav.mesh.dataformats import LedConfig
|
||||||
from c3nav.mesh.messages import MeshMessageType, MeshMessage, MESH_ROOT_ADDRESS, MESH_BROADCAST_ADDRESS
|
from c3nav.mesh.messages import MESH_BROADCAST_ADDRESS, MESH_ROOT_ADDRESS, MeshMessage, MeshMessageType
|
||||||
from c3nav.mesh.models import MeshNode
|
from c3nav.mesh.models import MeshNode
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,8 @@ from dataclasses import fields
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
from c3nav.mesh.dataformats import LedConfig
|
|
||||||
from c3nav.mesh.baseformats import normalize_name
|
from c3nav.mesh.baseformats import normalize_name
|
||||||
from c3nav.mesh.messages import MeshMessage, MeshMessageType
|
from c3nav.mesh.messages import MeshMessage
|
||||||
from c3nav.mesh.utils import indent_c
|
from c3nav.mesh.utils import indent_c
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +42,8 @@ class Command(BaseCommand):
|
||||||
struct_lines[base_name] = "%s %s;" % (name, base_name.replace('_announce', ''))
|
struct_lines[base_name] = "%s %s;" % (name, base_name.replace('_announce', ''))
|
||||||
struct_sizes.append(size)
|
struct_sizes.append(size)
|
||||||
print(code)
|
print(code)
|
||||||
print("static_assert(sizeof(%s) == %d, \"size of generated message structs is calculated wrong\");" % (name, size))
|
print("static_assert(sizeof(%s) == %d, \"size of generated message structs is calculated wrong\");" %
|
||||||
|
(name, size))
|
||||||
print()
|
print()
|
||||||
else:
|
else:
|
||||||
nodata.add(msg_type)
|
nodata.add(msg_type)
|
||||||
|
@ -53,7 +53,10 @@ class Command(BaseCommand):
|
||||||
for line in struct_lines.values():
|
for line in struct_lines.values():
|
||||||
print(indent_c(line))
|
print(indent_c(line))
|
||||||
print("} mesh_msg_data_t; ")
|
print("} mesh_msg_data_t; ")
|
||||||
print("static_assert(sizeof(mesh_msg_data_t) == %d, \"size of generated message structs is calculated wrong\");" % max(struct_sizes))
|
print(
|
||||||
|
"static_assert(sizeof(mesh_msg_data_t) == %d, \"size of generated message structs is calculated wrong\");"
|
||||||
|
% max(struct_sizes)
|
||||||
|
)
|
||||||
|
|
||||||
max_msg_type = max(MeshMessage.get_types().keys())
|
max_msg_type = max(MeshMessage.get_types().keys())
|
||||||
macro_data = []
|
macro_data = []
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
import re
|
import re
|
||||||
from dataclasses import asdict, dataclass, field, fields, is_dataclass
|
from dataclasses import dataclass, field
|
||||||
from enum import IntEnum, unique
|
from enum import IntEnum, unique
|
||||||
from itertools import chain
|
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
import channels
|
import channels
|
||||||
from asgiref.sync import async_to_sync
|
from asgiref.sync import async_to_sync
|
||||||
|
|
||||||
from c3nav.mesh.utils import get_mesh_comm_group, indent_c
|
from c3nav.mesh.baseformats import BoolFormat, FixedStrFormat, SimpleFormat, StructType, VarArrayFormat, VarStrFormat
|
||||||
from c3nav.mesh.dataformats import (LedConfig, LedConfig,
|
from c3nav.mesh.dataformats import (FirmwareAppDescription, LedConfig, MacAddressesListFormat, MacAddressFormat,
|
||||||
MacAddressesListFormat, MacAddressFormat, RangeItemType, FirmwareAppDescription)
|
RangeItemType)
|
||||||
from c3nav.mesh.baseformats import SimpleFormat, BoolFormat, FixedStrFormat, FixedHexFormat, VarArrayFormat, \
|
from c3nav.mesh.utils import get_mesh_comm_group
|
||||||
VarStrFormat, StructType
|
|
||||||
|
|
||||||
MESH_ROOT_ADDRESS = '00:00:00:00:00:00'
|
MESH_ROOT_ADDRESS = '00:00:00:00:00:00'
|
||||||
MESH_NONE_ADDRESS = '00:00:00:00:00:00'
|
MESH_NONE_ADDRESS = '00:00:00:00:00:00'
|
||||||
|
@ -20,6 +18,7 @@ MESH_CHILDREN_ADDRESS = '00:00:00:00:ff:ff'
|
||||||
MESH_BROADCAST_ADDRESS = 'ff:ff:ff:ff:ff:ff'
|
MESH_BROADCAST_ADDRESS = 'ff:ff:ff:ff:ff:ff'
|
||||||
NO_LAYER = 0xFF
|
NO_LAYER = 0xFF
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class MeshMessageType(IntEnum):
|
class MeshMessageType(IntEnum):
|
||||||
NOOP = 0x00
|
NOOP = 0x00
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
from collections import UserDict
|
from collections import UserDict
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from typing import Mapping, Self, Any
|
from typing import Any, Mapping, Self
|
||||||
|
|
||||||
from django.db import models, NotSupportedError
|
from django.db import NotSupportedError, models
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from c3nav.mesh.messages import MeshMessageType, ChipType, MeshMessage as MeshMessage
|
from c3nav.mesh.messages import ChipType
|
||||||
|
from c3nav.mesh.messages import MeshMessage as MeshMessage
|
||||||
|
from c3nav.mesh.messages import MeshMessageType
|
||||||
|
|
||||||
|
|
||||||
class MeshNodeQuerySet(models.QuerySet):
|
class MeshNodeQuerySet(models.QuerySet):
|
||||||
|
@ -42,6 +44,7 @@ class MeshNodeQuerySet(models.QuerySet):
|
||||||
except NotSupportedError:
|
except NotSupportedError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class LastMessagesByTypeLookup(UserDict):
|
class LastMessagesByTypeLookup(UserDict):
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue