Commit 72b7c6bc authored by BERJON Matthieu's avatar BERJON Matthieu Committed by BAIRE Anthony
Browse files

Adding the Terms of Service model

I added two models for ToS system. A first model called `Tos` that
stores the data itself of the policy using a version number and a link
to a PDF version if necessary. The content of the policy should be
written in markdown.
Another model just stores the user and its related ToS version in order
for the user to be able to sign several versions.

I updated the admin to display the information related to the ToS

Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <>
parent 308d66cb
......@@ -13,6 +13,8 @@ from .models import (
......@@ -69,3 +71,5 @@, WebappVersionAdmin), JobAdmin)
......@@ -10,6 +10,7 @@ from django.core.validators import MinLengthValidator, MinValueValidator, \
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.shortcuts import redirect
from taggit.managers import TaggableManager
from allauth.account.models import EmailAddress
from allauth.socialaccount.models import SocialAccount
......@@ -612,8 +613,38 @@ class Job(TimeStampModel):
return os.path.join(settings.DATASTORE, str(
# def __str__(self):
# return self.webapp
class Tos(BaseModel):
""" The Terms of Service model
It can contains several version of a same ToS. The current view will always
look for the latest version in the model. Check the view if you have any
content = models.TextField(blank=True)
url = models.URLField(blank=True)
version = models.DecimalField(default=1.0, decimal_places=2, max_digits=6)
def __str__(self):
return str(self.version)
class Meta:
db_table = "dj_tos"
class UserAgreement(BaseModel):
""" User agreement model
Link a user to one or several ToS.
tos = models.ForeignKey('Tos', on_delete=models.CASCADE, related_name='tos')
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_agreement')
def __str__(self):
return "{0} - {1}".format(self.user, self.tos)
class Meta:
db_table = 'dj_user_agreement'
@receiver(post_save, sender=User)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment