Skip to content

Commit

Permalink
Another htmx fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandgeider committed Dec 5, 2024
1 parent fae102d commit b027470
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions wger/gallery/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class Meta:
blank=True,
)

def __str__(self):
"""
Return a more human-readable representation
"""
return f'Gallery image #{self.pk}'

def get_owner_object(self):
"""
Returns the object that has owner information
Expand Down
20 changes: 15 additions & 5 deletions wger/gallery/templates/images/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,33 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{ image.date }}</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<button type="button" class="close" data-bs-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<a href="{{ image.image.url }}">
<img src="{{ image.image.url }}" class="img-fluid">
<img src="{{ image.image.url }}" class="img-fluid" alt="">
</a>
{% if image.description %}
<p> {{ image.description }}</p>
{% endif %}

</div>
<div class="modal-footer">
<a href="{% url 'gallery:images:delete' image.id %}"
class="btn btn-primary">
{% url 'gallery:images:delete' image.id as url %}
<a
href="{{ url }}"
class="btn btn-primary"
hx-get="{{ url }}"
hx-target="#ajax-info-content"
data-bs-toggle="modal"
data-bs-target="#wger-ajax-info"
>
<span class="{% fa_class 'trash' %}"></span>
</a>

<a href="{% url 'gallery:images:edit' image.id %}" class="btn btn-primary">
<span class="{% fa_class 'edit' %}"></span>
</a>
Expand All @@ -47,7 +56,8 @@ <h5 class="modal-title" id="exampleModalLabel">{{ image.date }}</h5>
<div class="col-sm-6 col-lg-4 mb-4">
<div class="card">
<a href="#" data-bs-toggle="modal" data-bs-target="#modalImage{{ image.id }}">
<img class="card-img-top" src="{{ image.image.url }}" alt="{{ image.description }}">
<img class="card-img-top" src="{{ image.image.url }}"
alt="{{ image.description }}">
</a>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions wger/gallery/views/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ImageAddView(WgerFormMixin, CreateView):
model = Image
form_class = ImageForm
title = _('Add')
template_name = 'form_content.html'

def get_initial(self):
"""
Expand Down Expand Up @@ -92,6 +93,7 @@ class ImageUpdateView(WgerFormMixin, LoginRequiredMixin, UpdateView):

model = Image
form_class = ImageForm
template_name = 'form_content.html'

def get_context_data(self, **kwargs):
context = super(ImageUpdateView, self).get_context_data(**kwargs)
Expand Down

0 comments on commit b027470

Please sign in to comment.