mirror of
https://github.com/Hopiu/django-tos.git
synced 2026-03-17 04:20:22 +00:00
Readme, admin, and models first pass
This commit is contained in:
parent
42d43e3b86
commit
e96044f412
4 changed files with 70 additions and 0 deletions
13
README.rst
Normal file
13
README.rst
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
==========
|
||||
django-tos
|
||||
==========
|
||||
|
||||
This project gives the admin the ability to reset terms of agreement with the end users. It tracks when TOS are changed and when users agree to the new TOS.
|
||||
|
||||
Summary
|
||||
=======
|
||||
|
||||
- based flatpage
|
||||
- keep track of when TOS is changed
|
||||
- Users need to be informed and reagree when they relogin (custom login)
|
||||
- 2 models likely (TOS table and user re-agree)
|
||||
13
tos/admin.py
Normal file
13
tos/admin.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from tos.models import TermsOfService, UserAgreement
|
||||
|
||||
class TermsOfServiceAdmin(admin.ModelAdmin):
|
||||
model = TermsOfService
|
||||
|
||||
admin.site.register(TermsOfService, TermsOfServiceAdmin)
|
||||
|
||||
class UserAgreementAdmin(admin.ModelAdmin):
|
||||
model = UserAgreement
|
||||
|
||||
admin.site.register(UserAgreement, UserAgreementAdmin)
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
from django.contrib.auth.models import User
|
||||
from django.contrib.flatpages import FlatPage
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
class BaseModel(models.Model):
|
||||
|
||||
created = models.DateTimeField(label=_('created'), auto_now_add=False, editable=False)
|
||||
modified = models.DateTimeField(label=_('modified'), auto_now=False, editable=False)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class TermsOfService(BaseModel):
|
||||
|
||||
flat_page = models.ForeignKey(FlatPage, label=_('terms of service'), related_name='flatpage')
|
||||
active = models.BooleanField(_('active'), _('Only one terms of service is allowed to be active'))
|
||||
|
||||
class Meta:
|
||||
ordering = ('created')
|
||||
verbose_name=_('Terms of Service')
|
||||
verbose_name_plural=_('Terms of Service')
|
||||
|
||||
def __unicode__(self):
|
||||
active = 'inactive'
|
||||
if self.active:
|
||||
active = 'active'
|
||||
return '%s: %s' % (self.created, active)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
""" Ensure we're being saved properly """
|
||||
|
||||
self.objects.exclude(id=self.id).update(active=False)
|
||||
|
||||
super(TermsOfService,self).save(*args, **kwargs)
|
||||
|
||||
class UserAgreement(BaseModel):
|
||||
|
||||
terms_of_service = models.ForeignKey(FlatPage, label=_('terms of service'), related_name='terms')
|
||||
user = models.ForeignKey(User related_name='user')
|
||||
|
||||
def __unicode__(self):
|
||||
return self.terms_of_service
|
||||
Loading…
Reference in a new issue