Kumi
ff70221553
Removed unnecessary imports across various modules to streamline the application's dependencies and improve loading times. Specific changes include the removal of unused Django model and admin imports in several apps, simplifying view imports by eliminating unutilized components, and cleaning up static CSS for better maintainability. Corrections were made to conditional expressions for clearer logic. The removal of the django.test.TestCase import in test files reflects a shift towards a different testing strategy or the current lack of tests. Exception handling has been made more explicit to avoid catching unintended exceptions, paving the way for more robust error handling and logging in the future. Additionally, a new CSS file was added for frontend enhancements, indicating ongoing UI/UX improvements. These changes collectively aim to make the codebase more maintainable and efficient, reducing clutter and focusing on used functionalities. It's a step towards optimizing the application's performance and ensuring a clean, manageable codebase for future development.
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from django.views import View
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from django.shortcuts import get_object_or_404
|
|
from django.utils import timezone
|
|
from django.contrib.gis.geos import Point
|
|
|
|
from .models import GPSTrack, GPSToken
|
|
|
|
|
|
class GPSLogView(LoginRequiredMixin, View):
|
|
# TODO: Finish this view
|
|
def dispatch(self, request, *args, **kwargs):
|
|
self.gps_track = get_object_or_404(GPSTrack, id=self.kwargs["track"])
|
|
self.gps_token = get_object_or_404(
|
|
GPSToken, track=self.gps_track, token=self.kwargs["token"])
|
|
|
|
if request.method == "POST" and not self.gps_token.write:
|
|
return self.http_method_not_allowed(request, *args, **kwargs)
|
|
|
|
return super().dispatch(request, *args, **kwargs)
|
|
|
|
# ?lat=47.07047834&lon=15.45140181&alt=427.04833984375&tst=1043419092&batt=23.0&acc=14.692631721496582&spd=0.0&dir=&sat=6
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
if self.gps_token.write and all(field in request.GET for field in ("lat", "lon")):
|
|
lat = request.GET["lat"]
|
|
lon = request.GET["lon"]
|
|
|
|
alt = request.GET.get("alt", None)
|
|
|
|
point = Point(lat, lon, alt) # noqa: F841
|
|
|
|
tst = request.GET.get("tst", timezone.now().timestamp()) # noqa: F841
|
|
|
|
def post(self, request, *args, **kwargs):
|
|
pass
|