def notify_admin(request, doc): if 'mail_admin_sent' in doc: return doc['mail_admin_sent'] = 1 request.db.doc.save(doc) author = get_doc(request, doc['doc']['user']) author_name = ct(request, author['doc']['name']) if author else u'Аноним' from core.core import get_admin try: to = get_admin(request, True)['doc']['mail'] text = '' domain = get_settings('domain') if get_const_value(request, 'only_closed_news', 'false') == 'true': if doc['doc_type'] == 'des:obj' and (not 'accept' in author['doc'] or author['doc']['accept'] == 'false'): link = 'http://'+domain+'/news/'+doc['doc']['rev'] text = 'Не удостовереный Пользователь {0} разместил новый материал. Можете просмотреть по адресу {1}'.format( ct(request, author['doc']['name']), link) else: if doc['doc_type'] == 'des:comments': link = 'http://'+domain+'/news/'+doc['doc']['owner']+'#comm_'+str(doc['doc']['comm_id']) text = u'Пользователь {0} оставил комментарий. Можете просмотреть по адресу {1}'.format(request, author_name, link) else: link = 'http://'+domain+'/news/'+doc['doc']['rev'] text = u'Пользователь {0} разместил новый материал. Можете просмотреть по адресу {1}'.format( ct(request, author['doc']['name']), link) from core.core import route_mail if text: route_mail(request, to, u'Новые материалы на сайте '+domain, text) except: pass
def is_admin(request): return get_current_user(request, True) == get_admin(request)