web qism tugadi

This commit is contained in:
behruz-dev
2025-11-25 16:50:30 +05:00
parent 8d7738483c
commit 55bb751899
16 changed files with 500 additions and 5 deletions

View File

@@ -4,4 +4,6 @@ from .district import *
from .place import *
from .doctor import *
from .pharmacy import *
from .plan import *
from .plan import *
from .location import *
from .tour_plan import *

View File

@@ -0,0 +1,30 @@
from django.db import models
# shared
from core.apps.shared.models import BaseModel, District, Doctor, Place, Pharmacy
# accounts
from core.apps.accounts.models import User
class Location(BaseModel):
district = models.ForeignKey(District, on_delete=models.SET_NULL, related_name='locations', null=True, blank=True)
place = models.ForeignKey(Place, on_delete=models.SET_NULL, related_name='locations', null=True, blank=True)
doctor = models.ForeignKey(Doctor, on_delete=models.SET_NULL, related_name='locations', null=True, blank=True)
pharmacy = models.ForeignKey(Pharmacy, on_delete=models.SET_NULL, related_name='locations', null=True, blank=True)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='locations')
longitude = models.FloatField()
latitude = models.FloatField()
def __str__(self):
return f"{self.user} sended location from {self.longitude} long and {self.langitude} lat"
class UserLocation(BaseModel):
latitude = models.FloatField()
longitude = models.FloatField()
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_locations')
def __str__(self):
return f"{self.user}'s location: {self.longitude} long and {self.latitude} lat at {self.created_at.date}/{self.created_at.time}"

View File

@@ -0,0 +1,17 @@
from django.db import models
# shared
from core.apps.shared.models import BaseModel, District
# accounts
from core.apps.accounts.models import User
class TourPlan(BaseModel):
district = models.ForeignKey(District, on_delete=models.CASCADE, related_name='tour_plans')
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='tour_plans')
latitude = models.FloatField(null=True, blank=True)
longitude = models.FloatField(null=True, blank=True)
def __str__(self):
return f"{self.user.first_name}'s tour plan to {self.district.name}"