def test_success(self): self.request_login(self.editor.email) self.check_ajax_ok(self.post_ajax_json(url("news:disable-send-mails", self.news1.id))) news = logic.load_news(self.news1.id) self.assertTrue(news.emailed.is_DISABLED)
def test_success(self): self.request_login(self.editor.email) self.check_ajax_ok(self.post_ajax_json(url('news:disable-send-mails', self.news1.id))) news = logic.load_news(self.news1.id) self.assertTrue(news.emailed.is_DISABLED)
def test_form_errors(self): self.request_login(self.editor.email) self.check_ajax_error(self.post_ajax_json(url("news:update", self.news1.id), {}), "form_errors") news = logic.load_news(self.news1.id) self.assertEqual(news.caption, self.news1.caption) self.assertEqual(news.description, self.news1.description) self.assertEqual(news.content, self.news1.content)
def test_form_errors(self): self.request_login(self.editor.email) self.check_ajax_error(self.post_ajax_json(url('news:update', self.news1.id), {}), 'form_errors') news = logic.load_news(self.news1.id) self.assertEqual(news.caption, self.news1.caption) self.assertEqual(news.description, self.news1.description) self.assertEqual(news.content, self.news1.content)
def parse(self, context, raw_value): try: id = int(raw_value) except ValueError: self.raise_wrong_format() news = logic.load_news(id) if news is None: self.raise_wrong_value() return news
def test_success(self): self.request_login(self.editor.email) with self.check_delta(post_service_models.Message.objects.count, 1): self.check_ajax_ok(self.post_ajax_json(url("news:send-mails", self.news1.id))) last_message = post_service_prototypes.MessagePrototype._db_latest() self.assertEqual(last_message.handler.news_id, self.news1.id) news = logic.load_news(self.news1.id) self.assertTrue(news.emailed.is_EMAILED)
def test_success(self): self.request_login(self.editor.email) with self.check_delta(post_service_models.Message.objects.count, 1): self.check_ajax_ok(self.post_ajax_json(url('news:send-mails', self.news1.id))) last_message = post_service_prototypes.MessagePrototype._db_latest() self.assertEqual(last_message.handler.news_id, self.news1.id) news = logic.load_news(self.news1.id) self.assertTrue(news.emailed.is_EMAILED)
def test_success(self): self.request_login(self.editor.email) with self.check_delta(models.News.objects.all().count, 0): self.check_ajax_ok(self.post_ajax_json(url('news:update', self.news1.id), {'caption': 'updated-news-caption', 'description': 'updated-news-description', 'content': 'updated-news-content'})) news = logic.load_news(self.news1.id) self.assertEqual(news.caption, 'updated-news-caption') self.assertEqual(news.description, 'updated-news-description') self.assertEqual(news.content, 'updated-news-content')
def process(self): from the_tale.cms.news import logic as news_logic news = news_logic.load_news(self.news_id) if news is None: return True accounts = (AccountPrototype(model=account_model) for account_model in AccountPrototype._db_filter(news_subscription=True).iterator()) subject = '«Сказка»::Новости: %s' % news.caption context = {'news': news} html_content = jinja2.render(self.EMAIL_HTML_TEMPLATE, context) text_content = jinja2.render(self.EMAIL_TEXT_TEMPLATE, context) return logic.send_mail(accounts, subject, text_content, html_content)
def process(self): from the_tale.cms.news import logic as news_logic news = news_logic.load_news(self.news_id) if news is None: return True accounts = (AccountPrototype(model=account_model) for account_model in AccountPrototype._db_filter( news_subscription=True).iterator()) subject = '«Сказка»::Новости: %s' % news.caption context = {'news': news} html_content = jinja2.render(self.EMAIL_HTML_TEMPLATE, context) text_content = jinja2.render(self.EMAIL_TEXT_TEMPLATE, context) return logic.send_mail(accounts, subject, text_content, html_content)
def test_success(self): self.request_login(self.editor.email) with self.check_delta(models.News.objects.all().count, 0): self.check_ajax_ok( self.post_ajax_json( url("news:update", self.news1.id), { "caption": "updated-news-caption", "description": "updated-news-description", "content": "updated-news-content", }, ) ) news = logic.load_news(self.news1.id) self.assertEqual(news.caption, "updated-news-caption") self.assertEqual(news.description, "updated-news-description") self.assertEqual(news.content, "updated-news-content")