示例#1
0
def notification_create(request, topic_id):
    topic = get_object_or_404(Topic.objects.for_access(request.user), pk=topic_id)
    form = NotificationCreationForm(user=request.user, topic=topic, data=request.POST)

    if form.is_valid():
        form.save()
        return redirect(request.POST.get("next", topic.get_absolute_url()))
    else:
        messages.error(request, utils.render_form_errors(form))
        return redirect(request.POST.get("next", topic.get_absolute_url()))
示例#2
0
def notification_create(request, topic_id):
    topic = get_object_or_404(Topic.objects.for_access(request.user),
                              pk=topic_id)
    form = NotificationCreationForm(user=request.user,
                                    topic=topic,
                                    data=request.POST)

    if form.is_valid():
        form.save()
        return redirect(request.POST.get('next', topic.get_absolute_url()))
    else:
        messages.error(request, utils.render_form_errors(form))
        return redirect(request.POST.get('next', topic.get_absolute_url()))
示例#3
0
    def test_notification_creation(self):
        """
        create notification
        """
        category = utils.create_category()
        topic = utils.create_topic(category)
        form_data = {
            'is_active': True,
        }
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), True)

        TopicNotification.objects.create(user=self.user,
                                         topic=topic,
                                         is_active=True,
                                         action=COMMENT)
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), False)
    def test_notification_creation(self):
        """
        create notification
        """
        category = utils.create_category()
        topic = utils.create_topic(category)
        form_data = {'is_active': True, }
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), True)

        TopicNotification.objects.create(user=self.user, topic=topic,
                                         is_active=True, action=COMMENT)
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), False)
    def test_notification_creation(self):
        """
        create notification
        """
        # Should be ready to suscribe (true)
        form = NotificationCreationForm()
        self.assertEqual(form.fields['is_active'].initial, True)

        category = utils.create_category()
        topic = utils.create_topic(category)
        form_data = {'is_active': True, }
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), True)

        TopicNotification.objects.create(user=self.user, topic=topic,
                                         is_active=True, action=COMMENT)
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), False)
示例#6
0
    def test_notification_creation(self):
        """
        create notification
        """
        # Should be ready to suscribe (true)
        form = NotificationCreationForm()
        self.assertEqual(form.fields['is_active'].initial, True)

        category = utils.create_category()
        topic = utils.create_topic(category)
        form_data = {
            'is_active': True,
        }
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), True)

        TopicNotification.objects.create(user=self.user,
                                         topic=topic,
                                         is_active=True,
                                         action=COMMENT)
        form = NotificationCreationForm(data=form_data)
        form.user = self.user
        form.topic = topic
        self.assertEqual(form.is_valid(), False)