@ -1,3 +1,4 @@
import time
from urllib . parse import quote
import requests
@ -14,7 +15,7 @@ class Orders(models.Model):
orderName = models . CharField ( max_length = 100 , verbose_name = ' наименование ' , null = True )
orderDesc = models . TextField ( verbose_name = ' описание ' , null = True )
orderPhoto = models . ImageField ( verbose_name = ' фото ' , null = True )
orderPhotoPay = models . ImageField ( upload_to = ' photo/ ' , verbose_name = ' чек ' )
orderPhotoPay = models . ImageField ( verbose_name = ' чек ' )
orderAddress = models . CharField ( max_length = 100 , verbose_name = ' адрес доставки ' , blank = True , null = True )
orderAccess = models . CharField ( max_length = 100 , verbose_name = ' доступ ' , blank = True , null = True )
orderCreateDateTime = models . DateTimeField ( auto_now_add = True , null = True , verbose_name = ' дата и время создания ' )
@ -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 = " Уменьшить фото " ;
} }
} }
@ -135,6 +139,7 @@ class Orders(models.Model):
"""
return html
class Meta :
verbose_name_plural = ' Заказы '