Skip to content

Commit

Permalink
⬆️ django 4.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolas committed Oct 13, 2023
1 parent 5a47089 commit 4705091
Show file tree
Hide file tree
Showing 19 changed files with 208 additions and 228 deletions.
6 changes: 3 additions & 3 deletions footprints/batch/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django import forms
from django.utils.encoding import (
DjangoUnicodeDecodeError, force_text, smart_text)
DjangoUnicodeDecodeError, force_str, smart_str)
from footprints.batch.models import BatchRow


Expand Down Expand Up @@ -47,7 +47,7 @@ def validate_column_count(self, row):
def validate_encoding(self, row):
for col in row:
try:
force_text(col)
force_str(col)
except DjangoUnicodeDecodeError as e:
return False, e

Expand Down Expand Up @@ -93,7 +93,7 @@ def validate_clean_data(self, cleaned_data):
if not valid:
self._errors['csvfile'] = self.error_class([
self.INVALID_ENCODING.format(
smart_text(e).encode('utf-8'))])
smart_str(e).encode('utf-8'))])
break

except csv.Error:
Expand Down
26 changes: 13 additions & 13 deletions footprints/batch/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from django.conf.urls import url
from django.urls import path

from footprints.batch.views import BatchJobDetailView, BatchJobListView, \
BatchJobDeleteView, BatchRowUpdateView, BatchRowDeleteView, \
BatchJobUpdateView


urlpatterns = [
url(r'^$',
BatchJobListView.as_view(), name='batchjob-list-view'),
url(r'job/(?P<pk>\d+)/$',
BatchJobDetailView.as_view(), name='batchjob-detail-view'),
url(r'job/delete/(?P<pk>\d+)/$',
BatchJobDeleteView.as_view(), name='batchjob-delete-view'),
url(r'job/update/(?P<pk>\d+)/$',
BatchJobUpdateView.as_view(), name='batchjob-update-view'),
url(r'row/update/(?P<pk>\d+)/$',
BatchRowUpdateView.as_view(), name='batchrow-update-view'),
url(r'row/delete/(?P<pk>\d+)/$',
BatchRowDeleteView.as_view(), name='batchrow-delete-view'),
path('',
BatchJobListView.as_view(), name='batchjob-list-view'),
path('job/<int:pk>/',
BatchJobDetailView.as_view(), name='batchjob-detail-view'),
path('job/delete/<int:pk>/',
BatchJobDeleteView.as_view(), name='batchjob-delete-view'),
path('job/update/<int:pk>/',
BatchJobUpdateView.as_view(), name='batchjob-update-view'),
path('row/update/<int:pk>/',
BatchRowUpdateView.as_view(), name='batchrow-update-view'),
path('row/delete/<int:pk>/',
BatchRowDeleteView.as_view(), name='batchrow-delete-view'),
]
4 changes: 2 additions & 2 deletions footprints/batch/validators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
from edtf.edtf import EDTF


Expand All @@ -8,7 +8,7 @@ def validate_date(value):
return True

try:
s = smart_text(EDTF.from_natural_text(value))
s = smart_str(EDTF.from_natural_text(value))
return s != '' and 'invalid' not in s
except OverflowError:
return False
Expand Down
4 changes: 2 additions & 2 deletions footprints/main/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.gis.geos.point import Point
from django.db.models.fields import TextField
from django.forms.widgets import MultiWidget, TextInput
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
from reversion.admin import VersionAdmin

from footprints.main.models import Footprint, DigitalFormat, Role, \
Expand Down Expand Up @@ -104,7 +104,7 @@ class WrittenWorkAdmin(admin.ModelAdmin):


def imprint_display(obj):
return smart_text(obj.imprint)
return smart_str(obj.imprint)


class BookCopyAdmin(admin.ModelAdmin):
Expand Down
4 changes: 2 additions & 2 deletions footprints/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db.models.query_utils import Q
from django.forms.fields import MultipleChoiceField
from django.forms.models import ModelForm
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
from haystack.forms import ModelSearchForm
from registration.forms import RegistrationForm

Expand Down Expand Up @@ -324,7 +324,7 @@ def clean(self):
cleaned_data = super(ExtendedDateForm, self).clean()
edt = self.get_extended_date()

display_format = smart_text(edt)
display_format = smart_str(edt)
if 'invalid' in display_format or 'None' in display_format:
self._errors['__all__'] = self.error_class([
'Please fill out all required fields'])
Expand Down
12 changes: 6 additions & 6 deletions footprints/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.template import loader
from django.urls.base import reverse
from django.utils import timezone
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
from edtf import edtf_date
from edtf.edtf import EDTF
from past.builtins import basestring
Expand Down Expand Up @@ -102,7 +102,7 @@ def from_dict(self, values):
return ExtendedDate(edtf_format=dt)

def create_from_string(self, date_str):
edtf = smart_text(EDTF.from_natural_text(date_str))
edtf = smart_str(EDTF.from_natural_text(date_str))
return ExtendedDate.objects.create(edtf_format=edtf)


