Beispiel #1
0
def notification_update(request, pk):
    notification = get_object_or_404(TopicNotification, pk=pk, user=request.user)
    form = NotificationForm(data=request.POST, instance=notification)

    if form.is_valid():
        form.save()
        return redirect(request.POST.get('next', notification.topic.get_absolute_url()))
    else:
        messages.error(request, utils.render_form_errors(form))
        return redirect(request.POST.get('next', notification.topic.get_absolute_url()))
    def test_notification(self):
        """
        update notification
        """
        category = utils.create_category()
        topic = utils.create_topic(category)
        notification = TopicNotification.objects.create(user=self.user, topic=topic,
                                                        is_active=True, action=COMMENT)

        form_data = {'is_active': True, }
        form = NotificationForm(data=form_data, instance=notification)
        self.assertEqual(form.is_valid(), True)
Beispiel #3
0
def notification_update(request, pk):
    notification = get_object_or_404(TopicNotification,
                                     pk=pk,
                                     user=request.user)
    form = NotificationForm(data=request.POST, instance=notification)

    if form.is_valid():
        form.save()
        return redirect(
            request.POST.get('next', notification.topic.get_absolute_url()))
    else:
        messages.error(request, utils.render_form_errors(form))
        return redirect(
            request.POST.get('next', notification.topic.get_absolute_url()))
Beispiel #4
0
    def test_notification(self):
        """
        update notification
        """
        category = utils.create_category()
        topic = utils.create_topic(category)
        notification = TopicNotification.objects.create(user=self.user,
                                                        topic=topic,
                                                        is_active=True,
                                                        action=COMMENT)

        form_data = {
            'is_active': True,
        }
        form = NotificationForm(data=form_data, instance=notification)
        self.assertEqual(form.is_valid(), True)