From 3d2b948e340c7b8cf90860186f0c84b79ba2bb1d Mon Sep 17 00:00:00 2001 From: test test Date: Wed, 26 May 2021 15:14:03 +0200 Subject: [PATCH] Update imports, modules, and migrate some code to python 3 / django 3 --- pdfannotator/admin.py | 6 +--- pdfannotator/models.py | 8 ++--- .../0001_initial.py | 0 .../0002_auto__add_annotationcomment.py | 0 ...ent_created__add_field_annotation_order.py | 0 ...nt_uuid__add_index_annotation_uuid__add.py | 0 .../__init__.py | 0 pdfannotator/templatetags/pdfannotator.py | 2 -- pdfannotator/urls.py | 36 +++++++++---------- 9 files changed, 23 insertions(+), 29 deletions(-) rename pdfannotator/{migrations => south_migrations}/0001_initial.py (100%) rename pdfannotator/{migrations => south_migrations}/0002_auto__add_annotationcomment.py (100%) rename pdfannotator/{migrations => south_migrations}/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py (100%) rename pdfannotator/{migrations => south_migrations}/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py (100%) rename pdfannotator/{migrations => south_migrations}/__init__.py (100%) diff --git a/pdfannotator/admin.py b/pdfannotator/admin.py index 20d6d3e..2ac44eb 100644 --- a/pdfannotator/admin.py +++ b/pdfannotator/admin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from django.contrib import admin -from pdfannotator.models import Annotation, AnnotationComment +from .models import Annotation, AnnotationComment class AnnotationAdmin(admin.ModelAdmin): @@ -12,9 +12,5 @@ class AnnotationCommentAdmin(admin.ModelAdmin): model = AnnotationComment - - admin.site.register(Annotation, AnnotationAdmin) admin.site.register(AnnotationComment, AnnotationCommentAdmin) - - diff --git a/pdfannotator/models.py b/pdfannotator/models.py index 129adaf..cf4ba54 100644 --- a/pdfannotator/models.py +++ b/pdfannotator/models.py @@ -13,8 +13,8 @@ class Annotation(models.Model): verbose_name = "Annotation" verbose_name_plural = "Annotations" - def __unicode__(self): - return unicode('Annotation %d - %s for %s' % (self.id, self.annotation_id, self.uuid)) + def __str__(self): + return str('Annotation %d - %s for %s' % (self.id, self.annotation_id, self.uuid)) class AnnotationComment(models.Model): uuid = models.CharField(db_index=True, blank=False, null=False, max_length=50) # file uuid @@ -26,8 +26,8 @@ class AnnotationComment(models.Model): verbose_name = "AnnotationComment" verbose_name_plural = "AnnotationComments" - def __unicode__(self): - return unicode('Comment %d - %s' % (self.id, self.annotation_id)) + def __str__(self): + return str('Comment %d - %s' % (self.id, self.annotation_id)) @property def annotation(self): diff --git a/pdfannotator/migrations/0001_initial.py b/pdfannotator/south_migrations/0001_initial.py similarity index 100% rename from pdfannotator/migrations/0001_initial.py rename to pdfannotator/south_migrations/0001_initial.py diff --git a/pdfannotator/migrations/0002_auto__add_annotationcomment.py b/pdfannotator/south_migrations/0002_auto__add_annotationcomment.py similarity index 100% rename from pdfannotator/migrations/0002_auto__add_annotationcomment.py rename to pdfannotator/south_migrations/0002_auto__add_annotationcomment.py diff --git a/pdfannotator/migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py b/pdfannotator/south_migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py similarity index 100% rename from pdfannotator/migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py rename to pdfannotator/south_migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py diff --git a/pdfannotator/migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py b/pdfannotator/south_migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py similarity index 100% rename from pdfannotator/migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py rename to pdfannotator/south_migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py diff --git a/pdfannotator/migrations/__init__.py b/pdfannotator/south_migrations/__init__.py similarity index 100% rename from pdfannotator/migrations/__init__.py rename to pdfannotator/south_migrations/__init__.py diff --git a/pdfannotator/templatetags/pdfannotator.py b/pdfannotator/templatetags/pdfannotator.py index 161fca9..bf40662 100644 --- a/pdfannotator/templatetags/pdfannotator.py +++ b/pdfannotator/templatetags/pdfannotator.py @@ -1,6 +1,4 @@ from django import template -from django.conf import settings - register = template.Library() diff --git a/pdfannotator/urls.py b/pdfannotator/urls.py index 569fadb..9f1b9ad 100644 --- a/pdfannotator/urls.py +++ b/pdfannotator/urls.py @@ -1,21 +1,21 @@ -try: - from django.conf.urls import * -except ImportError: # django < 1.4 - from django.conf.urls.defaults import * +from django.conf.urls import url +from . import views -# place app url patterns here -from django.conf.urls import patterns, url, include -from pdfannotator import views +urlpatterns = [ + url(r'^add-annotation/$', views.add_annotation, + name="pdfannotator-add-annotation"), -urlpatterns = patterns('', - url(r'^add-annotation/$', views.add_annotation, name="pdfannotator-add-annotation"), - - url(r'^update-annotation/$', views.update_annotation, name="pdfannotator-update-annotation"), - url(r'^delete-annotation/$', views.delete_annotation, name="pdfannotator-delete-annotation"), - url(r'^get-annotations/$', views.get_annotations, name="pdfannotator-get-annotations"), - url(r'^get-annotation/$', views.get_annotation, name="pdfannotator-get-annotation"), + url(r'^update-annotation/$', views.update_annotation, + name="pdfannotator-update-annotation"), + url(r'^delete-annotation/$', views.delete_annotation, + name="pdfannotator-delete-annotation"), + url(r'^get-annotations/$', views.get_annotations, + name="pdfannotator-get-annotations"), + url(r'^get-annotation/$', views.get_annotation, + name="pdfannotator-get-annotation"), url(r'^add-comment/$', views.add_comment, name="pdfannotator-add-comment"), - url(r'^get-comments/$', views.get_comments, name="pdfannotator-get-comments"), - url(r'^update-comment/$', views.update_comment, name="pdfannotator-update-comment"), - # url(r'^delete-comment/$', views.delete_comment, name="pdfannotator-delete-comment"), -) + url(r'^get-comments/$', views.get_comments, + name="pdfannotator-get-comments"), + url(r'^update-comment/$', views.update_comment, + name="pdfannotator-update-comment"), +] -- 2.47.3