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)
|
description = models.TextField(null=True, blank=True)
|
||||||
|
|
||||||
|
DRAFT = "10"
|
||||||
|
PUBLIC = "20"
|
||||||
STATUS = (
|
STATUS = (
|
||||||
("10", "DRAFT"),
|
(DRAFT, "DRAFT"),
|
||||||
("20", "PUBLIC"),
|
(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(
|
event_date = models.DateField(
|
||||||
verbose_name="Event Datum", null=True, blank=True, default=timezone.now
|
verbose_name="Event Datum", null=True, blank=True, default=timezone.now
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ def index(request):
|
|||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
albums = deque(Album.objects.all().order_by("-event_date"))
|
albums = deque(Album.objects.all().order_by("-event_date"))
|
||||||
else:
|
else:
|
||||||
# show only PUBLIC albums ("20" -> PUBLIC).
|
# show only PUBLIC albums.
|
||||||
albums = deque(Album.objects.filter(status="20").order_by("-event_date"))
|
albums = deque(Album.objects.filter(status=Album.PUBLIC).order_by("-event_date"))
|
||||||
|
|
||||||
for album in list(albums):
|
for album in list(albums):
|
||||||
img_list = get_image_list(album.folder_name)
|
img_list = get_image_list(album.folder_name)
|
||||||
@@ -35,7 +35,7 @@ def index(request):
|
|||||||
album.thumbnail = img_list[value]["thumb_url"]
|
album.thumbnail = img_list[value]["thumb_url"]
|
||||||
else:
|
else:
|
||||||
# empty album is set to DRAFT.
|
# empty album is set to DRAFT.
|
||||||
album.status = "10"
|
album.status = Album.DRAFT
|
||||||
|
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
for folder in get_folder_list():
|
for folder in get_folder_list():
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
{% if album.event_date %}
|
{% if album.event_date %}
|
||||||
Datum: {{ album.event_date }}<br>
|
Datum: {{ album.event_date }}<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if album.status == "10" %}
|
{% if album.status == album.DRAFT %}
|
||||||
DRAFT<br>
|
DRAFT<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if album.description %}
|
{% if album.description %}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<div class="grid-x">
|
<div class="grid-x">
|
||||||
{% for album in albums %}
|
{% 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" %}
|
{% if album.status == "10" %}
|
||||||
<a href="{% url 'draft-album' album.slug %}">
|
<a href="{% url 'draft-album' album.slug %}">
|
||||||
|
|||||||
Reference in New Issue
Block a user