Exemple #1
0
 def on_button_clicked(self, button):
     retvalue = None
     if button == self.okbutton.body:
         if self.newpwedit.body.get_edit_text(
         ) == self.confirmedit.body.get_edit_text():
             retvalue, message = self.server.member_manager.modify_password(
                 self.session_key, {
                     'username':
                     self.server.member_manager.get_info(
                         self.session_key)[1]['username'],
                     'current_password':
                     self.oldpwedit.body.get_edit_text(),
                     'new_password':
                     self.newpwedit.body.get_edit_text()
                 })
             if retvalue:
                 confirm = widget.Dialog(_('Password changed.'), [_('OK')],
                                         ('menu', 'bg', 'bgf'), 30, 5, self)
                 self.overlay = confirm
                 self.parent.run()
                 self.parent.change_page("user_preferences",
                                         {'session_key': self.session_key})
             else:
                 confirm = widget.Dialog(message, [_('OK')],
                                         ('menu', 'bg', 'bgf'), 30, 5, self)
                 self.overlay = confirm
                 self.parent.run()
                 self.overlay = None
                 self.parent.run()
     elif button == self.cancelbutton.body:
         self.parent.change_page("user_preferences",
                                 {'session_key': self.session_key})
Exemple #2
0
 def notify_guest(self):
     confirm = widget.Dialog(_('Not available in guest mode.'), [_('Ok')],
                             ('menu', 'bg', 'bgf'), 30, 6, self)
     self.overlay = confirm
     self.parent.run()
     self.overlay = None
     self.parent.run()
Exemple #3
0
 def keypress(self, size, key):
     mainpile_focus = self.mainpile.get_focus()
     if mainpile_focus == self.boardlist:
         if key == "enter":
             # self.boardlist.get_body().get_focus()[0].w.w.widget_list : 현재 활성화된 항목
             boardname = self.boardlist.get_body().get_focus(
             )[0].w.w.widget_list[0].get_text()[0]
             self.parent.change_page("list_article", {
                 'session_key': self.session_key,
                 'board_name': boardname
             })
         else:
             self.mainpile.keypress(size, key)
     elif mainpile_focus == self.boardnameedit:
         if key == 'enter':
             boardname = self.boardnameedit.body.get_edit_text()
             try:
                 status = self.server.board_manager.get_board(boardname)
                 self.parent.change_page("list_article", {
                     'session_key': self.session_key,
                     'board_name': boardname
                 })
             except InvalidOperation, e:
                 confirm = widget.Dialog(
                     _('No such board. Returning to main menu.'), [_('Ok')],
                     ('menu', 'bg', 'bgf'), 30, 6, self)
                 self.overlay = confirm
                 self.parent.run()
                 self.parent.change_page('main',
                                         {'session_key': self.session_key})
         else:
             self.mainpile.keypress(size, key)
Exemple #4
0
 def delete_account(self):
     confirm = widget.Dialog(_('Do you want to delete your ARA account?'),
                             [_('OK'), _('Cancel')], ('menu', 'bg', 'bgf'),
                             45, 5, self)
     self.overlay = confirm
     self.parent.run()
     if confirm.b_pressed == _('OK'):
         self.server.remove_user(self.session_key)
         sys.exit(0)
     else:
         self.overlay = None
         self.parent.run()
Exemple #5
0
 def confirm_quit(self):
     confirm = widget.Dialog(_('Really quit?'),
                             [_('Yes'), _('No')], ('menu', 'bg', 'bgf'), 30,
                             5, self)
     self.overlay = confirm
     self.parent.run()
     if confirm.b_pressed == _('Yes'):
         self.server.login_manager.logout(self.session_key)
         sys.exit(0)
     else:
         self.overlay = None
         self.parent.run()
Exemple #6
0
 def on_button_clicked(self, button):
     retvalue = None
     if button == self.btnokay:
         to = self.idedit.get_edit_text()
         body = self.bodyedit.body.get_edit_text()
         try:
             self.server.messaging_manager.send_message(
                 self.session_key, to, body)
             confirm = widget.Dialog(_('Message sent.'), [_('OK')],
                                     ('menu', 'bg', 'bgf'), 30, 5, self)
             self.overlay = confirm
             self.parent.run()
             self.parent.change_page("list_pm",
                                     {'session_key': self.session_key})
         except InvalidOperation, e:
             confirm = widget.Dialog(e.why, [_('OK')],
                                     ('menu', 'bg', 'bgf'), 30, 5, self)
             self.overlay = confirm
             self.parent.run()
             self.parent.change_page("list_pm",
                                     {'session_key': self.session_key})
Exemple #7
0
 def on_button_clicked(self, button):
     retvalue = None
     if button == self.joinbutton.body:
         reg_dic = {
             'username': self.idedit.body.get_edit_text(),
             'password': self.pwedit.body.get_edit_text(),
             'nickname': self.nickedit.body.get_edit_text(),
             'email': self.emailedit.body.get_edit_text(),
             'signature': '',
             'self_introduction': '',
             'default_language': 'ko'
         }
         try:
             reg_key = self.server.member_manager.register(**reg_dic)
             self.server.member_manager.send_mail(
                 self.emailedit.body.get_edit_text(),
                 self.idedit.body.get_edit_text(), reg_key)
             confirm = widget.Dialog(
                 _('Account created.\nPlease confirm it.'), [_('OK')],
                 ('menu', 'bg', 'bgf'), 30, 6, self)
             self.overlay = confirm
             self.parent.run()
             if confirm.b_pressed == _('OK'):
                 self.parent.change_page("login", {})
         except InvalidOperation, e:
             message = widget.Dialog(reg_key, [_('OK')],
                                     ('menu', 'bg', 'bgf'), 30, 6, self)
             self.overlay = e.why
             self.parent.run()
             if message.b_pressed == _('OK'):
                 self.parent.change_page("login", {})
         except InternalError, e:
             message = widget.Dialog(reg_key, [_('OK')],
                                     ('menu', 'bg', 'bgf'), 30, 6, self)
             self.overlay = e.ouch
             self.parent.run()
             if message.b_pressed == _('OK'):
                 self.parent.change_page("login", {})
