mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 08:22:15 +00:00
Fixed issues with __unicode__() becoming __str__() in Python 3.
Fixed recursion issue with VatRate
This commit is contained in:
@@ -43,11 +43,11 @@ def import_people():
|
|||||||
person, created = models.Person.objects.get_or_create(pk=row[0], name=row[1], phone=row[2], email=email,
|
person, created = models.Person.objects.get_or_create(pk=row[0], name=row[1], phone=row[2], email=email,
|
||||||
address=row[4], notes=notes)
|
address=row[4], notes=notes)
|
||||||
if created:
|
if created:
|
||||||
print("Created: " + person.__unicode__())
|
print("Created: " + person.__str__())
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
person.save()
|
person.save()
|
||||||
else:
|
else:
|
||||||
print("Found: " + person.__unicode__())
|
print("Found: " + person.__str__())
|
||||||
|
|
||||||
|
|
||||||
def import_organisations():
|
def import_organisations():
|
||||||
@@ -65,11 +65,11 @@ def import_organisations():
|
|||||||
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.__unicode__())
|
print("Created: " + object.__str__())
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
object.save()
|
object.save()
|
||||||
else:
|
else:
|
||||||
print("Found: " + object.__unicode__())
|
print("Found: " + object.__str__())
|
||||||
|
|
||||||
|
|
||||||
def import_vat_rates():
|
def import_vat_rates():
|
||||||
@@ -83,11 +83,11 @@ def import_vat_rates():
|
|||||||
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.__unicode__())
|
print("Created: " + object.__str__())
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
object.save()
|
object.save()
|
||||||
else:
|
else:
|
||||||
print("Found: " + object.__unicode__())
|
print("Found: " + object.__str__())
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Person(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
notes = models.TextField(blank=True, null=True)
|
notes = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if len(self.notes) > 0:
|
if len(self.notes) > 0:
|
||||||
string += "*"
|
string += "*"
|
||||||
@@ -55,7 +55,7 @@ class Organisation(models.Model, RevisionMixin):
|
|||||||
notes = models.TextField(blank=True, null=True)
|
notes = models.TextField(blank=True, null=True)
|
||||||
union_account = models.BooleanField(default=False)
|
union_account = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if len(self.notes) > 0:
|
if len(self.notes) > 0:
|
||||||
string += "*"
|
string += "*"
|
||||||
@@ -68,8 +68,9 @@ class VatRate(models.Model, RevisionMixin):
|
|||||||
rate = models.DecimalField(max_digits=6, decimal_places=6)
|
rate = models.DecimalField(max_digits=6, decimal_places=6)
|
||||||
comment = models.CharField(max_length=255)
|
comment = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
@property
|
||||||
def as_percent(self):
|
def as_percent(self):
|
||||||
return self.rate * 100
|
return (self.rate * 100)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.comment + " " + str(self.start_at) + " @ " + str(self.as_percent) + "%"
|
return self.comment + " " + str(self.start_at) + " @ " + str(self.as_percent) + "%"
|
||||||
|
|||||||
Reference in New Issue
Block a user