register inclusion_tag online_menu html def online_menu online_menu On

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
register.inclusion_tag('online_menu.html')
def online_menu():
online_menu = Online.objects.all()
return {'online_menu':online_menu}
@register.inclusion_tag('new_message.html', takes_context=True)
def new_message(context):
try:
user = context['user']
new_msg = Message.objects.filter(reciver=user,read=0).count()
return {'new_msg':new_msg}
except:
return {'new_msg':None}
@register.inclusion_tag('users_photo.html', takes_context=True)
def users_photo(context):
users_photo = Photo.objects.order_by('?')[:2]
return {'users_photo':users_photo}
def create_my_html(sender, session, last, content):
counter = Message.objects.filter(session=session).count()
messages = Message.objects.filter(session=session).order_by('id')
html = ''
for i in messages[int(last):counter]:
html += "<b style='color: blue'>"+escape(i.sender.get_profile().display_name)+"</b><br />"+bbcode(escape(i.message))+"<br /><br />"
return html