From 3035320e8218c3bf661185c8217e69c31a8fdc37 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 21 Jun 2017 11:27:53 +0100 Subject: [PATCH] Run through 2-to-3 converter. This is not in a working state --- PyRIGS/formats/en/formats.py | 2 +- RIGS/finance.py | 2 +- RIGS/migrations/0001_initial.py | 2 +- RIGS/migrations/0002_modelcomment_person.py | 2 +- RIGS/migrations/0003_auto_20141031_0219.py | 2 +- RIGS/migrations/0004_organisation.py | 2 +- RIGS/migrations/0005_auto_20141104_1619.py | 2 +- RIGS/migrations/0006_auto_20141105_1553.py | 2 +- RIGS/migrations/0007_vatrate.py | 2 +- RIGS/migrations/0008_auto_20141105_1908.py | 2 +- RIGS/migrations/0009_auto_20141105_1916.py | 2 +- RIGS/migrations/0010_auto_20141105_2219.py | 2 +- RIGS/migrations/0011_venue_address.py | 2 +- RIGS/migrations/0012_auto_20141106_0253.py | 2 +- RIGS/migrations/0013_auto_20141202_0041.py | 2 +- RIGS/migrations/0014_auto_20141208_0220.py | 2 +- RIGS/migrations/0015_auto_20141208_0233.py | 2 +- RIGS/migrations/0016_auto_20150127_1905.py | 2 +- RIGS/migrations/0017_auto_20150129_2041.py | 2 +- RIGS/migrations/0018_auto_20150130_0016.py | 2 +- RIGS/migrations/0019_auto_20150131_1919.py | 2 +- RIGS/migrations/0020_auto_20150303_0243.py | 2 +- RIGS/migrations/0021_auto_20150420_1155.py | 2 +- RIGS/migrations/0022_auto_20150424_2104.py | 2 +- RIGS/migrations/0023_auto_20150529_0048.py | 2 +- RIGS/migrations/0024_auto_20160229_2042.py | 2 +- RIGS/migrations/0025_auto_20160331_1302.py | 2 +- RIGS/migrations/0025_eventauthorisation.py | 2 +- RIGS/migrations/0026_auto_20170510_1846.py | 2 +- ...26_remove_eventauthorisation_created_at.py | 2 +- .../0027_eventauthorisation_event_singular.py | 2 +- .../0029_eventauthorisation_sent_by.py | 2 +- RIGS/migrations/0030_auth_request_sending.py | 2 +- RIGS/migrations/0031_merge_20170512_2102.py | 2 +- RIGS/models.py | 4 +-- RIGS/rigboard.py | 10 +++--- RIGS/signals.py | 6 ++-- RIGS/templatetags/filters.py | 2 +- RIGS/test_functional.py | 18 +++++------ RIGS/test_models.py | 32 +++++++++---------- RIGS/test_unit.py | 20 ++++++------ RIGS/versioning.py | 8 ++--- RIGS/views.py | 1 + importer.py | 24 +++++++------- 44 files changed, 97 insertions(+), 96 deletions(-) diff --git a/PyRIGS/formats/en/formats.py b/PyRIGS/formats/en/formats.py index f10454b6..f9b9d4b9 100644 --- a/PyRIGS/formats/en/formats.py +++ b/PyRIGS/formats/en/formats.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + DATETIME_FORMAT = ('d/m/Y H:i') DATE_FORMAT = ('d/m/Y') diff --git a/RIGS/finance.py b/RIGS/finance.py index 2c9f21c0..422d9e3b 100644 --- a/RIGS/finance.py +++ b/RIGS/finance.py @@ -1,4 +1,4 @@ -import cStringIO as StringIO +import io as StringIO import datetime import re diff --git a/RIGS/migrations/0001_initial.py b/RIGS/migrations/0001_initial.py index 62687347..8440a997 100644 --- a/RIGS/migrations/0001_initial.py +++ b/RIGS/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations import django.core.validators diff --git a/RIGS/migrations/0002_modelcomment_person.py b/RIGS/migrations/0002_modelcomment_person.py index 346d46f0..27cb744c 100644 --- a/RIGS/migrations/0002_modelcomment_person.py +++ b/RIGS/migrations/0002_modelcomment_person.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations from django.conf import settings diff --git a/RIGS/migrations/0003_auto_20141031_0219.py b/RIGS/migrations/0003_auto_20141031_0219.py index 3bb2f635..ce949ac0 100644 --- a/RIGS/migrations/0003_auto_20141031_0219.py +++ b/RIGS/migrations/0003_auto_20141031_0219.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0004_organisation.py b/RIGS/migrations/0004_organisation.py index bf1bbbf4..06e29955 100644 --- a/RIGS/migrations/0004_organisation.py +++ b/RIGS/migrations/0004_organisation.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations import RIGS.models diff --git a/RIGS/migrations/0005_auto_20141104_1619.py b/RIGS/migrations/0005_auto_20141104_1619.py index 0e8b24d2..4bc9e97c 100644 --- a/RIGS/migrations/0005_auto_20141104_1619.py +++ b/RIGS/migrations/0005_auto_20141104_1619.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0006_auto_20141105_1553.py b/RIGS/migrations/0006_auto_20141105_1553.py index a125838e..67b53326 100644 --- a/RIGS/migrations/0006_auto_20141105_1553.py +++ b/RIGS/migrations/0006_auto_20141105_1553.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0007_vatrate.py b/RIGS/migrations/0007_vatrate.py index 07d7e497..02aa1625 100644 --- a/RIGS/migrations/0007_vatrate.py +++ b/RIGS/migrations/0007_vatrate.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations import RIGS.models diff --git a/RIGS/migrations/0008_auto_20141105_1908.py b/RIGS/migrations/0008_auto_20141105_1908.py index 2bba681c..93203ff3 100644 --- a/RIGS/migrations/0008_auto_20141105_1908.py +++ b/RIGS/migrations/0008_auto_20141105_1908.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations from django.conf import settings diff --git a/RIGS/migrations/0009_auto_20141105_1916.py b/RIGS/migrations/0009_auto_20141105_1916.py index 77973814..2ea37023 100644 --- a/RIGS/migrations/0009_auto_20141105_1916.py +++ b/RIGS/migrations/0009_auto_20141105_1916.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations from django.conf import settings diff --git a/RIGS/migrations/0010_auto_20141105_2219.py b/RIGS/migrations/0010_auto_20141105_2219.py index e6a9ef25..6576c412 100644 --- a/RIGS/migrations/0010_auto_20141105_2219.py +++ b/RIGS/migrations/0010_auto_20141105_2219.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations from django.conf import settings diff --git a/RIGS/migrations/0011_venue_address.py b/RIGS/migrations/0011_venue_address.py index 5973866f..eda0e1ba 100644 --- a/RIGS/migrations/0011_venue_address.py +++ b/RIGS/migrations/0011_venue_address.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0012_auto_20141106_0253.py b/RIGS/migrations/0012_auto_20141106_0253.py index 10fa6429..2c5c7b3a 100644 --- a/RIGS/migrations/0012_auto_20141106_0253.py +++ b/RIGS/migrations/0012_auto_20141106_0253.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0013_auto_20141202_0041.py b/RIGS/migrations/0013_auto_20141202_0041.py index 9403ad12..002a715e 100644 --- a/RIGS/migrations/0013_auto_20141202_0041.py +++ b/RIGS/migrations/0013_auto_20141202_0041.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0014_auto_20141208_0220.py b/RIGS/migrations/0014_auto_20141208_0220.py index f8d97f8f..54df0a7b 100644 --- a/RIGS/migrations/0014_auto_20141208_0220.py +++ b/RIGS/migrations/0014_auto_20141208_0220.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0015_auto_20141208_0233.py b/RIGS/migrations/0015_auto_20141208_0233.py index df842ece..9562110d 100644 --- a/RIGS/migrations/0015_auto_20141208_0233.py +++ b/RIGS/migrations/0015_auto_20141208_0233.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0016_auto_20150127_1905.py b/RIGS/migrations/0016_auto_20150127_1905.py index 9056c4f8..82551163 100644 --- a/RIGS/migrations/0016_auto_20150127_1905.py +++ b/RIGS/migrations/0016_auto_20150127_1905.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations from django.conf import settings diff --git a/RIGS/migrations/0017_auto_20150129_2041.py b/RIGS/migrations/0017_auto_20150129_2041.py index e90491a6..d55c658b 100644 --- a/RIGS/migrations/0017_auto_20150129_2041.py +++ b/RIGS/migrations/0017_auto_20150129_2041.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0018_auto_20150130_0016.py b/RIGS/migrations/0018_auto_20150130_0016.py index 67c3eb97..c0ac2e55 100644 --- a/RIGS/migrations/0018_auto_20150130_0016.py +++ b/RIGS/migrations/0018_auto_20150130_0016.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0019_auto_20150131_1919.py b/RIGS/migrations/0019_auto_20150131_1919.py index c55541b6..b696f28d 100644 --- a/RIGS/migrations/0019_auto_20150131_1919.py +++ b/RIGS/migrations/0019_auto_20150131_1919.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0020_auto_20150303_0243.py b/RIGS/migrations/0020_auto_20150303_0243.py index 9d9ee33f..bde7dd49 100644 --- a/RIGS/migrations/0020_auto_20150303_0243.py +++ b/RIGS/migrations/0020_auto_20150303_0243.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0021_auto_20150420_1155.py b/RIGS/migrations/0021_auto_20150420_1155.py index 269f9bc1..e89d5651 100644 --- a/RIGS/migrations/0021_auto_20150420_1155.py +++ b/RIGS/migrations/0021_auto_20150420_1155.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0022_auto_20150424_2104.py b/RIGS/migrations/0022_auto_20150424_2104.py index cdc3abe0..d5f818fb 100644 --- a/RIGS/migrations/0022_auto_20150424_2104.py +++ b/RIGS/migrations/0022_auto_20150424_2104.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0023_auto_20150529_0048.py b/RIGS/migrations/0023_auto_20150529_0048.py index 27fbc42b..2e18701f 100644 --- a/RIGS/migrations/0023_auto_20150529_0048.py +++ b/RIGS/migrations/0023_auto_20150529_0048.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations import django.core.validators diff --git a/RIGS/migrations/0024_auto_20160229_2042.py b/RIGS/migrations/0024_auto_20160229_2042.py index 163ff8e4..318d9ff3 100644 --- a/RIGS/migrations/0024_auto_20160229_2042.py +++ b/RIGS/migrations/0024_auto_20160229_2042.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations import django.db.models.deletion diff --git a/RIGS/migrations/0025_auto_20160331_1302.py b/RIGS/migrations/0025_auto_20160331_1302.py index eacc7bfd..8f6311c4 100644 --- a/RIGS/migrations/0025_auto_20160331_1302.py +++ b/RIGS/migrations/0025_auto_20160331_1302.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by Django 1.9.4 on 2016-03-31 12:02 -from __future__ import unicode_literals + import django.core.validators from django.db import migrations, models diff --git a/RIGS/migrations/0025_eventauthorisation.py b/RIGS/migrations/0025_eventauthorisation.py index 2065c11d..07262127 100644 --- a/RIGS/migrations/0025_eventauthorisation.py +++ b/RIGS/migrations/0025_eventauthorisation.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0026_auto_20170510_1846.py b/RIGS/migrations/0026_auto_20170510_1846.py index 0a350f10..8ede101b 100644 --- a/RIGS/migrations/0026_auto_20170510_1846.py +++ b/RIGS/migrations/0026_auto_20170510_1846.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.1 on 2017-05-10 17:46 -from __future__ import unicode_literals + import django.contrib.auth.validators from django.db import migrations, models diff --git a/RIGS/migrations/0026_remove_eventauthorisation_created_at.py b/RIGS/migrations/0026_remove_eventauthorisation_created_at.py index c5ddc143..57d00265 100644 --- a/RIGS/migrations/0026_remove_eventauthorisation_created_at.py +++ b/RIGS/migrations/0026_remove_eventauthorisation_created_at.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0027_eventauthorisation_event_singular.py b/RIGS/migrations/0027_eventauthorisation_event_singular.py index d7796895..60a3595f 100644 --- a/RIGS/migrations/0027_eventauthorisation_event_singular.py +++ b/RIGS/migrations/0027_eventauthorisation_event_singular.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations diff --git a/RIGS/migrations/0029_eventauthorisation_sent_by.py b/RIGS/migrations/0029_eventauthorisation_sent_by.py index 592bc968..4dec7d71 100644 --- a/RIGS/migrations/0029_eventauthorisation_sent_by.py +++ b/RIGS/migrations/0029_eventauthorisation_sent_by.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations from django.conf import settings diff --git a/RIGS/migrations/0030_auth_request_sending.py b/RIGS/migrations/0030_auth_request_sending.py index 7243e9a7..3b02bffc 100644 --- a/RIGS/migrations/0030_auth_request_sending.py +++ b/RIGS/migrations/0030_auth_request_sending.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations from django.conf import settings diff --git a/RIGS/migrations/0031_merge_20170512_2102.py b/RIGS/migrations/0031_merge_20170512_2102.py index 7056c46b..b8e04bfc 100644 --- a/RIGS/migrations/0031_merge_20170512_2102.py +++ b/RIGS/migrations/0031_merge_20170512_2102.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.1 on 2017-05-12 20:02 -from __future__ import unicode_literals + from django.db import migrations diff --git a/RIGS/models.py b/RIGS/models.py index 5d71c898..025ea508 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -461,7 +461,7 @@ class Event(models.Model, RevisionMixin): return reverse_lazy('event_detail', kwargs={'pk': self.pk}) def __str__(self): - return unicode(self.pk) + ": " + self.name + return str(self.pk) + ": " + self.name def clean(self): if self.end_date and self.start_date > self.end_date: @@ -526,7 +526,7 @@ class EventAuthorisation(models.Model, RevisionMixin): @property def activity_feed_string(self): - return unicode("N%05d" % self.event.pk + ' (requested by ' + self.sent_by.initials + ')') + return str("N%05d" % self.event.pk + ' (requested by ' + self.sent_by.initials + ')') @python_2_unicode_compatible diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 4546b502..db66ad4d 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -1,6 +1,6 @@ -import cStringIO as StringIO +import io as StringIO from io import BytesIO -import urllib2 +import urllib.request, urllib.error, urllib.parse from django.contrib.staticfiles.storage import staticfiles_storage from django.core.mail import EmailMessage, EmailMultiAlternatives @@ -93,7 +93,7 @@ class EventCreate(generic.CreateView): messages.info(self.request, "Your item changes have been saved. Please fix the errors and save the event.") # Get some other objects to include in the form. Used when there are errors but also nice and quick. - for field, model in form.related_models.iteritems(): + for field, model in form.related_models.items(): value = form[field].value() if value is not None and value != '': context[field] = model.objects.get(pk=value) @@ -114,7 +114,7 @@ class EventUpdate(generic.UpdateView): form = context['form'] # Get some other objects to include in the form. Used when there are errors but also nice and quick. - for field, model in form.related_models.iteritems(): + for field, model in form.related_models.items(): value = form[field].value() if value is not None and value != '': context[field] = model.objects.get(pk=value) @@ -183,7 +183,7 @@ class EventPrint(generic.View): merger.append(PdfFileReader(buffer)) buffer.close() - terms = urllib2.urlopen(settings.TERMS_OF_HIRE_URL) + terms = urllib.request.urlopen(settings.TERMS_OF_HIRE_URL) merger.append(StringIO.StringIO(terms.read())) merged = BytesIO() diff --git a/RIGS/signals.py b/RIGS/signals.py index ab37c2af..e6b803c5 100644 --- a/RIGS/signals.py +++ b/RIGS/signals.py @@ -1,6 +1,6 @@ -import cStringIO as StringIO +import io as StringIO import re -import urllib2 +import urllib.request, urllib.error, urllib.parse from io import BytesIO from django.db.models.signals import post_save @@ -38,7 +38,7 @@ def send_eventauthorisation_success_email(instance): merger.append(PdfFileReader(buffer)) buffer.close() - terms = urllib2.urlopen(settings.TERMS_OF_HIRE_URL) + terms = urllib.request.urlopen(settings.TERMS_OF_HIRE_URL) merger.append(StringIO.StringIO(terms.read())) merged = BytesIO() diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index b14f5798..2a246d6a 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -17,7 +17,7 @@ def to_class_name(value): def nice_errors(form, non_field_msg='General form errors'): nice_errors = ErrorDict() if isinstance(form, forms.BaseForm): - for field, errors in form.errors.items(): + for field, errors in list(form.errors.items()): if field == NON_FIELD_ERRORS: key = non_field_msg else: diff --git a/RIGS/test_functional.py b/RIGS/test_functional.py index 87e031a2..5ab9156c 100644 --- a/RIGS/test_functional.py +++ b/RIGS/test_functional.py @@ -407,9 +407,9 @@ class EventTest(LiveServerTestCase): self.assertIn("Test Item 1", row.find_element_by_xpath('//span[@class="name"]').text) self.assertIn("This is an item description", row.find_element_by_xpath('//div[@class="item-description"]').text) - self.assertEqual(u'£ 23.95', row.find_element_by_xpath('//tr[@id="item--1"]/td[2]').text) + self.assertEqual('£ 23.95', row.find_element_by_xpath('//tr[@id="item--1"]/td[2]').text) self.assertEqual("2", row.find_element_by_xpath('//td[@class="quantity"]').text) - self.assertEqual(u'£ 47.90', row.find_element_by_xpath('//tr[@id="item--1"]/td[4]').text) + self.assertEqual('£ 47.90', row.find_element_by_xpath('//tr[@id="item--1"]/td[4]').text) # Check totals self.assertEqual("47.90", self.browser.find_element_by_id('sumtotal').text) @@ -461,7 +461,7 @@ class EventTest(LiveServerTestCase): description="start future no end", purchase_order='TESTPO', auth_request_by=self.profile, - auth_request_at=self.create_datetime(2015, 06, 04, 10, 00), + auth_request_at=self.create_datetime(2015, 0o6, 0o4, 10, 00), auth_request_to="some@email.address") item1 = models.EventItem( @@ -760,12 +760,12 @@ class EventTest(LiveServerTestCase): 'organisation': organisation, 'venue': venue, 'mic': self.profile, - 'start_date': date(2015, 06, 04), - 'end_date': date(2015, 06, 05), + 'start_date': date(2015, 0o6, 0o4), + 'end_date': date(2015, 0o6, 0o5), 'start_time': time(10, 00), 'end_time': time(15, 00), - 'meet_at': self.create_datetime(2015, 06, 04, 10, 00), - 'access_at': self.create_datetime(2015, 06, 04, 10, 00), + 'meet_at': self.create_datetime(2015, 0o6, 0o4, 10, 00), + 'access_at': self.create_datetime(2015, 0o6, 0o4, 10, 00), 'collector': 'A Person' } @@ -795,11 +795,11 @@ class EventTest(LiveServerTestCase): reloadedItem = models.EventItem.objects.get(name='Detail Item 1') # Check the event - for key, value in eventData.iteritems(): + for key, value in eventData.items(): self.assertEqual(str(getattr(reloadedEvent, key)), str(value)) # Check the item - for key, value in item1Data.iteritems(): + for key, value in item1Data.items(): self.assertEqual(str(getattr(reloadedItem, key)), str(value)) def create_datetime(self, year, month, day, hour, min): diff --git a/RIGS/test_models.py b/RIGS/test_models.py index 0a7a72e6..6a3e1d40 100644 --- a/RIGS/test_models.py +++ b/RIGS/test_models.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + import pytz from reversion import revisions as reversion @@ -119,7 +119,7 @@ class EventTestCase(TestCase): e1 = [] e2 = [] - for (key, event) in self.events.iteritems(): + for (key, event) in self.events.items(): if event.pk % 2: event.venue = v1 e1.append(event) @@ -131,7 +131,7 @@ class EventTestCase(TestCase): self.assertItemsEqual(e1, v1.latest_events) self.assertItemsEqual(e2, v2.latest_events) - for (key, event) in self.events.iteritems(): + for (key, event) in self.events.items(): event.venue = None def test_related_vatrate(self): @@ -143,7 +143,7 @@ class EventTestCase(TestCase): e1 = [] e2 = [] - for (key, event) in self.events.iteritems(): + for (key, event) in self.events.items(): if event.pk % 2: event.person = p1 e1.append(event) @@ -155,7 +155,7 @@ class EventTestCase(TestCase): self.assertItemsEqual(e1, p1.latest_events) self.assertItemsEqual(e2, p2.latest_events) - for (key, event) in self.events.iteritems(): + for (key, event) in self.events.items(): event.person = None def test_related_organisation(self): @@ -164,7 +164,7 @@ class EventTestCase(TestCase): e1 = [] e2 = [] - for (key, event) in self.events.iteritems(): + for (key, event) in self.events.items(): if event.pk % 2: event.organisation = o1 e1.append(event) @@ -176,7 +176,7 @@ class EventTestCase(TestCase): self.assertItemsEqual(e1, o1.latest_events) self.assertItemsEqual(e2, o2.latest_events) - for (key, event) in self.events.iteritems(): + for (key, event) in self.events.items(): event.organisation = None def test_organisation_person_join(self): @@ -235,29 +235,29 @@ class EventTestCase(TestCase): event.save() def test_earliest_time(self): - event = models.Event(name="TE ET", start_date=date(2016, 01, 01)) + event = models.Event(name="TE ET", start_date=date(2016, 0o1, 0o1)) # Just a start date - self.assertEqual(event.earliest_time, date(2016, 01, 01)) + self.assertEqual(event.earliest_time, date(2016, 0o1, 0o1)) # With start time event.start_time = time(9, 00) self.assertEqual(event.earliest_time, self.create_datetime(2016, 1, 1, 9, 00)) # With access time - event.access_at = self.create_datetime(2015, 12, 03, 9, 57) + event.access_at = self.create_datetime(2015, 12, 0o3, 9, 57) self.assertEqual(event.earliest_time, event.access_at) # With meet time - event.meet_at = self.create_datetime(2015, 12, 03, 9, 55) + event.meet_at = self.create_datetime(2015, 12, 0o3, 9, 55) self.assertEqual(event.earliest_time, event.meet_at) # Check order isn't important - event.start_date = date(2015, 12, 03) - self.assertEqual(event.earliest_time, self.create_datetime(2015, 12, 03, 9, 00)) + event.start_date = date(2015, 12, 0o3) + self.assertEqual(event.earliest_time, self.create_datetime(2015, 12, 0o3, 9, 00)) def test_latest_time(self): - event = models.Event(name="TE LT", start_date=date(2016, 01, 01)) + event = models.Event(name="TE LT", start_date=date(2016, 0o1, 0o1)) # Just start date self.assertEqual(event.latest_time, event.start_date) @@ -279,8 +279,8 @@ class EventTestCase(TestCase): # basic checks manager.create(name='TE IB2', start_date='2016-01-02', end_date='2016-01-04'), manager.create(name='TE IB3', start_date='2015-12-31', end_date='2016-01-03'), - manager.create(name='TE IB4', start_date='2016-01-04', access_at=self.create_datetime(2016, 01, 03, 00, 00)), - manager.create(name='TE IB5', start_date='2016-01-04', meet_at=self.create_datetime(2016, 01, 02, 00, 00)), + manager.create(name='TE IB4', start_date='2016-01-04', access_at=self.create_datetime(2016, 0o1, 0o3, 00, 00)), + manager.create(name='TE IB5', start_date='2016-01-04', meet_at=self.create_datetime(2016, 0o1, 0o2, 00, 00)), # negative check manager.create(name='TE IB6', start_date='2015-12-31', end_date='2016-01-01'), diff --git a/RIGS/test_unit.py b/RIGS/test_unit.py index 8216791a..6ed2f3f1 100644 --- a/RIGS/test_unit.py +++ b/RIGS/test_unit.py @@ -53,19 +53,19 @@ class TestAdminMergeObjects(TestCase): change_url = reverse('admin:RIGS_venue_changelist') data = { 'action': 'merge', - '_selected_action': [unicode(val.pk) for key, val in self.venues.iteritems()] + '_selected_action': [str(val.pk) for key, val in self.venues.items()] } response = self.client.post(change_url, data, follow=True) self.assertContains(response, "The following objects will be merged") - for key, venue in self.venues.iteritems(): + for key, venue in self.venues.items(): self.assertContains(response, venue.name) def test_merge_no_master(self): change_url = reverse('admin:RIGS_venue_changelist') data = {'action': 'merge', - '_selected_action': [unicode(val.pk) for key, val in self.venues.iteritems()], + '_selected_action': [str(val.pk) for key, val in self.venues.items()], 'post': 'yes', } response = self.client.post(change_url, data, follow=True) @@ -76,7 +76,7 @@ class TestAdminMergeObjects(TestCase): change_url = reverse('admin:RIGS_venue_changelist') data = {'action': 'merge', - '_selected_action': [unicode(self.venues[1].pk), unicode(self.venues[2].pk)], + '_selected_action': [str(self.venues[1].pk), str(self.venues[2].pk)], 'post': 'yes', 'master': self.venues[1].pk } @@ -95,7 +95,7 @@ class TestAdminMergeObjects(TestCase): self.assertEqual(models.Venue.objects.get(pk=self.venues[3].pk), self.venues[3]) # Check the events have been moved to the master venue - for key, event in self.events.iteritems(): + for key, event in self.events.items(): updatedEvent = models.Event.objects.get(pk=event.pk) if event.venue == self.venues[3]: # The one we left in place continue @@ -105,7 +105,7 @@ class TestAdminMergeObjects(TestCase): change_url = reverse('admin:RIGS_person_changelist') data = {'action': 'merge', - '_selected_action': [unicode(self.persons[1].pk), unicode(self.persons[2].pk)], + '_selected_action': [str(self.persons[1].pk), str(self.persons[2].pk)], 'post': 'yes', 'master': self.persons[1].pk } @@ -124,7 +124,7 @@ class TestAdminMergeObjects(TestCase): self.assertEqual(models.Person.objects.get(pk=self.persons[3].pk), self.persons[3]) # Check the events have been moved to the master person - for key, event in self.events.iteritems(): + for key, event in self.events.items(): updatedEvent = models.Event.objects.get(pk=event.pk) if event.person == self.persons[3]: # The one we left in place continue @@ -134,7 +134,7 @@ class TestAdminMergeObjects(TestCase): change_url = reverse('admin:RIGS_organisation_changelist') data = {'action': 'merge', - '_selected_action': [unicode(self.organisations[1].pk), unicode(self.organisations[2].pk)], + '_selected_action': [str(self.organisations[1].pk), str(self.organisations[2].pk)], 'post': 'yes', 'master': self.organisations[1].pk } @@ -153,7 +153,7 @@ class TestAdminMergeObjects(TestCase): self.assertEqual(models.Organisation.objects.get(pk=self.organisations[3].pk), self.organisations[3]) # Check the events have been moved to the master organisation - for key, event in self.events.iteritems(): + for key, event in self.events.items(): updatedEvent = models.Event.objects.get(pk=event.pk) if event.organisation == self.organisations[3]: # The one we left in place continue @@ -421,4 +421,4 @@ class TestSampleDataGenerator(TestCase): def test_production_exception(self): from django.core.management.base import CommandError - self.assertRaisesRegexp(CommandError, ".*production", call_command, 'generateSampleData') + self.assertRaisesRegex(CommandError, ".*production", call_command, 'generateSampleData') diff --git a/RIGS/versioning.py b/RIGS/versioning.py index d055a12d..0e9fd54e 100644 --- a/RIGS/versioning.py +++ b/RIGS/versioning.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals + import logging import datetime @@ -51,8 +51,8 @@ class FieldComparison(object): @property def diff(self): - oldText = unicode(self.display_value(self._old)) or "" - newText = unicode(self.display_value(self._new)) or "" + oldText = str(self.display_value(self._old)) or "" + newText = str(self.display_value(self._new)) or "" dmp = diff_match_patch() diffs = dmp.diff_main(oldText, newText) dmp.diff_cleanupSemantic(diffs) @@ -145,7 +145,7 @@ class ModelComparison(object): item_dict[version.object_id] = compare # update the dictionary with the changes changes = [] - for (_, compare) in item_dict.items(): + for (_, compare) in list(item_dict.items()): if compare.fields_changed: changes.append(compare) diff --git a/RIGS/views.py b/RIGS/views.py index b681c1bb..06d46c6e 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -16,6 +16,7 @@ from django.views.decorators.csrf import csrf_exempt from RIGS import models, forms +from functools import reduce """ Displays the current rig count along with a few other bits and pieces diff --git a/importer.py b/importer.py index c7f3c9e0..8803d759 100644 --- a/importer.py +++ b/importer.py @@ -31,7 +31,7 @@ def setup_cursor(): return cursor except ConnectionDoesNotExist: print("Legacy database is not configured") - print(connections._databases) + print((connections._databases)) return None @@ -55,13 +55,13 @@ def import_users(delete=False): object.initials = row[6] object.phone = row[7] object.save() - print("Updated " + str(object)) + print(("Updated " + str(object))) except ObjectDoesNotExist: object = models.Profile(pk=row[0], username=row[1], email=row[2], first_name=row[3], last_name=row[4], is_active=row[5], initials=row[6], phone=row[7]) object.set_password(uuid.uuid4().hex) object.save() - print("Created " + str(object)) + print(("Created " + str(object))) def import_people(delete=False): @@ -85,15 +85,15 @@ def import_people(delete=False): if row[5] != "Normal": notes = row[5] - print("Trying %s %s %s" % (pk, name, phone)) + print(("Trying %s %s %s" % (pk, name, phone))) person, created = models.Person.objects.get_or_create(pk=pk, name=name, phone=phone, email=email, address=address, notes=notes) if created: - print("Created: " + person.__str__()) + print(("Created: " + person.__str__())) with reversion.create_revision(): person.save() else: - print("Found: " + person.__str__()) + print(("Found: " + person.__str__())) def import_organisations(delete=False): @@ -113,11 +113,11 @@ def import_organisations(delete=False): address=row[3], union_account=row[4], notes=notes) if created: - print("Created: " + object.__str__()) + print(("Created: " + object.__str__())) with reversion.create_revision(): object.save() else: - print("Found: " + object.__str__()) + print(("Found: " + object.__str__())) def import_vat_rates(delete=False): @@ -133,11 +133,11 @@ def import_vat_rates(delete=False): object, created = models.VatRate.objects.get_or_create(pk=row[0], start_at=start_at, comment=row[3], rate=row[4]) if created: - print("Created: " + object.__str__()) + print(("Created: " + object.__str__())) with reversion.create_revision(): object.save() else: - print("Found: " + object.__str__()) + print(("Found: " + object.__str__())) def import_venues(delete=False): @@ -295,11 +295,11 @@ def import_invoices(delete=False): cursor.execute(sql) for row in cursor.fetchall(): print(row) - print row[1] + print(row[1]) try: event = models.Event.objects.get(pk=row[1]) except ObjectDoesNotExist: - print "Event %d not found" % row[1] + print("Event %d not found" % row[1]) continue print(event)