replace status strings to constants
This commit is contained in:
@@ -20,11 +20,13 @@ class Album(models.Model):
|
||||
)
|
||||
description = models.TextField(null=True, blank=True)
|
||||
|
||||
DRAFT = "10"
|
||||
PUBLIC = "20"
|
||||
STATUS = (
|
||||
("10", "DRAFT"),
|
||||
("20", "PUBLIC"),
|
||||
(DRAFT, "DRAFT"),
|
||||
(PUBLIC, "PUBLIC"),
|
||||
)
|
||||
status = models.CharField(max_length=2, choices=STATUS, default="10")
|
||||
status = models.CharField(max_length=2, choices=STATUS, default=DRAFT)
|
||||
|
||||
event_date = models.DateField(
|
||||
verbose_name="Event Datum", null=True, blank=True, default=timezone.now
|
||||
|
||||
@@ -16,8 +16,8 @@ def index(request):
|
||||
if request.user.is_authenticated:
|
||||
albums = deque(Album.objects.all().order_by("-event_date"))
|
||||
else:
|
||||
# show only PUBLIC albums ("20" -> PUBLIC).
|
||||
albums = deque(Album.objects.filter(status="20").order_by("-event_date"))
|
||||
# show only PUBLIC albums.
|
||||
albums = deque(Album.objects.filter(status=Album.PUBLIC).order_by("-event_date"))
|
||||
|
||||
for album in list(albums):
|
||||
img_list = get_image_list(album.folder_name)
|
||||
@@ -35,7 +35,7 @@ def index(request):
|
||||
album.thumbnail = img_list[value]["thumb_url"]
|
||||
else:
|
||||
# empty album is set to DRAFT.
|
||||
album.status = "10"
|
||||
album.status = Album.DRAFT
|
||||
|
||||
if request.user.is_authenticated:
|
||||
for folder in get_folder_list():
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
{% if album.event_date %}
|
||||
Datum: {{ album.event_date }}<br>
|
||||
{% endif %}
|
||||
{% if album.status == "10" %}
|
||||
{% if album.status == album.DRAFT %}
|
||||
DRAFT<br>
|
||||
{% endif %}
|
||||
{% if album.description %}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<div class="grid-x">
|
||||
{% for album in albums %}
|
||||
<div class="cell large-2 medium-3 small-12" {% if album.status == "10" %}style="background-color:red;"{% endif %}>
|
||||
<div class="cell large-2 medium-3 small-12" {% if album.status == album.DRAFT %}style="background-color:red;"{% endif %}>
|
||||
|
||||
{% if album.status == "10" %}
|
||||
<a href="{% url 'draft-album' album.slug %}">
|
||||
|
||||
Reference in New Issue
Block a user