Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
language: python
python:
- "2.7"
- "3.4"
- "3.9"
- "3.10"
- "3.11"
env:
- DJANGO_VERSION=1.7.11
- DJANGO_VERSION=1.8.10
- DJANGO_VERSION=1.9.4
- DJANGO_VERSION=3.2.23
- DJANGO_VERSION=4.1.13
- DJANGO_VERSION=4.2.8
script: "python manage.py test batchform"
install:
- pip install Django==$DJANGO_VERSION --quiet --use-mirrors
Expand Down
4 changes: 2 additions & 2 deletions batchform/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from django import forms
from django.forms import formsets
from django.utils.encoding import force_text
from django.utils.encoding import force_str

from . import parsers
from .parsers import csv as csv_parsers
Expand Down Expand Up @@ -40,7 +40,7 @@ def clean_file(self):

raise forms.ValidationError(
"No parser could read the file. Tried with parsers %s." %
(", " % (force_text(p) for p in available_parsers)))
(", " % (force_str(p) for p in available_parsers)))


class LineFormSet(formsets.BaseFormSet):
Expand Down
2 changes: 1 addition & 1 deletion batchform/templates/batchform/lines_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "batchform/base.html" %}
{% load i18n staticfiles %}
{% load i18n static %}

{% block css %}
{{ block.super }}
Expand Down
11 changes: 9 additions & 2 deletions batchform/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@

from django import forms
from django.test import TestCase
import django.contrib.messages.storage.cookie as cookie_storage


data_dir = os.path.join(os.path.dirname(__file__), 'data')


def decode_cookie_messages(cookie):
"""Decode a cookie encoded by CookieStorage
"""
return cookie_storage.CookieStorage(request=None)._decode(cookie)


class BaseTestCase(TestCase):
urls = 'dev.urls'

Expand Down Expand Up @@ -62,7 +69,7 @@ def test_lines_form(self):
})

self.assertRedirects(response, '/')
self.assertIn("3 lines", response.cookies['messages'].value)
self.assertIn("3 lines", decode_cookie_messages(response.cookies['messages'].value)[0].message)

def test_incomplete_form(self):
response = self.client.post('/', {
Expand Down Expand Up @@ -107,4 +114,4 @@ def test_lines_form_with_deleted(self):
})

self.assertRedirects(response, '/')
self.assertIn("2 lines", response.cookies['messages'].value)
self.assertIn("2 lines", decode_cookie_messages(response.cookies['messages'].value)[0].message)
16 changes: 9 additions & 7 deletions dev/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os.path

ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
BASE_DIR = os.path.abspath(os.path.dirname(ROOT_DIR))

DEBUG = True
TEMPLATE_DEBUG = DEBUG
Expand Down Expand Up @@ -90,7 +91,7 @@
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand All @@ -105,12 +106,13 @@
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'dev.wsgi.application'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(ROOT_DIR, 'templates'),
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
}
]

INSTALLED_APPS = (
'django.contrib.auth',
Expand Down
2 changes: 1 addition & 1 deletion dev/site/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load staticfiles %}
{% load static %}
<html>
<head>
<title>django-batchform :: Demo</title>
Expand Down
8 changes: 4 additions & 4 deletions dev/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Copyright (c) 2013 Raphaël Barrois


from django.conf.urls import patterns, include, url
from django.urls import path

from . import views

urlpatterns = patterns('',
url(r'^$', views.CSVUploadView.as_view(), name='example'),
)
urlpatterns = [
path('', views.CSVUploadView.as_view(), name='example'),
]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Django>=1.7
Django>=3.2,<4.3