diff --git a/.idea/dataSources.ids b/.idea/dataSources.ids index efee65b5..dd862776 100644 --- a/.idea/dataSources.ids +++ b/.idea/dataSources.ids @@ -4,6 +4,16 @@ + + + + + + + + + +
@@ -160,4 +170,664 @@
+ + + #@ + ` + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + +
+ + + +
+ + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + +
+ + + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+
\ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 349ba60d..c7226b0d 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,6 +1,6 @@ - + sqlite.xerial org.sqlite.JDBC @@ -8,6 +8,19 @@ .* + + mysql + true + com.mysql.jdbc.Driver + jdbc:mysql://alfie.codedinternet.com:3306/tec_rigs + tec_rigs + dfd2dfe7dfe4dfc8df82dfc8df81dfeddfc3dfdfdff7df8c + + + + + + diff --git a/RIGS/importer.py b/RIGS/importer.py index 34af1c57..b9ff30ac 100644 --- a/RIGS/importer.py +++ b/RIGS/importer.py @@ -27,10 +27,7 @@ def import_people(): sql = """SELECT `id`, `name`, `phone`, `email`, `address`, `status` FROM `people`""" cursor.execute(sql) resp = cursor.fetchall() - i=0 for row in resp: - if (i+1) > 1: - break email = row[3] if email is not "" and "@" not in email: email += "@nottingham.ac.uk" @@ -47,8 +44,32 @@ def import_people(): else: print("Found: " + person.__unicode__()) +def import_organisations(): + cursor = setup_cursor() + if cursor is None: + return + sql = """SELECT `id`, `name`, `phone`, `address`, `union_account`, `status` FROM `organisations`""" + cursor.execute(sql) + for row in cursor.fetchall(): + unionAccount = False + if row[4] == "1": + unionAccount = True + + notes = "" + if row[5] != "Normal": + notes = row[5] + + object, created = models.Organisation.objects.get_or_create(pk=row[0], name=row[1], phone=row[2], address=row[3], unionAccount=unionAccount, notes=notes) + if created: + print("Created: " + object.__unicode__()) + with transaction.atomic(), reversion.create_revision(): + object.save() + else: + print("Found: " + object.__unicode__()) + def main(): - import_people() + #import_people() + import_organisations() if __name__=="__main__": main() \ No newline at end of file diff --git a/RIGS/migrations/0004_organisation.py b/RIGS/migrations/0004_organisation.py new file mode 100644 index 00000000..bf1bbbf4 --- /dev/null +++ b/RIGS/migrations/0004_organisation.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import RIGS.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('RIGS', '0003_auto_20141031_0219'), + ] + + operations = [ + migrations.CreateModel( + name='Organisation', + fields=[ + ('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)), + ('name', models.CharField(max_length=50)), + ('phone', models.CharField(null=True, blank=True, max_length=15)), + ('email', models.EmailField(null=True, blank=True, max_length=75)), + ('address', models.TextField(null=True, blank=True)), + ('notes', models.TextField(null=True, blank=True)), + ('unionAccount', models.BooleanField(default=False)), + ], + options={ + }, + bases=(models.Model, RIGS.models.RevisionMixin), + ), + ] diff --git a/RIGS/models.py b/RIGS/models.py index 35380888..819f08e8 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -44,3 +44,19 @@ class Person(models.Model, RevisionMixin): string += "*" return string +@reversion.register +class Organisation(models.Model, RevisionMixin): + name = models.CharField(max_length=50) + phone = models.CharField(max_length=15, blank=True, null=True) + email = models.EmailField(blank=True, null=True) + + address = models.TextField(blank=True, null=True) + + notes = models.TextField(blank=True, null=True) + unionAccount = models.BooleanField(default=False) + + def __unicode__(self): + string = self.name + if len(self.notes) > 0: + string += "*" + return string \ No newline at end of file