Expand Down Expand Up @@ -235,7 +235,7 @@ def end(self):
return self._validate_python_date(edtf.end_date_latest())

def match_string(self, date_str):
return self.edtf_format == smart_text(EDTF.from_natural_text(date_str))
return self.edtf_format == smart_str(EDTF.from_natural_text(date_str))


def fmt_uncertain(date_obj, result):
Expand Down Expand Up @@ -474,11 +474,11 @@ def get_or_create_by_attributes(self, name, viaf, role, born, died):
# update birth date & death date
if born and person.birth_date is None:
person.birth_date = ExtendedDate.objects.create(
edtf_format=smart_text(EDTF.from_natural_text(born)))
edtf_format=smart_str(EDTF.from_natural_text(born)))

if died and person.death_date is None:
person.death_date = ExtendedDate.objects.create(
edtf_format=smart_text(EDTF.from_natural_text(died)))
edtf_format=smart_str(EDTF.from_natural_text(died)))

person.save()
return person
Expand Down Expand Up @@ -1056,7 +1056,7 @@ class Meta:
verbose_name_plural = "Book Copies"

def __str__(self):
return "[%s] %s" % (self.id, smart_text(self.imprint))
return "[%s] %s" % (self.id, smart_str(self.imprint))

def percent_complete(self):
required = 3.0
Expand Down
28 changes: 14 additions & 14 deletions footprints/main/search_indexes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from django.utils.encoding import smart_text
from django.utils.encoding import smart_str

from django.db.models.query_utils import Q
from footprints.main.models import WrittenWork, Footprint, Person, Place, \
Expand Down Expand Up @@ -60,7 +60,7 @@ def prepare_object_type(self, obj):
return type(obj).__name__

def prepare_sort_by(self, obj):
return format_sort_by(smart_text(obj), remove_articles=True)
return format_sort_by(smart_str(obj), remove_articles=True)

def prepare_footprint_end_date(self, obj):
return obj.footprints_end_date()
Expand Down Expand Up @@ -102,7 +102,7 @@ def prepare_actor(self, obj):

def prepare_actor_title(self, obj):
# prepare all actors associated with this work
return [smart_text(actor) for actor in self._actors(obj)]
return [smart_str(actor) for actor in self._actors(obj)]


class ImprintIndex(SearchIndex, Indexable):
Expand Down Expand Up @@ -151,7 +151,7 @@ def prepare_imprint_location(self, obj):

def prepare_imprint_location_title(self, obj):
if obj.place:
return [smart_text(obj.place.canonical_place.canonical_name)]
return [smart_str(obj.place.canonical_place.canonical_name)]
return []

def prepare_footprint_location(self, obj):
Expand All @@ -166,7 +166,7 @@ def prepare_footprint_location_title(self, obj):
for f in obj.footprints():
if f.place:
name = f.place.canonical_place.canonical_name
places.append(smart_text(name))
places.append(smart_str(name))
return places

def _actors(self, obj):
Expand All @@ -180,7 +180,7 @@ def prepare_actor(self, obj):
return [actor.id for actor in self._actors(obj)]

def prepare_actor_title(self, obj):
return [smart_text(actor) for actor in self._actors(obj)]
return [smart_str(actor) for actor in self._actors(obj)]


class BookCopyIndex(SearchIndex, Indexable):
Expand Down Expand Up @@ -248,7 +248,7 @@ def prepare_imprint_location(self, obj):

def prepare_imprint_location_title(self, obj):
if obj.imprint.place:
name = smart_text(obj.imprint.place.canonical_place.canonical_name)
name = smart_str(obj.imprint.place.canonical_place.canonical_name)
return [name]
return []

Expand All @@ -263,7 +263,7 @@ def prepare_footprint_location_title(self, obj):
places = []
for f in obj.footprints():
if f.place:
name = smart_text(f.place.canonical_place.canonical_name)
name = smart_str(f.place.canonical_place.canonical_name)
places.append(name)
return places

Expand All @@ -283,7 +283,7 @@ def prepare_actor_title(self, obj):
Q(imprint=obj.imprint) |
Q(footprint__in=footprints)).distinct()

return [smart_text(actor) for actor in qs]
return [smart_str(actor) for actor in qs]

def prepare_censored(self, obj):
return obj.has_censor()
Expand Down Expand Up @@ -358,7 +358,7 @@ def prepare_ftitle(self, obj):

def prepare_flocation(self, obj):
if obj.place:
return smart_text(obj.place)
return smart_str(obj.place)

return ''

Expand Down Expand Up @@ -400,7 +400,7 @@ def prepare_footprint_location(self, obj):

def prepare_footprint_location_title(self, obj):
if obj.place:
return [smart_text(obj.place.canonical_place.canonical_name)]
return [smart_str(obj.place.canonical_place.canonical_name)]

return []

Expand All @@ -413,7 +413,7 @@ def prepare_imprint_location(self, obj):
def prepare_imprint_location_title(self, obj):
if obj.book_copy.imprint.place:
place = obj.book_copy.imprint.place
return [smart_text(place.canonical_place.canonical_name)]
return [smart_str(place.canonical_place.canonical_name)]

