Add missing methods in models from gmba-connect
This commit is contained in:
parent
b628f6621d
commit
e21450730d
1 changed files with 62 additions and 0 deletions
|
@ -23,6 +23,11 @@ class Field(models.Model):
|
|||
class Meta:
|
||||
db_table = 'field'
|
||||
|
||||
def __repr__(self): return self.name
|
||||
|
||||
def dict(self):
|
||||
return {'id': self.id, 'name': self.name}
|
||||
|
||||
|
||||
class FieldsPeople(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
@ -40,6 +45,11 @@ class Method(models.Model):
|
|||
class Meta:
|
||||
db_table = 'method'
|
||||
|
||||
def __repr__(self): return self.name
|
||||
|
||||
def dict(self):
|
||||
return {'id': self.id, 'name': self.name}
|
||||
|
||||
|
||||
class MethodsPeople(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
@ -67,6 +77,30 @@ class Person(models.Model):
|
|||
class Meta:
|
||||
db_table = 'person'
|
||||
|
||||
def index(self):
|
||||
self.field_indexer = " ".join([
|
||||
self.first_name, self.last_name, self.organisation, self.position, self.biography
|
||||
])
|
||||
return True
|
||||
|
||||
def fullname(self):
|
||||
return " ".join([self.title, self.first_name, self.last_name])
|
||||
|
||||
def __repr__(self):
|
||||
return self.fullname()
|
||||
|
||||
def dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'fullname': self.fullname(),
|
||||
'organisation': self.organisation or '',
|
||||
'position': self.position or '',
|
||||
'country': self.country or '',
|
||||
'personal_url': self.personal_url or '',
|
||||
'personal_urls': self.personal_url.split(';'),
|
||||
'biography': self.biography or '',
|
||||
}
|
||||
|
||||
|
||||
class Range(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
@ -78,6 +112,17 @@ class Range(models.Model):
|
|||
class Meta:
|
||||
db_table = 'range'
|
||||
|
||||
def __repr__(self):
|
||||
return self.name
|
||||
|
||||
def dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'name': self.name,
|
||||
'gmba_id': self.gmba_id,
|
||||
'countries': self.countries,
|
||||
}
|
||||
|
||||
|
||||
class RangesPeople(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
@ -99,6 +144,18 @@ class Resource(models.Model):
|
|||
class Meta:
|
||||
db_table = 'resource'
|
||||
|
||||
def __repr__(self):
|
||||
return self.title
|
||||
|
||||
def dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'title': self.title or '',
|
||||
'citation': self.citation or '',
|
||||
'url': self.url or '',
|
||||
'abstract': self.abstract or '',
|
||||
}
|
||||
|
||||
|
||||
class ResourcesPeople(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
@ -141,3 +198,8 @@ class Taxon(models.Model):
|
|||
|
||||
class Meta:
|
||||
db_table = 'taxon'
|
||||
|
||||
def __repr__(self): return self.name
|
||||
|
||||
def dict(self):
|
||||
return {'id': self.id, 'name': self.name}
|
||||
|
|
Loading…
Reference in a new issue