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
This commit is contained in:
parent
d6def5b802
commit
3db84cf215
|
@ -774,7 +774,11 @@ class App(object):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def newStory(self):
|
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',
|
urwid.connect_signal(dialog, 'save',
|
||||||
lambda button: self.saveNewStory(dialog))
|
lambda button: self.saveNewStory(dialog))
|
||||||
urwid.connect_signal(dialog, 'cancel',
|
urwid.connect_signal(dialog, 'cancel',
|
||||||
|
@ -793,7 +797,7 @@ class App(object):
|
||||||
description=dialog.description_field.edit_text,
|
description=dialog.description_field.edit_text,
|
||||||
pending=True)
|
pending=True)
|
||||||
task = story.addTask(
|
task = story.addTask(
|
||||||
project=session.getProjectByID(dialog.project_button.key),
|
project=session.getProject(dialog.project_button.key),
|
||||||
title=dialog.title_field.edit_text,
|
title=dialog.title_field.edit_text,
|
||||||
pending=True)
|
pending=True)
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ except AttributeError:
|
||||||
|
|
||||||
class NewStoryDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
|
class NewStoryDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
|
||||||
signals = ['save', 'cancel']
|
signals = ['save', 'cancel']
|
||||||
def __init__(self, app):
|
def __init__(self, app, project_key):
|
||||||
self.app = app
|
self.app = app
|
||||||
save_button = mywid.FixedButton(u'Save')
|
save_button = mywid.FixedButton(u'Save')
|
||||||
cancel_button = mywid.FixedButton(u'Cancel')
|
cancel_button = mywid.FixedButton(u'Cancel')
|
||||||
|
@ -53,7 +53,14 @@ class NewStoryDialog(urwid.WidgetWrap, mywid.LineBoxTitlePropertyMixin):
|
||||||
('pack', cancel_button)]
|
('pack', cancel_button)]
|
||||||
buttons = urwid.Columns(buttons, dividechars=2)
|
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.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring)
|
||||||
self.description_field = mywid.MyEdit(u'', edit_text='',
|
self.description_field = mywid.MyEdit(u'', edit_text='',
|
||||||
multiline=True, ring=app.ring)
|
multiline=True, ring=app.ring)
|
||||||
|
|
Loading…
Reference in New Issue