# Path: rolodex/models.py
# class Person(models.Model):
# 	slug = models.SlugField(unique=True, editable=False)
# 	lastName = models.CharField(max_length=100)
# 	firstName = models.CharField(max_length=100)
# 	role = models.ForeignKey('PersonRole', blank=True, null=True, related_name='person_role')
# 	position = models.CharField(max_length=250, blank=True, null=True)
# 	department = models.CharField(max_length=250, blank=True, null=True)
# 	gender = models.CharField(max_length=250, blank=True, null=True, choices=gender_types)
# 	birthdate = models.CharField(blank=True, null=True, max_length=50)
# 	race = models.CharField(max_length=250, blank=True, null=True, choices=race_types)
# 	# Minimum ethnicity category of US fed gov't
# 	ethnicity = models.CharField(max_length=250, blank=True, null=True, choices=ethnicity_types)
# 	# Relationships
# 	p_relations = models.ManyToManyField('self', through='P2P', symmetrical=False, related_name='+', blank=True)
# 	org_relations = models.ManyToManyField('Org', through='P2Org', related_name='people', blank=True)
# 
# 	notes = models.TextField(blank=True, null=True)
# 
# 	last_edited_by = models.CharField(max_length=250, blank=True, null=True)
# 
# 	tags = TaggableManager()
# 
# 	def __unicode__(self):
# 		return self.lastName + ", " + self.firstName
# 
# 	def save(self, *args, **kwargs):
# 		unique_slugify(self, self.firstName + "-" + self.lastName)
# 		super(Person, self).save(*args, **kwargs)


from rolodex.models import Person
'''
This script can be run from within the django shell to add an example network into the database.

The data is a subset of the facebook graph from Stanford's Network Analysis Project (SNAP). 

http://snap.stanford.edu/data/egonets-Facebook.html
'''


edge_docs = ['0.edges',]#'107.edges','348.edges','414.edges','686.edges']
base= '/home/jon/DMN/Scripts/django-rolodex/example/sample network data/facebook/'
relationships =[]

for doc in edge_docs:
    
    with open(base+doc,'r+') as file:
	print(doc)
        for line in file:
            ents=line.split()

# Path: rolodex/models.py
# class Person(models.Model):
# 	slug = models.SlugField(unique=True, editable=False)
# 	lastName = models.CharField(max_length=100)
# 	firstName = models.CharField(max_length=100)
# 	role = models.ForeignKey('PersonRole', blank=True, null=True, related_name='person_role')
# 	position = models.CharField(max_length=250, blank=True, null=True)
# 	department = models.CharField(max_length=250, blank=True, null=True)
# 	gender = models.CharField(max_length=250, blank=True, null=True, choices=gender_types)
# 	birthdate = models.CharField(blank=True, null=True, max_length=50)
# 	race = models.CharField(max_length=250, blank=True, null=True, choices=race_types)
# 	# Minimum ethnicity category of US fed gov't
# 	ethnicity = models.CharField(max_length=250, blank=True, null=True, choices=ethnicity_types)
# 	# Relationships
# 	p_relations = models.ManyToManyField('self', through='P2P', symmetrical=False, related_name='+', blank=True)
# 	org_relations = models.ManyToManyField('Org', through='P2Org', related_name='people', blank=True)
# 
# 	notes = models.TextField(blank=True, null=True)
# 
# 	last_edited_by = models.CharField(max_length=250, blank=True, null=True)
# 
# 	tags = TaggableManager()
# 
# 	def __unicode__(self):
# 		return self.lastName + ", " + self.firstName
# 
# 	def save(self, *args, **kwargs):
# 		unique_slugify(self, self.firstName + "-" + self.lastName)
# 		super(Person, self).save(*args, **kwargs)


# Path: example/sample network data/add_samples.py
from rolodex.models import Person

'''
This script can be run from within the django shell to add an example network into the database.

The data is a subset of the facebook graph from Stanford's Network Analysis Project (SNAP). 

http://snap.stanford.edu/data/egonets-Facebook.html
'''


edge_docs = ['0.edges',]#'107.edges','348.edges','414.edges','686.edges']
base= '/home/jon/DMN/Scripts/django-rolodex/example/sample network data/facebook/'
relationships =[]

for doc in edge_docs:
    
    with open(base+doc,'r+') as file:
	print(doc)
        for line in file:
            ents=line.split()

            ent1, get = Person.objects.get_or_create(firstName='node',lastName=ents[0])