mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2025-06-28 16:25:44 +08:00
Improved landmarks view and added prefilled in landmarks
This commit is contained in:
parent
ba7e79cdc2
commit
6e357defcf
5 changed files with 107 additions and 15 deletions
|
@ -1,5 +1,8 @@
|
|||
from django.db import models
|
||||
from django.contrib.gis.db import models as gis_models
|
||||
from django.contrib.gis.geos import GEOSGeometry
|
||||
from django.db.models.signals import post_migrate
|
||||
from django.dispatch import receiver
|
||||
# Create your models here.
|
||||
|
||||
|
||||
|
@ -9,3 +12,24 @@ class Landmark(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@receiver(post_migrate)
|
||||
def populate_courses(sender, **kwargs):
|
||||
if sender.name == 'landmarks':
|
||||
SRID = 4326
|
||||
Landmark.objects.get_or_create(
|
||||
name='Gymnasium',
|
||||
location=GEOSGeometry(
|
||||
'POLYGON ((124.656383 8.485963, 124.656576 8.485483, 124.657009 8.485659, 124.656827 8.486126, 124.656383 8.485963))',
|
||||
srid=4326
|
||||
)
|
||||
)
|
||||
Landmark.objects.get_or_create(
|
||||
name='Arts & Culture Building',
|
||||
location=GEOSGeometry(
|
||||
'POLYGON ((124.658427 8.486268, 124.658432 8.48617, 124.658582 8.486202, 124.658555 8.4863, 124.658427 8.486268))',
|
||||
srid=4326
|
||||
)
|
||||
)
|
||||
# Add more predefined records as needed
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from rest_framework import generics
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from .serializers import LandmarkSerializer
|
||||
from .models import Landmark
|
||||
|
||||
|
||||
class LandmarkListView(generics.ListAPIView):
|
||||
serializer_class = LandmarkSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
# permission_classes = [IsAuthenticated]
|
||||
queryset = Landmark.objects.all()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue