Add models for Interest and Profile
This commit is contained in:
parent
37581fb96a
commit
cbf1911fe7
1 changed files with 33 additions and 0 deletions
|
@ -106,3 +106,36 @@ class SearchEngine(models.Model):
|
||||||
if '{}' not in pattern:
|
if '{}' not in pattern:
|
||||||
raise InvalidData("Search engine {}: bad pattern".format(self))
|
raise InvalidData("Search engine {}: bad pattern".format(self))
|
||||||
return str(self.query_pattern).format(search_term)
|
return str(self.query_pattern).format(search_term)
|
||||||
|
|
||||||
|
|
||||||
|
class Interest(models.Model):
|
||||||
|
''' A class of interests '''
|
||||||
|
|
||||||
|
name = models.CharField(max_length=256)
|
||||||
|
|
||||||
|
keywords = models.ManyToManyField(Keyword)
|
||||||
|
places = models.ManyToManyField(Place)
|
||||||
|
websites = models.ManyToManyField(Website)
|
||||||
|
events = models.ManyToManyField(Event)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
class Profile(models.Model):
|
||||||
|
''' Represents a user profile, containing a few data to make their requests
|
||||||
|
consistent '''
|
||||||
|
|
||||||
|
nick = models.CharField(max_length=64,
|
||||||
|
help_text="The user's online identity")
|
||||||
|
first_name = models.CharField(max_length=64)
|
||||||
|
last_name = models.CharField(max_length=64)
|
||||||
|
email = models.EmailField()
|
||||||
|
uses_urls = models.BooleanField(
|
||||||
|
help_text=('Does the user usually go to a given website using its url '
|
||||||
|
'or searching it in a search engine?'))
|
||||||
|
interests = models.ManyToManyField(Interest)
|
||||||
|
search_engine = models.ForeignKey(SearchEngine,
|
||||||
|
on_delete=models.CASCADE)
|
||||||
|
browser_fingerprint = models.ForeignKey(BrowserFingerprint,
|
||||||
|
on_delete=models.CASCADE)
|
||||||
|
|
Loading…
Reference in a new issue