Advertisement
Mochinov

Untitled

Aug 28th, 2020 (edited)
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. @register.filter(name='set_or_redirect')
  2. def set_or_redirect(objects):
  3.     address = 'ул. ' + str(objects.street) + ' д.' + str(objects.building)
  4.     try:
  5.         if objects.subdivision_polyclinics != None :
  6.             if objects.subdivision_polyclinics.redirect:
  7.                 return '<a href="{}">Редирект</a>'.format(objects.subdivision_polyclinics.redirect)
  8.             else:
  9.                 if objects.polyclinic.redirect:
  10.                     return '<a href="{}">Редирект</a>'.format(objects.polyclinic.redirect)
  11.                 else:
  12.                     return '<a href="/new-write/{}/{}/">Записать</a>'.format( objects.polyclinic.id,address )
  13.                 return '<a href="/new-write/{}/{}/">Записать</a>'.format(objects.polyclinic.id,address )
  14.         else:
  15.             return '<a href="/new-write/{}/{}/">Записать</a>'.format(objects.polyclinic.id,address )
  16.     except Exception as e:
  17.         return '<a href="/new-write/{}/{}/">Записать</a>'.format(objects.polyclinic.id,address)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement