view and model notif and news
This commit is contained in:
@@ -207,6 +207,32 @@ class PushSubscription(models.Model):
|
||||
|
||||
|
||||
|
||||
class NotifBaseModel(models.Model):
|
||||
title = models.CharField(max_length=50)
|
||||
content = models.TextField()
|
||||
image = models.ImageField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
is_read = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class NewsModel(NotifBaseModel):
|
||||
|
||||
def notif_type(self):
|
||||
return 'NEWS'
|
||||
|
||||
|
||||
class UserNotificationModel(NotifBaseModel):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
|
||||
def notif_type(self):
|
||||
return 'USER_NOTIF'
|
||||
|
||||
|
||||
def get_location_from_ip(ip_address):
|
||||
try:
|
||||
response = requests.get(f"http://ip-api.com/json/{ip_address}")
|
||||
|
||||
Reference in New Issue
Block a user