def _prepare_glob_dict(): email_list = EmailModel().all() email_list.order("-date") product_list = ProductModel().all() product_list.order("-date") images_list = ImageModel().all() images_list.order("-date") propertie_list = PropertieModel().all() propertie_list.order("-date") comment_list = CommentModel().all() comment_list.filter("category", COMMENT_CATEGORY_PAGE) comment_list.order("-date") twitter_list = CommentModel().all() twitter_list.filter("category", COMMENT_CATEGORY_TWITTER) twitter_list.order("-date") glob_dict = { 'langs':CMS_LANGUAGES, 'page_list':get_pages(), 'blog_list':get_blog_pages(), 'menu_list':get_menus(), 'email_list':email_list, 'product_list':product_list, 'comment_list':comment_list, 'twitter_list':twitter_list, 'image_list':images_list, 'propertie_list':propertie_list, "admin_menu" : admin_menu } return glob_dict
def inline(self): count = self.request.get('count') to = self.request.get('to') id = self.request.get('id') email = EmailModel().get_by_id(int(id)) attachment = email.attachments attachments = [] if attachment: list = attachment.split(",") for id in list: image = ImageModel.get_by_id(int(id)) if image: attachments.append((image.title + ".png", image.content)) params = dict(sender=email.send_from, to=to, subject=email.subject, body=email.message, html=email.message ) if attachments: params['attachment'] = attachments statistic = EmailStatisticModel() statistic.count = int(count) statistic.send_to = to statistic.subject = email.subject try: mail.send_mail(**params) statistic.status = "OK" except Exception, e: logging.error(e) statistic.status = "Fail %s from: %s to: %s" % (str(e), email.send_from, to)