예제 #1
0
파일: tests.py 프로젝트: 32x32/fufufuu
    def test_moderator_report_manga_form_set_remove(self):
        report_list = ReportManga.open.filter(manga=self.manga)
        report_id_set = set(report_list.values_list('id', flat=True))
        report_count = report_list.count()
        data = {
            'form-TOTAL_FORMS': report_count,
            'form-INITIAL_FORMS': report_count,
            'form-MAX_NUM_FORMS': '100',
            'action': 'remove',
        }
        for i, report in enumerate(report_list):
            data['form-{}-id'.format(i)] = report.id
            data['form-{}-quality'.format(i)] = ReportQuality.GOOD

        formset_cls = ModeratorReportMangaView.get_formset_cls()
        formset = formset_cls(queryset=report_list, data=data)
        self.assertTrue(formset.is_valid())

        resolution = formset.save(user=self.user, manga=self.manga)
        self.assertTrue(resolution.removed)
        self.assertEqual(resolution.manga, self.manga)

        manga = Manga.objects.get(id=self.manga.id)
        self.assertEqual(manga.status, MangaStatus.REMOVED)

        closed_report_list = ReportManga.closed.filter(resolution=resolution)
        self.assertEqual(set(closed_report_list.values_list('id', flat=True)), report_id_set)
        for report in closed_report_list:
            self.assertEqual(report.quality, ReportQuality.GOOD)
예제 #2
0
파일: tests.py 프로젝트: 32x32/fufufuu
 def test_moderator_report_manga_form_set_missing_action(self):
     data = {
         'form-TOTAL_FORMS': '0',
         'form-INITIAL_FORMS': '0',
         'form-MAX_NUM_FORMS': '100',
     }
     formset_cls = ModeratorReportMangaView.get_formset_cls()
     formset = formset_cls(queryset=ReportManga.open.none(), data=data)
     self.assertFalse(formset.is_valid())
     self.assertEqual(formset.non_form_errors(), ['No action has been selected for the manga.'])
예제 #3
0
파일: tests.py 프로젝트: 32x32/fufufuu
    def test_moderator_report_manga_form_set_invalid(self):
        report_list = ReportManga.open.filter(manga=self.manga)
        report_count = report_list.count()
        data = {
            'form-TOTAL_FORMS': report_count,
            'form-INITIAL_FORMS': report_count,
            'form-MAX_NUM_FORMS': '100',
            'action': 'remove',
        }
        for i, report in enumerate(report_list):
            data['form-{}-id'.format(i)] = report.id

        formset_cls = ModeratorReportMangaView.get_formset_cls()
        formset = formset_cls(queryset=report_list, data=data)
        self.assertFalse(formset.is_valid())
        self.assertEqual(formset.errors, [{'quality': ['This field is required.']} for _ in range(report_count)])
예제 #4
0
파일: urls.py 프로젝트: 32x32/fufufuu
from django.conf.urls import patterns, url
from fufufuu.moderator.views import ModeratorReportMangaListView, ModeratorReportMangaView


urlpatterns = patterns('',

    url(r'^report/manga/$',                 ModeratorReportMangaListView.as_view(), name='moderator.report.manga.list'),
    url(r'^report/manga/(?P<id>\d+)/$',     ModeratorReportMangaView.as_view(), name='moderator.report.manga'),

)