return []

Expand All @@ -431,7 +431,7 @@ def prepare_actor_title(self, obj):
Q(imprint=obj.book_copy.imprint) |
Q(footprint=obj)).distinct()

return [smart_text(actor) for actor in qs]
return [smart_str(actor) for actor in qs]

def prepare_has_image(self, obj):
return obj.has_at_least_one_digital_object()
Expand Down Expand Up @@ -475,4 +475,4 @@ def prepare_object_type(self, obj):
return type(obj).__name__

def prepare_sort_by(self, obj):
return format_sort_by(smart_text(obj), remove_articles=True)
return format_sort_by(smart_str(obj), remove_articles=True)
10 changes: 5 additions & 5 deletions footprints/main/serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from django.utils import timezone
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
from rest_framework import serializers
from rest_framework.fields import CharField, ReadOnlyField
from rest_framework.serializers import Serializer, HyperlinkedModelSerializer
Expand Down Expand Up @@ -134,7 +134,7 @@ def get_queryset(self):
return Actor.objects.all()

def get_display_title(self, obj):
return smart_text(obj)
return smart_str(obj)

def to_internal_value(self, data):
try:
Expand Down Expand Up @@ -219,13 +219,13 @@ class Meta:
'created_by', 'last_modified_by')

def get_work_title(self, obj):
return smart_text(obj.book_copy.imprint.work.title)
return smart_str(obj.book_copy.imprint.work.title)

def get_imprint_title(self, obj):
return smart_text(obj.book_copy.imprint.title)
return smart_str(obj.book_copy.imprint.title)

def get_book_copy_identifier(self, obj):
return smart_text(obj.book_copy.identifier())
return smart_str(obj.book_copy.identifier())


class PathmapperImprintSerializer(HyperlinkedModelSerializer):
Expand Down
14 changes: 7 additions & 7 deletions footprints/main/tests/test_search_indexes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.test.testcases import TestCase
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str

from footprints.main.search_indexes import FootprintIndex, BookCopyIndex, \
WrittenWorkIndex, ImprintIndex
Expand All @@ -20,8 +20,8 @@ def test_prepare_actor_title(self):
fp = FootprintFactory()

actors = FootprintIndex().prepare_actor_title(fp)
self.assertTrue(smart_text(fp.actor.first()) in actors)
self.assertTrue(smart_text(fp.book_copy.imprint.work.actor.first())
self.assertTrue(smart_str(fp.actor.first()) in actors)
self.assertTrue(smart_str(fp.book_copy.imprint.work.actor.first())
in actors)


Expand All @@ -44,8 +44,8 @@ def test_prepare_actor_title(self):
fp = FootprintFactory()

actors = BookCopyIndex().prepare_actor_title(fp.book_copy)
self.assertTrue(smart_text(fp.actor.first()) in actors)
self.assertTrue(smart_text(fp.book_copy.imprint.work.actor.first())
self.assertTrue(smart_str(fp.actor.first()) in actors)
self.assertTrue(smart_str(fp.book_copy.imprint.work.actor.first())
in actors)


Expand All @@ -67,7 +67,7 @@ def test_prepare_actor_title(self):
fp = FootprintFactory()

actors = ImprintIndex().prepare_actor_title(fp.book_copy.imprint)
self.assertTrue(smart_text(fp.book_copy.imprint.actor.first())
self.assertTrue(smart_str(fp.book_copy.imprint.actor.first())
in actors)


Expand Down Expand Up @@ -98,5 +98,5 @@ def test_prepare_actor_title(self):

actors = WrittenWorkIndex().prepare_actor_title(
fp.book_copy.imprint.work)
self.assertTrue(smart_text(fp.book_copy.imprint.work.actor.first())
self.assertTrue(smart_str(fp.book_copy.imprint.work.actor.first())
in actors)
8 changes: 4 additions & 4 deletions footprints/main/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.test import TestCase
from django.test.client import RequestFactory
from django.urls.base import reverse
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str

from footprints.main.forms import ContactUsForm
from footprints.main.models import Footprint, Actor, Imprint, \
Expand Down Expand Up @@ -203,12 +203,12 @@ def get_headers(self):
'Evidence Call Number,Evidence Details,')

for r in Role.objects.for_footprint():
role = 'Footprint Role ' + smart_text(r.name) + ' Actor'
role = 'Footprint Role ' + smart_str(r.name) + ' Actor'
headers += role + ','
headers += (role + ' VIAF Number,')

for r in Role.objects.for_imprint():
role = 'Imprint Role: ' + smart_text(r.name) + ' Actor'
role = 'Imprint Role: ' + smart_str(r.name) + ' Actor'
headers += role + ','
headers += (role + ' VIAF Number,')

Expand All @@ -227,7 +227,7 @@ def test_export_list(self):
p = '; '.join(p)

# Imprint Actors
actors = [smart_text(a)
actors = [smart_str(a)
for a in self.footprint2.book_copy.imprint.actor.all()]
actors = '; '.join(actors)

Expand Down
Loading

0 comments on commit 4705091

Please sign in to comment.