def test_convert_to_list_month(self): """ Test function to render a list of months """ start_date = datetime.date(year=2013, month=9, day=3) stop_date = datetime.date(year=2014, month=2, day=5) # solution = [('1', 'September'),('2', 'October')('3', 'November'),('4', 'December')('5', 'January'),('6', 'February')] answer = convert_to_list_month(start_date, stop_date) self.assertEqual(solution, 'd')
def sidebar_box(request): linked = SocialNetwork.objects.get(name='linkedin') viadeo = SocialNetwork.objects.get(name="viadeo") google = SocialNetwork.objects.get(name="google") today = datetime.date.today() edito = Edito.objects.order_by('-created_at')[0] stop_day = prev_month(today, 3) archives = convert_to_list_month(stop_day, today) articles = last_articles(length=4) categories = Category.actifs.all() q = request.GET.get('q', '') form = SearchForm({'q': q}) return { 'linked':linked, 'viadeo': viadeo, 'google': google, 'edito': edito, 'archives': archives, 'form': form, 'last_articles': articles, 'categories': categories, }
def sidebar_box(request): linked = SocialNetwork.objects.get(name='linkedin') viadeo = SocialNetwork.objects.get(name="viadeo") google = SocialNetwork.objects.get(name="google") today = datetime.date.today() edito = Edito.objects.order_by('-created_at')[0] stop_day = prev_month(today, 3) archives = convert_to_list_month(stop_day, today) articles = last_articles(length=4) categories = Category.actifs.all() q = request.GET.get('q', '') form = SearchForm({'q': q}) return { 'linked': linked, 'viadeo': viadeo, 'google': google, 'edito': edito, 'archives': archives, 'form': form, 'last_articles': articles, 'categories': categories, }