La til reference i to_dict. #6
This commit is contained in:
parent
804ef55192
commit
1a9bf1a915
|
@ -80,9 +80,12 @@ class Book(models.Model):
|
||||||
else:
|
else:
|
||||||
dict['persons'][person.relation.name] = [person.id]
|
dict['persons'][person.relation.name] = [person.id]
|
||||||
|
|
||||||
dict['references'] = []
|
dict['references'] = {}
|
||||||
#for reference in self.references:
|
for reference in self.references.all():
|
||||||
# dict['references'].append(reference.text)
|
if person.relation.name in dict['references']:
|
||||||
|
dict['references'][reference.reference_type.name].append(reference.text)
|
||||||
|
else:
|
||||||
|
dict['references'][reference.reference_type.name] = [reference.text]
|
||||||
|
|
||||||
#TODO: add thumbnail and image fields
|
#TODO: add thumbnail and image fields
|
||||||
|
|
||||||
|
@ -151,6 +154,19 @@ class Person(models.Model):
|
||||||
last_name = models.CharField(max_length=255)
|
last_name = models.CharField(max_length=255)
|
||||||
references = models.ManyToManyField(Reference, related_name='persons', null=True, blank=True)
|
references = models.ManyToManyField(Reference, related_name='persons', null=True, blank=True)
|
||||||
|
|
||||||
|
def to_string(self, commit=False):
|
||||||
|
if commit:
|
||||||
|
#generate commit-string
|
||||||
|
print ''
|
||||||
|
else:
|
||||||
|
scratch = 'Name'.ljust(15, ' ') + ':'
|
||||||
|
scratch += ' '.join((first_name,last_name))
|
||||||
|
|
||||||
|
return scratch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.first_name + u' ' + self.last_name
|
return self.first_name + u' ' + self.last_name
|
||||||
|
|
||||||
|
|
Reference in New Issue