mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-03-07 12:38:23 +00:00
Run through 2-to-3 converter. This is not in a working state
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
DATETIME_FORMAT = ('d/m/Y H:i')
|
DATETIME_FORMAT = ('d/m/Y H:i')
|
||||||
DATE_FORMAT = ('d/m/Y')
|
DATE_FORMAT = ('d/m/Y')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import cStringIO as StringIO
|
import io as StringIO
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import RIGS.models
|
import RIGS.models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.9.4 on 2016-03-31 12:02
|
# Generated by Django 1.9.4 on 2016-03-31 12:02
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.11.1 on 2017-05-10 17:46
|
# Generated by Django 1.11.1 on 2017-05-10 17:46
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import django.contrib.auth.validators
|
import django.contrib.auth.validators
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.11.1 on 2017-05-12 20:02
|
# Generated by Django 1.11.1 on 2017-05-12 20:02
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations
|
from django.db import migrations
|
||||||
|
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ class Event(models.Model, RevisionMixin):
|
|||||||
return reverse_lazy('event_detail', kwargs={'pk': self.pk})
|
return reverse_lazy('event_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return unicode(self.pk) + ": " + self.name
|
return str(self.pk) + ": " + self.name
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if self.end_date and self.start_date > self.end_date:
|
if self.end_date and self.start_date > self.end_date:
|
||||||
@@ -526,7 +526,7 @@ class EventAuthorisation(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def activity_feed_string(self):
|
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
|
@python_2_unicode_compatible
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import cStringIO as StringIO
|
import io as StringIO
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import urllib2
|
import urllib.request, urllib.error, urllib.parse
|
||||||
|
|
||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
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.")
|
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.
|
# 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()
|
value = form[field].value()
|
||||||
if value is not None and value != '':
|
if value is not None and value != '':
|
||||||
context[field] = model.objects.get(pk=value)
|
context[field] = model.objects.get(pk=value)
|
||||||
@@ -114,7 +114,7 @@ class EventUpdate(generic.UpdateView):
|
|||||||
form = context['form']
|
form = context['form']
|
||||||
|
|
||||||
# Get some other objects to include in the form. Used when there are errors but also nice and quick.
|
# 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()
|
value = form[field].value()
|
||||||
if value is not None and value != '':
|
if value is not None and value != '':
|
||||||
context[field] = model.objects.get(pk=value)
|
context[field] = model.objects.get(pk=value)
|
||||||
@@ -183,7 +183,7 @@ class EventPrint(generic.View):
|
|||||||
merger.append(PdfFileReader(buffer))
|
merger.append(PdfFileReader(buffer))
|
||||||
buffer.close()
|
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()))
|
merger.append(StringIO.StringIO(terms.read()))
|
||||||
|
|
||||||
merged = BytesIO()
|
merged = BytesIO()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import cStringIO as StringIO
|
import io as StringIO
|
||||||
import re
|
import re
|
||||||
import urllib2
|
import urllib.request, urllib.error, urllib.parse
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
@@ -38,7 +38,7 @@ def send_eventauthorisation_success_email(instance):
|
|||||||
merger.append(PdfFileReader(buffer))
|
merger.append(PdfFileReader(buffer))
|
||||||
buffer.close()
|
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()))
|
merger.append(StringIO.StringIO(terms.read()))
|
||||||
|
|
||||||
merged = BytesIO()
|
merged = BytesIO()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def to_class_name(value):
|
|||||||
def nice_errors(form, non_field_msg='General form errors'):
|
def nice_errors(form, non_field_msg='General form errors'):
|
||||||
nice_errors = ErrorDict()
|
nice_errors = ErrorDict()
|
||||||
if isinstance(form, forms.BaseForm):
|
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:
|
if field == NON_FIELD_ERRORS:
|
||||||
key = non_field_msg
|
key = non_field_msg
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -407,9 +407,9 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.assertIn("Test Item 1", row.find_element_by_xpath('//span[@class="name"]').text)
|
self.assertIn("Test Item 1", row.find_element_by_xpath('//span[@class="name"]').text)
|
||||||
self.assertIn("This is an item description",
|
self.assertIn("This is an item description",
|
||||||
row.find_element_by_xpath('//div[@class="item-description"]').text)
|
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("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
|
# Check totals
|
||||||
self.assertEqual("47.90", self.browser.find_element_by_id('sumtotal').text)
|
self.assertEqual("47.90", self.browser.find_element_by_id('sumtotal').text)
|
||||||
@@ -461,7 +461,7 @@ class EventTest(LiveServerTestCase):
|
|||||||
description="start future no end",
|
description="start future no end",
|
||||||
purchase_order='TESTPO',
|
purchase_order='TESTPO',
|
||||||
auth_request_by=self.profile,
|
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")
|
auth_request_to="some@email.address")
|
||||||
|
|
||||||
item1 = models.EventItem(
|
item1 = models.EventItem(
|
||||||
@@ -760,12 +760,12 @@ class EventTest(LiveServerTestCase):
|
|||||||
'organisation': organisation,
|
'organisation': organisation,
|
||||||
'venue': venue,
|
'venue': venue,
|
||||||
'mic': self.profile,
|
'mic': self.profile,
|
||||||
'start_date': date(2015, 06, 04),
|
'start_date': date(2015, 0o6, 0o4),
|
||||||
'end_date': date(2015, 06, 05),
|
'end_date': date(2015, 0o6, 0o5),
|
||||||
'start_time': time(10, 00),
|
'start_time': time(10, 00),
|
||||||
'end_time': time(15, 00),
|
'end_time': time(15, 00),
|
||||||
'meet_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, 06, 04, 10, 00),
|
'access_at': self.create_datetime(2015, 0o6, 0o4, 10, 00),
|
||||||
'collector': 'A Person'
|
'collector': 'A Person'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -795,11 +795,11 @@ class EventTest(LiveServerTestCase):
|
|||||||
reloadedItem = models.EventItem.objects.get(name='Detail Item 1')
|
reloadedItem = models.EventItem.objects.get(name='Detail Item 1')
|
||||||
|
|
||||||
# Check the event
|
# Check the event
|
||||||
for key, value in eventData.iteritems():
|
for key, value in eventData.items():
|
||||||
self.assertEqual(str(getattr(reloadedEvent, key)), str(value))
|
self.assertEqual(str(getattr(reloadedEvent, key)), str(value))
|
||||||
|
|
||||||
# Check the item
|
# Check the item
|
||||||
for key, value in item1Data.iteritems():
|
for key, value in item1Data.items():
|
||||||
self.assertEqual(str(getattr(reloadedItem, key)), str(value))
|
self.assertEqual(str(getattr(reloadedItem, key)), str(value))
|
||||||
|
|
||||||
def create_datetime(self, year, month, day, hour, min):
|
def create_datetime(self, year, month, day, hour, min):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
@@ -119,7 +119,7 @@ class EventTestCase(TestCase):
|
|||||||
|
|
||||||
e1 = []
|
e1 = []
|
||||||
e2 = []
|
e2 = []
|
||||||
for (key, event) in self.events.iteritems():
|
for (key, event) in self.events.items():
|
||||||
if event.pk % 2:
|
if event.pk % 2:
|
||||||
event.venue = v1
|
event.venue = v1
|
||||||
e1.append(event)
|
e1.append(event)
|
||||||
@@ -131,7 +131,7 @@ class EventTestCase(TestCase):
|
|||||||
self.assertItemsEqual(e1, v1.latest_events)
|
self.assertItemsEqual(e1, v1.latest_events)
|
||||||
self.assertItemsEqual(e2, v2.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
|
event.venue = None
|
||||||
|
|
||||||
def test_related_vatrate(self):
|
def test_related_vatrate(self):
|
||||||
@@ -143,7 +143,7 @@ class EventTestCase(TestCase):
|
|||||||
|
|
||||||
e1 = []
|
e1 = []
|
||||||
e2 = []
|
e2 = []
|
||||||
for (key, event) in self.events.iteritems():
|
for (key, event) in self.events.items():
|
||||||
if event.pk % 2:
|
if event.pk % 2:
|
||||||
event.person = p1
|
event.person = p1
|
||||||
e1.append(event)
|
e1.append(event)
|
||||||
@@ -155,7 +155,7 @@ class EventTestCase(TestCase):
|
|||||||
self.assertItemsEqual(e1, p1.latest_events)
|
self.assertItemsEqual(e1, p1.latest_events)
|
||||||
self.assertItemsEqual(e2, p2.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
|
event.person = None
|
||||||
|
|
||||||
def test_related_organisation(self):
|
def test_related_organisation(self):
|
||||||
@@ -164,7 +164,7 @@ class EventTestCase(TestCase):
|
|||||||
|
|
||||||
e1 = []
|
e1 = []
|
||||||
e2 = []
|
e2 = []
|
||||||
for (key, event) in self.events.iteritems():
|
for (key, event) in self.events.items():
|
||||||
if event.pk % 2:
|
if event.pk % 2:
|
||||||
event.organisation = o1
|
event.organisation = o1
|
||||||
e1.append(event)
|
e1.append(event)
|
||||||
@@ -176,7 +176,7 @@ class EventTestCase(TestCase):
|
|||||||
self.assertItemsEqual(e1, o1.latest_events)
|
self.assertItemsEqual(e1, o1.latest_events)
|
||||||
self.assertItemsEqual(e2, o2.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
|
event.organisation = None
|
||||||
|
|
||||||
def test_organisation_person_join(self):
|
def test_organisation_person_join(self):
|
||||||
@@ -235,29 +235,29 @@ class EventTestCase(TestCase):
|
|||||||
event.save()
|
event.save()
|
||||||
|
|
||||||
def test_earliest_time(self):
|
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
|
# 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
|
# With start time
|
||||||
event.start_time = time(9, 00)
|
event.start_time = time(9, 00)
|
||||||
self.assertEqual(event.earliest_time, self.create_datetime(2016, 1, 1, 9, 00))
|
self.assertEqual(event.earliest_time, self.create_datetime(2016, 1, 1, 9, 00))
|
||||||
|
|
||||||
# With access time
|
# 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)
|
self.assertEqual(event.earliest_time, event.access_at)
|
||||||
|
|
||||||
# With meet time
|
# 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)
|
self.assertEqual(event.earliest_time, event.meet_at)
|
||||||
|
|
||||||
# Check order isn't important
|
# Check order isn't important
|
||||||
event.start_date = date(2015, 12, 03)
|
event.start_date = date(2015, 12, 0o3)
|
||||||
self.assertEqual(event.earliest_time, self.create_datetime(2015, 12, 03, 9, 00))
|
self.assertEqual(event.earliest_time, self.create_datetime(2015, 12, 0o3, 9, 00))
|
||||||
|
|
||||||
def test_latest_time(self):
|
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
|
# Just start date
|
||||||
self.assertEqual(event.latest_time, event.start_date)
|
self.assertEqual(event.latest_time, event.start_date)
|
||||||
@@ -279,8 +279,8 @@ class EventTestCase(TestCase):
|
|||||||
# basic checks
|
# basic checks
|
||||||
manager.create(name='TE IB2', start_date='2016-01-02', end_date='2016-01-04'),
|
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 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 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, 01, 02, 00, 00)),
|
manager.create(name='TE IB5', start_date='2016-01-04', meet_at=self.create_datetime(2016, 0o1, 0o2, 00, 00)),
|
||||||
|
|
||||||
# negative check
|
# negative check
|
||||||
manager.create(name='TE IB6', start_date='2015-12-31', end_date='2016-01-01'),
|
manager.create(name='TE IB6', start_date='2015-12-31', end_date='2016-01-01'),
|
||||||
|
|||||||
@@ -53,19 +53,19 @@ class TestAdminMergeObjects(TestCase):
|
|||||||
change_url = reverse('admin:RIGS_venue_changelist')
|
change_url = reverse('admin:RIGS_venue_changelist')
|
||||||
data = {
|
data = {
|
||||||
'action': 'merge',
|
'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)
|
response = self.client.post(change_url, data, follow=True)
|
||||||
|
|
||||||
self.assertContains(response, "The following objects will be merged")
|
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)
|
self.assertContains(response, venue.name)
|
||||||
|
|
||||||
def test_merge_no_master(self):
|
def test_merge_no_master(self):
|
||||||
change_url = reverse('admin:RIGS_venue_changelist')
|
change_url = reverse('admin:RIGS_venue_changelist')
|
||||||
data = {'action': 'merge',
|
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',
|
'post': 'yes',
|
||||||
}
|
}
|
||||||
response = self.client.post(change_url, data, follow=True)
|
response = self.client.post(change_url, data, follow=True)
|
||||||
@@ -76,7 +76,7 @@ class TestAdminMergeObjects(TestCase):
|
|||||||
change_url = reverse('admin:RIGS_venue_changelist')
|
change_url = reverse('admin:RIGS_venue_changelist')
|
||||||
|
|
||||||
data = {'action': 'merge',
|
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',
|
'post': 'yes',
|
||||||
'master': self.venues[1].pk
|
'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])
|
self.assertEqual(models.Venue.objects.get(pk=self.venues[3].pk), self.venues[3])
|
||||||
|
|
||||||
# Check the events have been moved to the master venue
|
# 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)
|
updatedEvent = models.Event.objects.get(pk=event.pk)
|
||||||
if event.venue == self.venues[3]: # The one we left in place
|
if event.venue == self.venues[3]: # The one we left in place
|
||||||
continue
|
continue
|
||||||
@@ -105,7 +105,7 @@ class TestAdminMergeObjects(TestCase):
|
|||||||
change_url = reverse('admin:RIGS_person_changelist')
|
change_url = reverse('admin:RIGS_person_changelist')
|
||||||
|
|
||||||
data = {'action': 'merge',
|
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',
|
'post': 'yes',
|
||||||
'master': self.persons[1].pk
|
'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])
|
self.assertEqual(models.Person.objects.get(pk=self.persons[3].pk), self.persons[3])
|
||||||
|
|
||||||
# Check the events have been moved to the master person
|
# 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)
|
updatedEvent = models.Event.objects.get(pk=event.pk)
|
||||||
if event.person == self.persons[3]: # The one we left in place
|
if event.person == self.persons[3]: # The one we left in place
|
||||||
continue
|
continue
|
||||||
@@ -134,7 +134,7 @@ class TestAdminMergeObjects(TestCase):
|
|||||||
change_url = reverse('admin:RIGS_organisation_changelist')
|
change_url = reverse('admin:RIGS_organisation_changelist')
|
||||||
|
|
||||||
data = {'action': 'merge',
|
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',
|
'post': 'yes',
|
||||||
'master': self.organisations[1].pk
|
'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])
|
self.assertEqual(models.Organisation.objects.get(pk=self.organisations[3].pk), self.organisations[3])
|
||||||
|
|
||||||
# Check the events have been moved to the master organisation
|
# 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)
|
updatedEvent = models.Event.objects.get(pk=event.pk)
|
||||||
if event.organisation == self.organisations[3]: # The one we left in place
|
if event.organisation == self.organisations[3]: # The one we left in place
|
||||||
continue
|
continue
|
||||||
@@ -421,4 +421,4 @@ class TestSampleDataGenerator(TestCase):
|
|||||||
def test_production_exception(self):
|
def test_production_exception(self):
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
|
|
||||||
self.assertRaisesRegexp(CommandError, ".*production", call_command, 'generateSampleData')
|
self.assertRaisesRegex(CommandError, ".*production", call_command, 'generateSampleData')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
@@ -51,8 +51,8 @@ class FieldComparison(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def diff(self):
|
def diff(self):
|
||||||
oldText = unicode(self.display_value(self._old)) or ""
|
oldText = str(self.display_value(self._old)) or ""
|
||||||
newText = unicode(self.display_value(self._new)) or ""
|
newText = str(self.display_value(self._new)) or ""
|
||||||
dmp = diff_match_patch()
|
dmp = diff_match_patch()
|
||||||
diffs = dmp.diff_main(oldText, newText)
|
diffs = dmp.diff_main(oldText, newText)
|
||||||
dmp.diff_cleanupSemantic(diffs)
|
dmp.diff_cleanupSemantic(diffs)
|
||||||
@@ -145,7 +145,7 @@ class ModelComparison(object):
|
|||||||
item_dict[version.object_id] = compare # update the dictionary with the changes
|
item_dict[version.object_id] = compare # update the dictionary with the changes
|
||||||
|
|
||||||
changes = []
|
changes = []
|
||||||
for (_, compare) in item_dict.items():
|
for (_, compare) in list(item_dict.items()):
|
||||||
if compare.fields_changed:
|
if compare.fields_changed:
|
||||||
changes.append(compare)
|
changes.append(compare)
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from django.views.decorators.csrf import csrf_exempt
|
|||||||
|
|
||||||
|
|
||||||
from RIGS import models, forms
|
from RIGS import models, forms
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Displays the current rig count along with a few other bits and pieces
|
Displays the current rig count along with a few other bits and pieces
|
||||||
|
|||||||
24
importer.py
24
importer.py
@@ -31,7 +31,7 @@ def setup_cursor():
|
|||||||
return cursor
|
return cursor
|
||||||
except ConnectionDoesNotExist:
|
except ConnectionDoesNotExist:
|
||||||
print("Legacy database is not configured")
|
print("Legacy database is not configured")
|
||||||
print(connections._databases)
|
print((connections._databases))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -55,13 +55,13 @@ def import_users(delete=False):
|
|||||||
object.initials = row[6]
|
object.initials = row[6]
|
||||||
object.phone = row[7]
|
object.phone = row[7]
|
||||||
object.save()
|
object.save()
|
||||||
print("Updated " + str(object))
|
print(("Updated " + str(object)))
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
object = models.Profile(pk=row[0], username=row[1], email=row[2], first_name=row[3], last_name=row[4],
|
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])
|
is_active=row[5], initials=row[6], phone=row[7])
|
||||||
object.set_password(uuid.uuid4().hex)
|
object.set_password(uuid.uuid4().hex)
|
||||||
object.save()
|
object.save()
|
||||||
print("Created " + str(object))
|
print(("Created " + str(object)))
|
||||||
|
|
||||||
|
|
||||||
def import_people(delete=False):
|
def import_people(delete=False):
|
||||||
@@ -85,15 +85,15 @@ def import_people(delete=False):
|
|||||||
if row[5] != "Normal":
|
if row[5] != "Normal":
|
||||||
notes = row[5]
|
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,
|
person, created = models.Person.objects.get_or_create(pk=pk, name=name, phone=phone, email=email,
|
||||||
address=address, notes=notes)
|
address=address, notes=notes)
|
||||||
if created:
|
if created:
|
||||||
print("Created: " + person.__str__())
|
print(("Created: " + person.__str__()))
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
person.save()
|
person.save()
|
||||||
else:
|
else:
|
||||||
print("Found: " + person.__str__())
|
print(("Found: " + person.__str__()))
|
||||||
|
|
||||||
|
|
||||||
def import_organisations(delete=False):
|
def import_organisations(delete=False):
|
||||||
@@ -113,11 +113,11 @@ def import_organisations(delete=False):
|
|||||||
address=row[3],
|
address=row[3],
|
||||||
union_account=row[4], notes=notes)
|
union_account=row[4], notes=notes)
|
||||||
if created:
|
if created:
|
||||||
print("Created: " + object.__str__())
|
print(("Created: " + object.__str__()))
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
object.save()
|
object.save()
|
||||||
else:
|
else:
|
||||||
print("Found: " + object.__str__())
|
print(("Found: " + object.__str__()))
|
||||||
|
|
||||||
|
|
||||||
def import_vat_rates(delete=False):
|
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,
|
object, created = models.VatRate.objects.get_or_create(pk=row[0], start_at=start_at,
|
||||||
comment=row[3], rate=row[4])
|
comment=row[3], rate=row[4])
|
||||||
if created:
|
if created:
|
||||||
print("Created: " + object.__str__())
|
print(("Created: " + object.__str__()))
|
||||||
with reversion.create_revision():
|
with reversion.create_revision():
|
||||||
object.save()
|
object.save()
|
||||||
else:
|
else:
|
||||||
print("Found: " + object.__str__())
|
print(("Found: " + object.__str__()))
|
||||||
|
|
||||||
|
|
||||||
def import_venues(delete=False):
|
def import_venues(delete=False):
|
||||||
@@ -295,11 +295,11 @@ def import_invoices(delete=False):
|
|||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
for row in cursor.fetchall():
|
for row in cursor.fetchall():
|
||||||
print(row)
|
print(row)
|
||||||
print row[1]
|
print(row[1])
|
||||||
try:
|
try:
|
||||||
event = models.Event.objects.get(pk=row[1])
|
event = models.Event.objects.get(pk=row[1])
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
print "Event %d not found" % row[1]
|
print("Event %d not found" % row[1])
|
||||||
continue
|
continue
|
||||||
print(event)
|
print(event)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user