Mercurial > getan
changeset 177:c37fb8223762
Add new States to edit project key and description
Add new ProjectEditKeyState to edit the key and ProjectEditDesciptionState to
edit the description of a project.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Thu, 13 Dec 2012 09:33:34 +0100 |
parents | 6e8b23f1ee94 |
children | 3f1ffb879ee8 |
files | getan/states.py |
diffstat | 1 files changed, 52 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/getan/states.py Thu Dec 13 09:32:21 2012 +0100 +++ b/getan/states.py Thu Dec 13 09:33:34 2012 +0100 @@ -658,3 +658,55 @@ def exit(self): self.view.set_footer_text("", 'entry_footer', False) return DefaultEntryListState(self.state, self.controller, self.view) + + +class ProjectEditKeyState(AlterProjectState): + + messages = { + 'proj_key': _('Insert key for project: '), + 'proj_description': _('Insert description for project: '), + 'choose_proj': _(" Choose a project.") + } + + def __init__(self, controller, view, project): + controller.view.set_footer_text(self.msg('proj_key'), + 'question', 1) + super(ProjectEditKeyState, self).__init__(controller, view) + self.project = project + self.view.frame.set_focus('footer') + self.footer.set_edit_text(project.key) + self.footer.set_edit_pos(len(self.footer.edit_text)) + + def enter(self): + key = self.footer.get_edit_text() + if key == '': + return self + self.project.key = key + return ProjectEditDescriptionState(self.controller, self.view, + self.project) + + +class ProjectEditDescriptionState(AlterProjectState): + + messages = { + "proj_description" : _("Insert description for project: "), + "choose_proj" : _(" Choose a project.") + } + + def __init__(self, controller, view, project): + controller.view.set_footer_text(self.msg("proj_description"), + "question", 1) + super(ProjectEditDescriptionState, self).__init__(controller, view) + self.project = project + self.view.frame.set_focus("footer") + self.footer.set_edit_text(project.desc) + self.footer.set_edit_pos(len(self.footer.edit_text)) + + def enter(self): + description = self.footer.get_edit_text() + if description == '': + return self + self.project.desc = description + self.controller.update_project(self.project) + self.controller.view.set_footer_text(self.msg('choose_proj'), 'question') + return PausedProjectsState(self.controller, self.view)