La til en funksjon som oppretter en midlertidig fil som man kan editere før man kjører commit
This commit is contained in:
python
@ -48,8 +48,7 @@ class Book(models.Model):
|
||||
def to_string(self, commit=False):
|
||||
scratch = ''
|
||||
if commit:
|
||||
# generate commit string by sending self.to_dict to oysteini function
|
||||
print self.to_dict()
|
||||
# generate commit string by sending self.to_dict to fileformat function
|
||||
print fileformat.write_action(self.to_dict())
|
||||
|
||||
else:
|
||||
@ -63,8 +62,6 @@ class Book(models.Model):
|
||||
scratch += format % (field[1], '')
|
||||
authors = ', '.join(map(unicode, self.get_authors()))
|
||||
scratch += format % ('Authors', authors)
|
||||
# scratch += 'Authors'.ljust(15, ' ') + ':'
|
||||
# scratch += authors.rjust(51, ' ')
|
||||
|
||||
return scratch
|
||||
|
||||
@ -163,7 +160,7 @@ class Person(models.Model):
|
||||
def to_string(self, commit=False):
|
||||
if commit:
|
||||
#generate commit-string
|
||||
print self.to_dict()
|
||||
print fileformat.write_action(self.to_dict())
|
||||
else:
|
||||
format = '%-10s: %50s \n'
|
||||
scratch = format % ('Name', ' '.join((self.first_name, self.last_name)))
|
||||
|
Reference in New Issue
Block a user