Browse Source

исправил баг по отображению картинок в админке #5

Anton 1 year ago
parent
commit
0a3086df05
  1. 36
      adminpanelapp/models.py

36
adminpanelapp/models.py

@ -1,3 +1,4 @@
import time
from urllib.parse import quote
import requests
@ -37,12 +38,13 @@ class Orders(models.Model):
<body>
<img src="{photo_url}" width="{width}" height="{height}" class="small-photo">
<img src="{photo_url}" width="{large_width}" height="{large_height}" class="large-photo">
<a href="#" onclick="togglePhoto()" id="toggle-button" class="button">Увеличить фото</a>
<a href="#" onclick="togglePhoto(event)" class="button">Увеличить фото</a>
<script>
function togglePhoto() {{
var smallPhoto = document.getElementsByClassName("small-photo")[0];
var largePhoto = document.getElementsByClassName("large-photo")[0];
var toggleButton = document.getElementById("toggle-button");
function togglePhoto(event) {{
var toggleButton = event.target;
var container = toggleButton.parentNode;
var smallPhoto = container.querySelector(".small-photo");
var largePhoto = container.querySelector(".large-photo");
if (smallPhoto.style.display === "none") {{
smallPhoto.style.display = "block";
@ -86,6 +88,7 @@ class Orders(models.Model):
response = requests.get(url)
data = response.json()
if data['ok']:
file_path = data["result"]["file_path"]
photo_url = f"https://api.telegram.org/file/bot{token}/{quote(file_path, safe='')}"
@ -95,20 +98,21 @@ class Orders(models.Model):
<body>
<img src="{photo_url}" width="{width}" height="{height}" class="small-photo">
<img src="{photo_url}" width="{large_width}" height="{large_height}" class="large-photo">
<a href="#" onclick="togglePhotoPay()" id="toggle-button" class="button">Увеличить фото</a>
<a href="#" onclick="togglePhoto(event)" class="button">Увеличить фото</a>
<script>
function togglePhotoPay() {{
var smallPhotoPay = document.getElementsByClassName("small-photo")[1];
var largePhotoPay = document.getElementsByClassName("large-photo")[1];
var toggleButton = document.getElementById("toggle-button");
if (smallPhotoPay.style.display === "none") {{
smallPhotoPay.style.display = "block";
largePhotoPay.style.display = "none";
function togglePhoto(event) {{
var toggleButton = event.target;
var container = toggleButton.parentNode;
var smallPhoto = container.querySelector(".small-photo");
var largePhoto = container.querySelector(".large-photo");
if (smallPhoto.style.display === "none") {{
smallPhoto.style.display = "block";
largePhoto.style.display = "none";
toggleButton.innerHTML = "Увеличить фото";
}} else {{
smallPhotoPay.style.display = "none";
largePhotoPay.style.display = "block";
smallPhoto.style.display = "none";
largePhoto.style.display = "block";
toggleButton.innerHTML = "Уменьшить фото";
}}
}}

Loading…
Cancel
Save