Пример #1
0
    def test_restricted(self):
        self.request_login(self.editor.email)

        self.news1.emailed = relations.EMAILED_STATE.random(exclude=(relations.EMAILED_STATE.NOT_EMAILED,))
        logic.save_news(self.news1)

        self.check_ajax_error(self.post_ajax_json(url("news:disable-send-mails", self.news1.id)), "wrong_mail_state")
Пример #2
0
def update(context):
    context.news.caption = context.form.c.caption
    context.news.description = context.form.c.description
    context.news.content = context.form.c.content

    logic.save_news(context.news)

    return dext_views.AjaxOk(content={'next_url': url('news:show', context.news.id)})
Пример #3
0
    def test_restricted(self):
        self.request_login(self.editor.email)

        self.news1.emailed = relations.EMAILED_STATE.random(exclude=(relations.EMAILED_STATE.NOT_EMAILED,))
        logic.save_news(self.news1)

        with self.check_not_changed(post_service_models.Message.objects.count):
            self.check_ajax_error(self.post_ajax_json(url("news:send-mails", self.news1.id)), "wrong_mail_state")
Пример #4
0
    def test_restricted(self):
        self.request_login(self.editor.email)

        self.news1.emailed = relations.EMAILED_STATE.random(exclude=(relations.EMAILED_STATE.NOT_EMAILED,))
        logic.save_news(self.news1)

        self.check_ajax_error(self.post_ajax_json(url('news:disable-send-mails', self.news1.id)),
                              'wrong_mail_state')
Пример #5
0
def disable_send_mails(context):
    if not context.news.emailed.is_NOT_EMAILED:
        raise dext_views.exceptions.ViewError(code='wrong_mail_state',
                                              message='Рассылку этой новости нельзя запретить')

    context.news.emailed = relations.EMAILED_STATE.DISABLED
    logic.save_news(context.news)

    return dext_views.AjaxOk()
Пример #6
0
def update(context):
    context.news.caption = context.form.c.caption
    context.news.description = context.form.c.description
    context.news.content = context.form.c.content

    logic.save_news(context.news)

    return dext_views.AjaxOk(
        content={'next_url': url('news:show', context.news.id)})
Пример #7
0
    def test_restricted(self):
        self.request_login(self.editor.email)

        self.news1.emailed = relations.EMAILED_STATE.random(exclude=(relations.EMAILED_STATE.NOT_EMAILED,))
        logic.save_news(self.news1)

        with self.check_not_changed(post_service_models.Message.objects.count):
            self.check_ajax_error(self.post_ajax_json(url('news:send-mails', self.news1.id)),
                                  'wrong_mail_state')
Пример #8
0
def disable_send_mails(context):
    if not context.news.emailed.is_NOT_EMAILED:
        raise dext_views.exceptions.ViewError(
            code='wrong_mail_state',
            message=u'Рассылку этой новости нельзя запретить')

    context.news.emailed = relations.EMAILED_STATE.DISABLED
    logic.save_news(context.news)

    return dext_views.AjaxOk()
Пример #9
0
def publish_on_forum(context):

    if conf.settings.FORUM_CATEGORY_UID is None:
        raise dext_views.exceptions.ViewError(
            code='forum_category_not_specified',
            message=
            u'try to publish news on forum when FORUM_CATEGORY_ID has not specified'
        )

    if forum_prototypes.SubCategoryPrototype.get_by_uid(
            conf.settings.FORUM_CATEGORY_UID) is None:
        raise dext_views.exceptions.ViewError(
            code='forum_category_not_exists',
            message=
            u'try to publish news on forum when FORUM_CATEGORY_ID has not exists'
        )

    if context.news.forum_thread_id is not None:
        raise dext_views.exceptions.ViewError(
            code='forum_thread_already_exists',
            message=
            u'try to publish news on forum when FORUM_CATEGORY_ID has not specified'
        )

    thread = forum_prototypes.ThreadPrototype.create(
        forum_prototypes.SubCategoryPrototype.get_by_uid(
            conf.settings.FORUM_CATEGORY_UID),
        caption=context.news.caption,
        author=accounts_logic.get_system_user(),
        text=context.news.content,
        markup_method=forum_relations.MARKUP_METHOD.MARKDOWN)

    context.news.forum_thread_id = thread.id
    logic.save_news(context.news)

    return dext_views.AjaxOk(
        content={'next_url': url('forum:threads:show', thread.id)})
Пример #10
0
def publish_on_forum(context):

    if conf.settings.FORUM_CATEGORY_UID is None:
        raise dext_views.exceptions.ViewError(code='forum_category_not_specified',
                                              message='try to publish news on forum when FORUM_CATEGORY_ID has not specified')

    if forum_prototypes.SubCategoryPrototype.get_by_uid(conf.settings.FORUM_CATEGORY_UID) is None:
        raise dext_views.exceptions.ViewError(code='forum_category_not_exists',
                                              message='try to publish news on forum when FORUM_CATEGORY_ID has not exists')

    if context.news.forum_thread_id is not None:
        raise dext_views.exceptions.ViewError(code='forum_thread_already_exists',
                                              message='try to publish news on forum when FORUM_CATEGORY_ID has not specified')

    thread = forum_prototypes.ThreadPrototype.create(forum_prototypes.SubCategoryPrototype.get_by_uid(conf.settings.FORUM_CATEGORY_UID ),
                                                     caption=context.news.caption,
                                                     author=accounts_logic.get_system_user(),
                                                     text=context.news.content,
                                                     markup_method=forum_relations.MARKUP_METHOD.MARKDOWN)

    context.news.forum_thread_id = thread.id
    logic.save_news(context.news)

    return dext_views.AjaxOk(content={'next_url': url('forum:threads:show', thread.id)})