mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-24 08:52:15 +00:00
Minor changes to models and importer
This commit is contained in:
@@ -99,20 +99,17 @@ def import_venues(delete=False):
|
|||||||
sql = """SELECT `venue`, `threephasepower` FROM `eventdetails` WHERE `venue` IS NOT NULL"""
|
sql = """SELECT `venue`, `threephasepower` FROM `eventdetails` WHERE `venue` IS NOT NULL"""
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
for row in cursor.fetchall():
|
for row in cursor.fetchall():
|
||||||
object, created = models.Venue.objects.get_or_create(name__iexact=row[0])
|
print("Searching for %s", row[0])
|
||||||
if created:
|
object = models.Venue.objects.get(name__iexact=row[0])
|
||||||
print("Created: " + object.__str__())
|
if object:
|
||||||
with transaction.atomic(), reversion.create_revision():
|
if not object.three_phase_available and row[1]:
|
||||||
object.three_phase_available = row[1]
|
with transaction.atomic(), reversion.create_revision():
|
||||||
object.save()
|
object.three_phase_available = row[1]
|
||||||
else:
|
object.save()
|
||||||
if not object.three_phase_available and row[1] == 1:
|
else:
|
||||||
print("Updating: " + object.__str__())
|
with transaction.atomic(), reversion.create_revision():
|
||||||
with transaction.atomic(), reversion.create_revision():
|
object = models.Venue(name=row[0], three_phase_available=row[1])
|
||||||
object.three_phase_available = row[1]
|
object.save()
|
||||||
object.save()
|
|
||||||
else:
|
|
||||||
print("Found: " + object.__str__())
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# import_people()
|
# import_people()
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class Venue(models.Model, RevisionMixin):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if len(self.notes) > 0:
|
if self.notes and len(self.notes) > 0:
|
||||||
string += "*"
|
string += "*"
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user