mirror of
https://github.com/DerTyp7/tealcode-django-python.git
synced 2025-10-30 20:57:07 +01:00
intitial
This commit is contained in:
@@ -1,17 +1,35 @@
|
||||
from django.db import models
|
||||
|
||||
from django.utils import timezone
|
||||
from main.models import Topic, Category
|
||||
|
||||
|
||||
|
||||
class View(models.Model):
|
||||
ip = models.CharField(max_length=200)
|
||||
date = models.DateTimeField(default=timezone.now)
|
||||
country = models.CharField(max_length=250, blank=True)
|
||||
state = models.CharField(max_length=250, blank=True)
|
||||
city = models.CharField(max_length=250, blank=True)
|
||||
topic = models.ForeignKey(Topic, on_delete=models.CASCADE, blank=True, null=True)
|
||||
category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True)
|
||||
admin = models.BooleanField(default=False)
|
||||
home = models.BooleanField(default=False)
|
||||
custom_title = models.CharField(max_length=250, blank=True)
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.ip
|
||||
a = self.ip
|
||||
|
||||
if self.country:
|
||||
a = a + " - " + self.country
|
||||
|
||||
if self.topic:
|
||||
a = a + " - " + self.topic.title
|
||||
|
||||
if self.category:
|
||||
a = a + " - " + self.category.title
|
||||
|
||||
if self.custom_title:
|
||||
a = a + " - " + self.custom_title
|
||||
|
||||
a = a + " - " + str(self.date.day) + "." + str(self.date.month) + "." + str(self.date.year)
|
||||
return a
|
||||
|
||||
Reference in New Issue
Block a user