61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
|
|
||
|
from django.db import models
|
||
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
||
|
|
||
|
from taggit.managers import TaggableManager
|
||
|
|
||
|
class Taggable(models.Model):
|
||
|
'''
|
||
|
This abstract model represtens an object that is taggalble
|
||
|
using django-taggit
|
||
|
'''
|
||
|
class Meta:
|
||
|
abstract = True
|
||
|
|
||
|
tags = TaggableManager(blank=True)
|
||
|
|
||
|
class Mapable(models.Model):
|
||
|
'''
|
||
|
This abstract model class represents an object that can be
|
||
|
displayed on a map.
|
||
|
'''
|
||
|
class Meta:
|
||
|
abstract = True
|
||
|
|
||
|
name = models.CharField(max_length=50)
|
||
|
latitude = models.FloatField(
|
||
|
validators=[
|
||
|
MinValueValidator(-90),
|
||
|
MaxValueValidator(90)
|
||
|
]
|
||
|
)
|
||
|
longitude = models.FloatField(
|
||
|
validators=[
|
||
|
MinValueValidator(-180),
|
||
|
MaxValueValidator(180)
|
||
|
]
|
||
|
)
|
||
|
|
||
|
class Submittable(models.Model):
|
||
|
'''
|
||
|
This abstract model class represents an object that can be submitted by
|
||
|
an explorer.
|
||
|
'''
|
||
|
class Meta:
|
||
|
abstract = True
|
||
|
|
||
|
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
||
|
submitted_by = models.ForeignKey(
|
||
|
'Explorer',
|
||
|
on_delete=models.SET_NULL,
|
||
|
null=True,
|
||
|
blank=True,
|
||
|
related_name='%(class)ss'
|
||
|
)
|
||
|
|
||
|
class Expireable(models.Model):
|
||
|
"""
|
||
|
Base class for things that can expire, i.e. VouchersAv
|
||
|
"""
|
||
|
created_when = models.DateTimeField(auto_now_add=True)
|
||
|
expires_when = models.DateTimeField()
|