diff --git a/histories/models.py b/histories/models.py index 71a8362..ef30e06 100644 --- a/histories/models.py +++ b/histories/models.py @@ -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)