Browse Source

Fix creating new stories

Look up the story by key, not id.

Pre-fill the project if in the context of a project story list.

Change-Id: I2a8ff647deee84a292d25e358ebf5c948a4374b8
changes/07/523207/1
James E. Blair 3 years ago
parent
commit
3db84cf215
2 changed files with 15 additions and 4 deletions
  1. +6
    -2
      boartty/app.py
  2. +9
    -2
      boartty/view/story.py

+ 6
- 2
boartty/app.py View File

@ -774,7 +774,11 @@ class App(object):
return ret
def newStory(self):
dialog = view_story.NewStoryDialog(self)
if hasattr(self.frame.body, 'project_key'):
project_key = self.frame.body.project_key
else:
project_key = None
dialog = view_story.NewStoryDialog(self, project_key)
urwid.connect_signal(dialog, 'save',
lambda button: self.saveNewStory(dialog))
urwid.connect_signal(dialog, 'cancel',
@ -793,7 +797,7 @@ class App(object):
description=dialog.description_field.edit_text,
pending=True)
task = story.addTask(
project=session.getProjectByID(dialog.project_button.key),
project=session.getProject(dialog.project_button.key),
title=dialog.title_field.edit_text,
pending=True)


+ 9
- 2
boartty/view/story.py View File

@ -39,7 +39,7 @@ except AttributeError:
class NewStoryDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
signals = ['save', 'cancel']
def __init__(self, app):
def __init__(self, app, project_key):
self.app = app
save_button = mywid.FixedButton(u'Save')
cancel_button = mywid.FixedButton(u'Cancel')
@ -53,7 +53,14 @@ class NewStoryDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
('pack', cancel_button)]
buttons = urwid.Columns(buttons, dividechars=2)
self.project_button = ProjectButton(self.app)
if project_key:
with self.app.db.getSession() as session:
project = session.getProject(project_key)
project_name = project.name
else:
project_name = None
self.project_button = ProjectButton(self.app, project_key, project_name)
self.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring)
self.description_field = mywid.MyEdit(u'', edit_text='',
multiline=True, ring=app.ring)


Loading…
Cancel
Save