Exemple #8
0
 def keypress(self, size, key):
     if key in self.keymap:
         key = self.keymap[key]
     if key == "enter" and not self.session_key == 'guest':
         # self.boardlist.get_body().get_focus()[0].w.w.widget_list : 현재 활성화된 항목
         article_id = self.articlelist.get_body().get_focus(
         )[0].w.w.widget_list[0].get_text()[0]
         if article_id != '':
             article_id = int(article_id)
             self.parent.change_page(
                 "read_article", {
                     'session_key': self.session_key,
                     'board_name': self.board_name,
                     'article_id': article_id
                 })
     elif key == 'w' and not self.readonly and not self.session_key == 'guest':
         self.parent.change_page(
             'post_article', {
                 'session_key': self.session_key,
                 'board_name': self.board_name,
                 'mode': 'post',
                 'article_id': ''
             })
     elif key == 'q':
         self.parent.change_page("main", {'session_key': self.session_key})
     elif key == 'f':
         if self.session_key == 'guest':
             return
         input_dialog = widget.Dialog(_('Search term:'),
                                      [_('OK'), _('Cancel')],
                                      ('menu', 'bg', 'bgf'), 30, 7, self,
                                      'Text')
         self.overlay = input_dialog
         self.parent.run()
         if input_dialog.b_pressed == _('OK'):
             search_term = input_dialog.edit_text
         else:
             search_term = ''
         if search_term.strip() == '':
             return
         listbody = urwid.ListBox(
             ArticleSearchWalker(self.session_key, self.board_name,
                                 self.make_widget, False,
                                 {'title': search_term}))
         self.articlelist.set_body(listbody)
         self.overlay = None
         self.parent.run()
     else:
         self.mainpile.keypress(size, key)
Exemple #9
0
 def on_button_clicked(self, button):
     retvalue = None
     if button == self.okbutton.body:
         if self.server.member_manager.is_registered_nickname(
                 self.nickedit.body.get_edit_text()):
             confirm = widget.Dialog(
                 _('Nickname is in use.\nTry another one.'), [_('OK')],
                 ('menu', 'bg', 'bgf'), 30, 6, self)
             self.overlay = confirm
             self.parent.run()
             if confirm.b_pressed == _('OK'):
                 self.parent.change_page("change_basic_info",
                                         {'session_key': self.session_key})
             else:
                 pass
             return
         else:
             self.myinfo['nickname'] = self.nickedit.body.get_edit_text()
             try:
                 self.server.member_manager.modify(self.session_key,
                                                   self.myinfo)
                 message = _('Nickname changed.')
             except InvalidOperation, e:
                 message = e.why
             except InternalError, e:
                 message = e.why
             confirm = widget.Dialog(message, [_('OK')],
                                     ('menu', 'bg', 'bgf'), 30, 6, self)
             self.overlay = confirm
             self.parent.run()
             if confirm.b_pressed == _('OK'):
                 self.parent.change_page("user_preferences",
                                         {'session_key': self.session_key})
             else:
                 pass
             return
Exemple #10
0
 def on_button_clicked(self, button):
     if button == self.btnokay:
         retvalue = None
         title = self.titleedit.body.get_edit_text()
         body = self.bodyedit.body.get_edit_text()
         try:
             title_content = {'title': title, 'content': body}
             if self.mode == 'modify':
                 result = self.server.article_manager.modify(
                     self.session_key, self.board_name, self.article_id,
                     **title_content)
             elif self.mode == 'reply':
                 result = self.server.article_manager.write_reply(
                     self.session_key, self.board_name, self.article_id,
                     **title_content)
             elif self.mode == 'post':
                 result = self.server.article_manager.write_article(
                     self.session_key, self.board_name, **title_content)
             else:
                 return
             confirm = widget.Dialog(_('Article posted.'), [_('OK')],
                                     ('menu', 'bg', 'bgf'), 30, 5, self)
             self.overlay = confirm
             self.parent.run()
             if confirm.b_pressed == _('OK'):
                 self.parent.change_page(
                     "list_article", {
                         'session_key': self.session_key,
                         'board_name': self.board_name
                     })
         except:
             #self.overlay = None
             #self.parent.run()
             pass
     elif button == self.btncancel:
         self.parent.change_page("list_article", {
             'session_key': self.session_key,
             'board_name': self.board_name
         })
     elif button == self.btnhelp:
         # TODO: 편집 도움말
         pass
     elif button == self.btnpreview:
         # TODO: 미리보기
         pass
     else:
         assert ("Call for undefined button")
Exemple #11
0
 def on_button_clicked(self, button):
     retvalue = None
     if button == self.btnokay:
         self.myinfo['signature'] = self.sigedit.body.get_edit_text()
         self.myinfo['self_introduce'] = self.introedit.body.get_edit_text()
         try:
             retvalue =  self.server.member_manager.modify(self.session_key, self.myinfo)
             confirm = widget.Dialog(_('Sig/intro changed.'), [_('OK')], ('menu', 'bg', 'bgf'), 30, 5, self)
             self.overlay = confirm
             self.parent.run()
             if confirm.b_pressed == _('OK'):
                 self.parent.change_page("user_preferences",{'session_key':self.session_key})
             else:
                 pass
         except:
                 pass
     elif button == self.btncancel:
         self.parent.change_page("user_preferences",{'session_key':self.session_key})