From: test test Date: Wed, 26 May 2021 13:14:03 +0000 (+0200) Subject: Update imports, modules, and migrate some code to python 3 / django 3 X-Git-Tag: v1.1.0~9 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=3d2b948e340c7b8cf90860186f0c84b79ba2bb1d;p=pdfannotator.git Update imports, modules, and migrate some code to python 3 / django 3 --- 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/migrations/0001_initial.py b/pdfannotator/migrations/0001_initial.py deleted file mode 100644 index ff5fa19..0000000 --- a/pdfannotator/migrations/0001_initial.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding model 'Annotation' - db.create_table('pdfannotator_annotation', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('annotation_id', self.gf('django.db.models.fields.CharField')(max_length=50)), - ('uuid', self.gf('django.db.models.fields.CharField')(max_length=50)), - ('page', self.gf('django.db.models.fields.IntegerField')()), - ('content', self.gf('django.db.models.fields.TextField')()), - )) - db.send_create_signal('pdfannotator', ['Annotation']) - - - def backwards(self, orm): - # Deleting model 'Annotation' - db.delete_table('pdfannotator_annotation') - - - models = { - 'pdfannotator.annotation': { - 'Meta': {'object_name': 'Annotation'}, - 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), - 'content': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'page': ('django.db.models.fields.IntegerField', [], {}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - } - } - - complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/migrations/0002_auto__add_annotationcomment.py b/pdfannotator/migrations/0002_auto__add_annotationcomment.py deleted file mode 100644 index a254bb8..0000000 --- a/pdfannotator/migrations/0002_auto__add_annotationcomment.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding model 'AnnotationComment' - db.create_table('pdfannotator_annotationcomment', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('uuid', self.gf('django.db.models.fields.CharField')(max_length=50)), - ('annotation_id', self.gf('django.db.models.fields.CharField')(max_length=50)), - ('content', self.gf('django.db.models.fields.TextField')()), - )) - db.send_create_signal('pdfannotator', ['AnnotationComment']) - - - def backwards(self, orm): - # Deleting model 'AnnotationComment' - db.delete_table('pdfannotator_annotationcomment') - - - models = { - 'pdfannotator.annotation': { - 'Meta': {'object_name': 'Annotation'}, - 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), - 'content': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'page': ('django.db.models.fields.IntegerField', [], {}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'pdfannotator.annotationcomment': { - 'Meta': {'object_name': 'AnnotationComment'}, - 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), - 'content': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - } - } - - complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py b/pdfannotator/migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py deleted file mode 100644 index 7ec1b22..0000000 --- a/pdfannotator/migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'AnnotationComment.created' - db.add_column('pdfannotator_annotationcomment', 'created', - self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, default=datetime.datetime(2018, 11, 16, 0, 0), blank=True), - keep_default=False) - - # Adding field 'Annotation.order' - db.add_column('pdfannotator_annotation', 'order', - self.gf('django.db.models.fields.CharField')(default='1', max_length=10), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'AnnotationComment.created' - db.delete_column('pdfannotator_annotationcomment', 'created') - - # Deleting field 'Annotation.order' - db.delete_column('pdfannotator_annotation', 'order') - - - models = { - 'pdfannotator.annotation': { - 'Meta': {'object_name': 'Annotation'}, - 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), - 'content': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.CharField', [], {'max_length': '10'}), - 'page': ('django.db.models.fields.IntegerField', [], {}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'pdfannotator.annotationcomment': { - 'Meta': {'object_name': 'AnnotationComment'}, - 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), - 'content': ('django.db.models.fields.TextField', [], {}), - 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - } - } - - complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py b/pdfannotator/migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py deleted file mode 100644 index 8c7e2fa..0000000 --- a/pdfannotator/migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding index on 'AnnotationComment', fields ['uuid'] - db.create_index('pdfannotator_annotationcomment', ['uuid']) - - # Adding index on 'Annotation', fields ['uuid'] - db.create_index('pdfannotator_annotation', ['uuid']) - - # Adding index on 'Annotation', fields ['annotation_id'] - db.create_index('pdfannotator_annotation', ['annotation_id']) - - - def backwards(self, orm): - # Removing index on 'Annotation', fields ['annotation_id'] - db.delete_index('pdfannotator_annotation', ['annotation_id']) - - # Removing index on 'Annotation', fields ['uuid'] - db.delete_index('pdfannotator_annotation', ['uuid']) - - # Removing index on 'AnnotationComment', fields ['uuid'] - db.delete_index('pdfannotator_annotationcomment', ['uuid']) - - - models = { - 'pdfannotator.annotation': { - 'Meta': {'object_name': 'Annotation'}, - 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), - 'content': ('django.db.models.fields.TextField', [], {}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'order': ('django.db.models.fields.CharField', [], {'max_length': '10'}), - 'page': ('django.db.models.fields.IntegerField', [], {}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) - }, - 'pdfannotator.annotationcomment': { - 'Meta': {'object_name': 'AnnotationComment'}, - 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), - 'content': ('django.db.models.fields.TextField', [], {}), - 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) - } - } - - complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/migrations/__init__.py b/pdfannotator/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 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/south_migrations/0001_initial.py b/pdfannotator/south_migrations/0001_initial.py new file mode 100644 index 0000000..ff5fa19 --- /dev/null +++ b/pdfannotator/south_migrations/0001_initial.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'Annotation' + db.create_table('pdfannotator_annotation', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('annotation_id', self.gf('django.db.models.fields.CharField')(max_length=50)), + ('uuid', self.gf('django.db.models.fields.CharField')(max_length=50)), + ('page', self.gf('django.db.models.fields.IntegerField')()), + ('content', self.gf('django.db.models.fields.TextField')()), + )) + db.send_create_signal('pdfannotator', ['Annotation']) + + + def backwards(self, orm): + # Deleting model 'Annotation' + db.delete_table('pdfannotator_annotation') + + + models = { + 'pdfannotator.annotation': { + 'Meta': {'object_name': 'Annotation'}, + 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'content': ('django.db.models.fields.TextField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'page': ('django.db.models.fields.IntegerField', [], {}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/south_migrations/0002_auto__add_annotationcomment.py b/pdfannotator/south_migrations/0002_auto__add_annotationcomment.py new file mode 100644 index 0000000..a254bb8 --- /dev/null +++ b/pdfannotator/south_migrations/0002_auto__add_annotationcomment.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'AnnotationComment' + db.create_table('pdfannotator_annotationcomment', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('uuid', self.gf('django.db.models.fields.CharField')(max_length=50)), + ('annotation_id', self.gf('django.db.models.fields.CharField')(max_length=50)), + ('content', self.gf('django.db.models.fields.TextField')()), + )) + db.send_create_signal('pdfannotator', ['AnnotationComment']) + + + def backwards(self, orm): + # Deleting model 'AnnotationComment' + db.delete_table('pdfannotator_annotationcomment') + + + models = { + 'pdfannotator.annotation': { + 'Meta': {'object_name': 'Annotation'}, + 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'content': ('django.db.models.fields.TextField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'page': ('django.db.models.fields.IntegerField', [], {}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'pdfannotator.annotationcomment': { + 'Meta': {'object_name': 'AnnotationComment'}, + 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'content': ('django.db.models.fields.TextField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/south_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 new file mode 100644 index 0000000..7ec1b22 --- /dev/null +++ b/pdfannotator/south_migrations/0003_auto__add_field_annotationcomment_created__add_field_annotation_order.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'AnnotationComment.created' + db.add_column('pdfannotator_annotationcomment', 'created', + self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, default=datetime.datetime(2018, 11, 16, 0, 0), blank=True), + keep_default=False) + + # Adding field 'Annotation.order' + db.add_column('pdfannotator_annotation', 'order', + self.gf('django.db.models.fields.CharField')(default='1', max_length=10), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'AnnotationComment.created' + db.delete_column('pdfannotator_annotationcomment', 'created') + + # Deleting field 'Annotation.order' + db.delete_column('pdfannotator_annotation', 'order') + + + models = { + 'pdfannotator.annotation': { + 'Meta': {'object_name': 'Annotation'}, + 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'content': ('django.db.models.fields.TextField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.CharField', [], {'max_length': '10'}), + 'page': ('django.db.models.fields.IntegerField', [], {}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'pdfannotator.annotationcomment': { + 'Meta': {'object_name': 'AnnotationComment'}, + 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'content': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/south_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 new file mode 100644 index 0000000..8c7e2fa --- /dev/null +++ b/pdfannotator/south_migrations/0004_auto__add_index_annotationcomment_uuid__add_index_annotation_uuid__add.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding index on 'AnnotationComment', fields ['uuid'] + db.create_index('pdfannotator_annotationcomment', ['uuid']) + + # Adding index on 'Annotation', fields ['uuid'] + db.create_index('pdfannotator_annotation', ['uuid']) + + # Adding index on 'Annotation', fields ['annotation_id'] + db.create_index('pdfannotator_annotation', ['annotation_id']) + + + def backwards(self, orm): + # Removing index on 'Annotation', fields ['annotation_id'] + db.delete_index('pdfannotator_annotation', ['annotation_id']) + + # Removing index on 'Annotation', fields ['uuid'] + db.delete_index('pdfannotator_annotation', ['uuid']) + + # Removing index on 'AnnotationComment', fields ['uuid'] + db.delete_index('pdfannotator_annotationcomment', ['uuid']) + + + models = { + 'pdfannotator.annotation': { + 'Meta': {'object_name': 'Annotation'}, + 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'content': ('django.db.models.fields.TextField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.CharField', [], {'max_length': '10'}), + 'page': ('django.db.models.fields.IntegerField', [], {}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) + }, + 'pdfannotator.annotationcomment': { + 'Meta': {'object_name': 'AnnotationComment'}, + 'annotation_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'content': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) + } + } + + complete_apps = ['pdfannotator'] \ No newline at end of file diff --git a/pdfannotator/south_migrations/__init__.py b/pdfannotator/south_migrations/__init__.py new file mode 100644 index 0000000..e69de29 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"), +]