Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
janpeterka committed Jun 30, 2023
1 parent e96c616 commit 8271776
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
19 changes: 5 additions & 14 deletions app/components/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,16 @@
class Image(BaseComponent):
def __init__(self, image, **kwargs):
super(Image, self).__init__(**kwargs)
self.src = image.url
if kwargs.get("thumbnail", False):
self.src = image.thumbnail_url
else:
self.src = image.url

self.alt = image.full_name
self.image = image


def recipe_gallery_image(image, editable=False, outer_class=None, **kwargs):
# {% set class = kwargs.pop('class', "") %}
# {% set style = kwargs.pop('style', "") %}
# {% set thumbnail = kwargs.pop('thumbnail', False) %}
# {% set with_delete = kwargs.pop('with_delete', False) %}
# {% set with_pin = kwargs.pop('with_pin', False) %}
# {% set center = kwargs.pop('center', False) %}

# {% if thumbnail %}
# {% set url = image.thumbnail_url %}
# {% else %}
# {% set url = image.url %}
# {% endif %}

if outer_class is None:
outer_class = "pos-r"
else:
Expand Down
9 changes: 6 additions & 3 deletions app/templates/recipes/_images.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
<turbo-frame id="images">
<div class="p-2">
<div class="row">
{% if editable %}
<div class="col-12 col-sm-6 col-md-3 pb-2">
{{ dropzone(action=url_for('RecipePhotoView:upload_photo', recipe_id=recipe.id), default_message="přetáhni fotku nebo klikni pro přidání.") }}
</div>
{% endif %}

{% for image in recipe.images %}
<div class="col-12 col-sm-6 col-md-3 pb-2">
{{ recipe_gallery_image(image, with_delete=editable, with_pin=editable, style="border-radius:0.4rem;") }}
</div>
{% endfor %}
</div>

{% if editable %}
{{ dropzone(action=url_for('RecipePhotoView:upload_photo', recipe_id=recipe.id), default_message="přetáhni fotku nebo klikni pro přidání.") }}
{% endif %}
</div>
</turbo-frame>

0 comments on commit 8271776

Please sign in to comment.