Add basic models for histories

This commit is contained in:
Rémi Oudin 2018-01-24 16:07:33 +01:00
parent 924657abdb
commit 60f09bd4d3

View file

@ -1,3 +1,36 @@
from django.db import models """ Models for the history. This history should be able to generate history
entries, which looks like human-based browsing, according to a dedicated user
interests, keywords...
"""
# Create your models here. from django.db import models
from profiles.models import BrowserFingerprint
class HistoryEntry(models.Model):
""" A history entry, aka a url, and a timestamp.
"""
search = models.CharField(max_length=255)
timestamp = models.DateTimeField()
history = models.ForeignKey(
'History',
on_delete=models.CASCADE
)
def __str__(self):
return "{} : {}".format(self.timestamp, self.search)
class History(models.Model):
""" A history for a user, containing some web connections (http, https).
Each history is timed, in a human-behaviour manner. """
start_ts = models.DateTimeField()
played = models.BooleanField(default=False)
user_agent = models.ForeignKey(
BrowserFingerprint,
on_delete=models.CASCADE
)
def __str__(self):
history_set = self.history_set.order_by('timestamp')
return "\n".join(history_set)