Skip to content

Commit

Permalink
image name and mexican flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-allaway committed Jul 19, 2024
1 parent f90ea6d commit 9b77eeb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions django/core/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ <h1>{% translate 'ProjectTitle' %}</h1>

<!-- Language -->
<div id="language-show">
{% if LANGUAGE_CODE == 'es' %}🇪🇸{% elif LANGUAGE_CODE == 'en' %}🇬🇧{% endif%}
{% if LANGUAGE_CODE == 'es' %}🇲🇽{% elif LANGUAGE_CODE == 'en' %}🇬🇧{% endif%}
</div>
<div id="language-popup">
<ul id="lang-options" class="navbar-nav">
{% get_available_languages as languages %}
{% for lang_code, lang_name in languages %}
<li>
<a href="{% language_url lang_code request.get_full_path %}">
{% if lang_code == 'es' %}🇪🇸{% elif lang_code == 'en' %}🇬🇧{% endif%}
{% if lang_code == 'es' %}🇲🇽{% elif lang_code == 'en' %}🇬🇧{% endif%}
{{ lang_name }}
</a>
</li>
Expand Down
18 changes: 18 additions & 0 deletions django/photographs/migrations/0002_photograph_image_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.14 on 2024-07-19 13:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('photographs', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='photograph',
name='image_name',
field=models.CharField(blank=True, help_text='A brief name/title for the image', max_length=255, null=True),
),
]
9 changes: 3 additions & 6 deletions django/photographs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Photograph(models.Model):
related_name = 'photographs'

image = models.ImageField(upload_to='photographs', blank=True, null=True)
image_name = models.CharField(max_length=255, blank=True, null=True, help_text="A brief name/title for the image")
description_es = RichTextUploadingField(blank=True, null=True, verbose_name='Description (Spanish)')
description_en = RichTextUploadingField(blank=True, null=True, verbose_name='Description (English)')
acknowledgements = models.TextField(blank=True, null=True)
Expand All @@ -29,15 +30,11 @@ class Photograph(models.Model):
def admin_url(self):
return reverse('admin:photographs_photograph_change', args=[self.id])

@property
def image_name(self):
return str(self.image.name).split('/')[-1].split('.')[0]

def __str__(self):
return f'Photograph #{self.id}: {self.image_name}'
return self.image_name if self.image_name else f'Photograph #{self.id}'

def get_absolute_url(self):
return reverse('photographs:detail', args=[self.meta_slug])
return reverse('photographs:detail', args=[self.id])


class PhotographUserContribution(models.Model):
Expand Down

0 comments on commit 9b77eeb

Please sign in to comment.