def test_clean(self): post_data = { 'start': '2014-12-01', 'end': '2015-01-01', 'search': 'approved', } form = ModerateLogForm(post_data) assert form.is_valid() eq_(form.cleaned_data['start'], date(2014, 12, 01)) # End date should a day ahead. eq_(form.cleaned_data['end'], date(2015, 01, 02)) eq_(form.cleaned_data['search'], mkt.LOG.APPROVE_REVIEW)
def moderatelog(request): form = ModerateLogForm(request.GET) modlog = ActivityLog.objects.editor_events() if form.is_valid(): if form.cleaned_data['start']: modlog = modlog.filter(created__gte=form.cleaned_data['start']) if form.cleaned_data['end']: modlog = modlog.filter(created__lt=form.cleaned_data['end']) if form.cleaned_data['search']: modlog = modlog.filter(action=form.cleaned_data['search'].id) pager = paginate(request, modlog, 50) data = context(request, form=form, pager=pager, tab='moderatelog') return render(request, 'reviewers/moderatelog.html', data)