Merge branch 'feature/localization' into develop
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
|
||||
from django.utils import timezone
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
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
|
||||
This abstract model represtens an object that is taggable
|
||||
using django-taggit
|
||||
'''
|
||||
class Meta:
|
||||
@@ -23,18 +24,25 @@ class Mapable(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
name = models.CharField(max_length=50)
|
||||
name = models.CharField(
|
||||
max_length=50,
|
||||
verbose_name=_('Name'),
|
||||
)
|
||||
latitude = models.FloatField(
|
||||
validators=[
|
||||
MinValueValidator(-90),
|
||||
MaxValueValidator(90)
|
||||
]
|
||||
],
|
||||
verbose_name=_('Latitude'),
|
||||
help_text=_('Latitude in decimal format: e. g. 41.40338')
|
||||
)
|
||||
longitude = models.FloatField(
|
||||
validators=[
|
||||
MinValueValidator(-180),
|
||||
MaxValueValidator(180)
|
||||
]
|
||||
],
|
||||
verbose_name=_('Longitude'),
|
||||
help_text=_('Longitude in decimal format: e. g. 2.17403')
|
||||
)
|
||||
|
||||
class Submittable(models.Model):
|
||||
@@ -66,4 +74,4 @@ class Expireable(models.Model):
|
||||
|
||||
@property
|
||||
def is_expired(self):
|
||||
return timezone.now() > self.expires_when
|
||||
return timezone.now() > self.expires_when
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from lostplaces.models.place import PlaceAsset
|
||||
|
||||
@@ -7,8 +8,14 @@ class ExternalLink(PlaceAsset):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
url = models.URLField(max_length=200)
|
||||
label = models.CharField(max_length=100)
|
||||
url = models.URLField(
|
||||
max_length=200,
|
||||
verbose_name=_('URL')
|
||||
)
|
||||
label = models.CharField(
|
||||
max_length=100,
|
||||
verbose_name=_('link text')
|
||||
)
|
||||
|
||||
class PhotoAlbum(ExternalLink):
|
||||
pass
|
@@ -4,6 +4,7 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.dispatch import receiver
|
||||
from django.db.models.signals import post_delete, pre_save
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from lostplaces.models.abstract_models import Submittable, Taggable, Mapable
|
||||
|
||||
@@ -15,8 +16,14 @@ class Place(Submittable, Taggable, Mapable):
|
||||
Place defines a lost place (location, name, description etc.).
|
||||
"""
|
||||
|
||||
location = models.CharField(max_length=50)
|
||||
description = models.TextField()
|
||||
location = models.CharField(
|
||||
max_length=50,
|
||||
verbose_name=_('Location'),
|
||||
)
|
||||
description = models.TextField(
|
||||
help_text=_('Description of the place: e.g. how to get there, where to be careful, the place\'s history...'),
|
||||
verbose_name=_('Description'),
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('place_detail', kwargs={'pk': self.pk})
|
||||
@@ -72,11 +79,16 @@ class PlaceImage (Submittable):
|
||||
PlaceImage references a Place to which it belongs.
|
||||
"""
|
||||
|
||||
description = models.TextField(blank=True)
|
||||
description = models.TextField(
|
||||
blank=True,
|
||||
verbose_name=_('Description'),
|
||||
)
|
||||
filename = ThumbnailerImageField(
|
||||
upload_to=generate_image_upload_path,
|
||||
resize_source=dict(size=(2560, 2560),
|
||||
sharpen=True)
|
||||
sharpen=True),
|
||||
verbose_name=_('Filename(s)'),
|
||||
help_text=_('Optional: One or more images to upload')
|
||||
)
|
||||
place = models.ForeignKey(
|
||||
Place,
|
||||
|
Reference in New Issue
Block a user