Skip to content

Commit

Permalink
chore: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
trebidav committed Nov 30, 2024
1 parent f37419d commit 68d7204
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
8 changes: 5 additions & 3 deletions comrade/comrade_core/templates/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@
lat: position.coords.latitude,
lng: position.coords.longitude
};
// Center the map on the user's location

// Center the map on the user's location
map.setCenter(userLocation);
map.setZoom(20); // Zoom in closer
// Add a marker for the user's location

// Add a marker for the user's location
const userMarker = new google.maps.marker.AdvancedMarkerElement({
position: userLocation,
map: map,
Expand Down Expand Up @@ -158,7 +160,7 @@
map: map,
gmpClickable: true
});

fetch('/user/', {
headers: { 'Authorization': 'Token a922af5f0cb0cd30abe67208e7f6a9ccc8795d0a' }
})
Expand Down
3 changes: 2 additions & 1 deletion comrade/comrade_core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
path('user/', views.UserDetailView.as_view(), name='user_detail'),
path('user/token/', views.login_view, name='login'),
path('map/', views.map, name='map'),
path('task/<int:taskId>/start', views.MyPostView.as_view(), name='start_task'),
path('task/<int:taskId>/start', views.TaskStartView.as_view(), name='start_task'),
path('task/<int:taskId>/finish', views.TaskFinishView.as_view(), name='finish_task'),
path('tasks/', views.TaskListView.as_view(), name='task_list'),
]

Expand Down
24 changes: 22 additions & 2 deletions comrade/comrade_core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def login_view(request):


# POST /task/{taskId}/start
class MyPostView(APIView):
class TaskStartView(APIView):
permission_classes = [IsAuthenticated]

def post(self, request: Request, taskId: int):
Expand All @@ -75,13 +75,33 @@ def post(self, request: Request, taskId: int):
try:
task.start(request.user)
except ValidationError as e:
return Response({"error": str(e)}, status=status.HTTP_403_FORBIDDEN)
return Response({"error": str(e)}, status=status.HTTP_412_PRECONDITION_FAILED)

return Response(
{"message": "Task started!"},
status=status.HTTP_200_OK,
)

class TaskFinishView(APIView):
permission_classes = [IsAuthenticated]

def post(self, request: Request, taskId: int):
task = None
try:
task = Task.objects.get(pk=taskId)
except Task.DoesNotExist as e:
return Response({"error": "Task not found"}, status=status.HTTP_404_NOT_FOUND)

print(request.user)
try:
task.finish(request.user)
except ValidationError as e:
return Response({"error": str(e)}, status=status.HTTP_412_PRECONDITION_FAILED)

return Response(
{"message": "Task finished!"},
status=status.HTTP_200_OK,
)

class TaskListView(APIView):
permission_classes = [IsAuthenticated]
Expand Down
Binary file modified dump.rdb
Binary file not shown.

0 comments on commit 68d7204

Please sign in to comment.