def __init__(self, desc_map, connection, parent=None): figure = Figure(figsize=(3,3), dpi=72) FigureCanvas.__init__(self, figure, parent) self.figure = figure self.connection = connection self.desc_map = desc_map self.start = datetime.datetime.utcnow() self.end = datetime.datetime.utcnow() self.adjust_signals_action = QtGui.QAction("Adjust signals plotted", self) self.addAction(self.adjust_signals_action) self.views = {} self.autoscale = True self.showing_dialog = False FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.plot = self.figure.add_subplot(111) self.setAcceptDrops(True) link(self.adjust_signals_action.triggered, self.adjust_signals)
def link(self, args): """ Actually deploy the configuration by linking the correct spot to the original file. @param args: The parsed arguments from the command-line. """ if args.dry: print(str(self.source) + " -> " + str(self.destination)) return if not self.src_exists: return if self.dst_exists_before: if args.replace: if self.dst_is_link_before: util.unlink(self.destination) elif self.dst_is_file_before: util.remove(self.destination) elif self.dst_is_dir_before: util.remove_dir(self.destination) else: #SUS should never get here. raise Exception("WTF is this shit") else: # File already exists and isn't going to be replaced. return else: #This is some weird nonsense conserning broken links if self.dst_is_link_before: util.unlink(self.destination) if args.copy: util.copy(self.source, self.destination) else: util.link(self.source, self.destination)
def __init__(self, tab_bar, source_finder, parent=None): figure = Figure(figsize=(3,3), dpi=72) FigureCanvas.__init__(self, figure, parent) BaseTabViewWidget.__init__(self, parent, init=False) self.figure = figure self.plots = [] self.tab_bar = tab_bar self.timescale = 30 self.find_source = source_finder #General plan for actions: #Plot specific actions are dispatched through the contextMenuEvent #handler which finds the selected plot using get_axes_at_point #and then generates a context menu with actions bound to the specific #plot. Generic non-plot-specific actions like adjusting the timescale #and renaming the tab are bound to the tab view and the tab widget #respectively. self.timescale_action = QtGui.QAction("Adjust timescale", self) self.addAction(self.timescale_action) link(self.timescale_action.triggered, self.adjust_timescale) FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) FigureCanvas.updateGeometry(self) self.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) self.setAcceptDrops(True)
def __init__(self, date=None, time=None, parent=None): QtGui.QDateTimeEdit.__init__(self, parent) date = date if date is not None else QtCore.QDate.currentDate() self.setDate(date) self.setMinimumDate(QtCore.QDate(1993, 6, 20)) self.setDisplayFormat("ddd MM/dd/yyyy h:mm:ss AP") self.setCalendarPopup(True) link(self.dateTimeChanged, self.emit_datetime)
def delete_get(self, board_name, board_id, current_uid = -1): if board_id == 1: board_name = '^root' default_referer = posixpath.join(util.link('/'), board_name, '+summary') action = posixpath.join(util.link('/'), board_name, '+delete') return util.render().question( question=_('Do you want to delete this board?'), board_path = board_name, board_desc = _('Confirmation'), title=_('Confirmation'), action=action, referer=web.ctx.env.get('HTTP_REFERER', default_referer))
def delete_get(self, board_name, board_id, article_id, current_uid = -1): if not acl.is_allowed('article', article_id, current_uid, 'delete'): return util.render().error(error_message = _('NO_PERMISSION'), help_context='error') default_referer = os.path.join(util.link('/'), board_name, '+read', str(article_id)) action=os.path.join(util.link('/'), board_name, '+delete', str(article_id)) return util.render().question( question=_('Do you want to delete the article?'), board_path = board_name, board_desc = _('Confirmation'), title=_('Confirmation'), action = action, referer=web.ctx.env.get('HTTP_REFERER', default_referer))
def __init__(self, parent=None): QtGui.QTabWidget.__init__(self, parent) self.rename_action = QtGui.QAction("Rename tab", self) self.addAction(self.rename_action) link(self.rename_action.triggered, self.rename) self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) #self.setTabsClosable(True) link(self.tabCloseRequested, self.close_tab)
def GET(self, board_name): if board_name == '*' or board_name == '^root': v = board_actions() return v.subboard_list_get() board_id = board._get_board_id_from_path(board_name) if board_id < 0: #try to find regex match board_id = board._get_board_id_from_regex_path(board_name) if board_id < 0: raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error')) else: path = board._get_path_from_board_id(board_id) raise web.seeother(util.link(path)) board_info = board.get_board_info(board_id) if board_info.bType == 0: # 디렉터리 v = board_actions() return v.subboard_list_get(board_name, board_id) elif board_info.bType == 2: # 넘겨주기 board_id = board._get_board_id_from_path(board_info.bDescription) if board_id < 0 or board_info.bDescription.strip() == '': raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_ALIAS'), help_context='error')) else: raise web.seeother(util.link(board_info.bDescription)) #processing new_article if web.ctx.session.has_key('uid'): uid = web.ctx.session.uid user.update_unreaded_articles_board(uid, board_id) qs = web.ctx.query if len(qs) > 0: qs = qs[1:] qs = parse_qs(qs) t = article._get_total_page_count(board_id, config.page_size) if qs: page = int(qs['page'][0]) else: page = t a = article.get_article_list(board_id, config.page_size, page) m = article.get_marked_article(board_id) return util.render().board(lang="ko", title = board_info.bName, board_path = board_info.bName[1:], board_desc = board_info.bDescription, stylesheet = board_info.stylesheet, articles=a, marked_articles = m, total_page = t, page = page, feed = True, help_context = 'board')
def manage_subscription_post(self, current_uid = -1): data = web.input() favorite_add = False favorite_delete = False favorite_delete_list = [] favorite_name = '' subscription_add = False subscription_delete = False subscription_delete_list = [] subscription_name = '' for k in data.keys(): if k.startswith('favorite_delete_'): favorite_delete_list.append(int(k[16:])) elif k.startswith('subscription_delete_'): subscription_delete_list.append(int(k[20:])) elif k == 'favorite_add': favorite_add = True elif k == 'favorite_delete': favorite_delete = True elif k == 'favorite_name': favorite_name = data[k] elif k == 'subscription_add': subscription_add = True elif k == 'subscription_delete': subscription_delete = True elif k == 'subscription_name': subscription_name = data[k] if favorite_add == True: if favorite_name.strip() == '': raise web.seeother(util.link('/+u/+manage_subscription')) board_id = board._get_board_id_from_path(favorite_name) if board_id < 0: raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error')) user.add_favorite_board(current_uid, board_id) elif favorite_delete == True: for b in favorite_delete_list: user.remove_favorite_board(current_uid, b) elif subscription_add == True: if favorite_name.strip() == '': raise web.seeother(util.link('/+u/+manage_subscription')) board_id = board._get_board_id_from_path(subscription_name) if board_id < 0: raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error')) user.add_subscription_board(current_uid, board_id) elif subscription_delete == True: for b in subscription_delete_list: user.remove_subscription_board(current_uid, b) raise web.seeother(util.link('/+u/+manage_subscription'))
def __init__(self, *args, **kwargs): QtGui.QDialog.__init__(self, *args, **kwargs) self.setWindowTitle("Signals Editor") self.vert_layout = QtGui.QVBoxLayout(self) self.horz_layout = QtGui.QHBoxLayout() self.vert_layout.addLayout(self.horz_layout) self.list_widget = SignalListWidget(self) self.control_frame = QtGui.QFrame(self) self.control_frame.setFrameShape(QtGui.QFrame.Box) self.control_layout = QtGui.QFormLayout(self.control_frame) self.name_field = QtGui.QLineEdit(self.control_frame) self.style_field = QtGui.QComboBox(self.control_frame) self.color_field = CustomColorPicker(self.control_frame) for (style, icon) in self.styles: if icon: self.style_field.addItem(icon, style) else: self.style_field.addItem(style) self.control_layout.addRow("Name:", self.name_field) self.control_layout.addRow("Style:", self.style_field) self.control_layout.addRow("Color:", self.color_field) ## self.edit_button = QtGui.QPushButton("&Edit", self) ## self.remove_button = QtGui.QPushButton("&Remove", self) ## ## self.control_layout.addWidget(self.edit_button) ## self.control_layout.addWidget(self.remove_button) ## self.control_layout.addStretch(1) self.control_frame.setLayout(self.control_layout) self.horz_layout.addWidget(self.list_widget) self.horz_layout.addWidget(self.control_frame) self.footer_buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Close) self.vert_layout.addWidget(self.footer_buttons) self.setLayout(self.vert_layout) link(self.footer_buttons.rejected, self.close) ## link(self.edit_button.clicked, self.do_edit) ## link(self.remove_button.clicked, self.do_remove) link(self.list_widget.currentItemChanged, self.update_controls)
def setup(self, choices): #General layout heuristic - if there are N choices, try to make #a ceil(sqrt(N)) x ceil(sqrt(N)) grid. M = N = int(math.ceil(math.sqrt(len(choices)))) for k, (name, icon, desc, ident) in enumerate(choices): button = QtGui.QPushButton(icon, name) label = QtGui.QLabel(desc) layout = QtGui.QVBoxLayout() i, j = divmod(k, N) self.layout.addLayout(layout, i, j) layout.addWidget(button) layout.addWidget(label) link(button.pressed, lambda ident=ident: self.choice_selected.emit(ident))
def join_post(self): data = web.input() recaptcha_url = 'http://www.google.com/recaptcha/api/verify' recaptcha_data = dict(challenge = data.recaptcha_challenge_field, response = data.recaptcha_response_field, remoteip = web.ctx.ip, privatekey = config.recaptcha_private_key) req = urllib2.Request(recaptcha_url, urllib.urlencode(recaptcha_data)) response = urllib2.urlopen(req) page = response.read().split('\n') if page[0] == 'false': if page[1].strip() == 'incorrect-captcha-sol': return util.render().error(error_message = _('INCORRECT_CAPTCHA'), help_context='error') else: return util.render().error(error_message = _('CAPTCHA_ERROR'), help_context='error') username = data.id.strip() if username == '': return util.render().error(error_message = _('NO_USERNAME_SPECIFIED'), help_context='error') if user._get_uid_from_username(username) > 0: return util.render().error(error_message = _('ID_ALREADY_EXISTS'), help_context='error') if data.password1 != data.password2: return util.render().error(error_message = _('PASSWORD_DO_NOT_MATCH'), help_context='error') if len(data.password1) < 6: return util.render().error(error_message = _('PASSWORD_TOO_SHORT'), help_context='error') nick = data.nick email = data.email password = data.password1 ret = user.join(locals()) if not ret[0]: return util.render().error(error_message = ret[1], help_context='error') self.session_set(username) user.update_last_login(web.ctx.session.uid, web.ctx.ip) raise web.seeother(util.link('/'))
def write_post(self, board_name, board_id, current_uid = -1): a = dict(title = web.input().title, body = web.input().content) board_info = board.get_board_info(board_id) ret = article.write_article(current_uid, board_id, a) if ret[0] == True: user.update_unreaded_articles_board(current_uid, board_id) user.read_article(current_uid, ret[1]) fs = web.ctx.get('_fieldstorage') try: if fs.has_key('new_attachment'): new_attachment = fs['new_attachment'] if type(new_attachment) == list: for f in new_attachment: attachment.add_attachment(ret[1], f.filename, f.value) else: try: attachment.add_attachment(ret[1], new_attachment.filename, new_attachment.value) except: pass except: pass url = util.link('/%s/+read/%s' % (board_name, ret[1])) raise web.seeother(url) else: return util.render().error(error_message = ret[1], help_context='error')
def create_board_post(self, board_name, board_id, current_uid = -1): board_info = board.get_board_info(board_id) if not acl.is_allowed('board', board_id, current_uid, 'create'): return util.render().error(error_message = _('NO_PERMISSION'), help_context='error') user_data = web.input() comment = 1 if user_data.has_key('commentable') else 0 write_by_other = 1 if user_data.has_key('writable') else 0 indexable = 1 if user_data.has_key('indexable') else 0 show_avatar = 1 if user_data.has_key('show_avatar') else 0 owner_uid = user._get_uid_from_username(user_data.owner) if owner_uid < 0: return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error') if user_data.name.strip() == '': return util.render().error(error_message = _('NO_NAME_SPECIFIED'), help_context='error') if board_name == '^root': new_path = posixpath.join('/', user_data.name) else: new_path = posixpath.join('/', board_name, user_data.name) if board._get_board_id_from_path(new_path) > 0: return util.render().error(error_message = _('BOARD_EXISTS'), help_context='error') settings = dict(path=new_path, board_owner = owner_uid, cover = user_data.information, description = user_data.description, type = int(user_data.type), guest_write = write_by_other, can_comment = comment, indexable = indexable, show_avatar = show_avatar, current_uid = current_uid) ret = board.create_board(board_id, settings) if ret[0] == False: return util.render().error(error_message = ret[1] ,help_context = 'error') raise web.seeother(util.link('%s') % (new_path))
def modify_post(self, current_uid = -1): user_id = current_uid usr = user.get_user(user_id)[1] data = web.input(profile_image = {}) if data.newpass1 and not user.verify_password(user_id, data.oldpass): return util.render().error(error_message=_('INVALID_PASSWORD'), help_context='error') if data.newpass1 != data.newpass2: return util.render().error(error_message = _('PASSWORD_DO_NOT_MATCH'), help_context='error') if len(data.newpass1) > 0 and len(data.newpass1) < 6: return util.render().error(error_message = _('PASSWORD_TOO_SHORT'), help_context='error') if len(data.newpass1) == 0: password = data.oldpass else: password = data.newpass1 nick = data.nick email = data.email homepage = data.homepage sig = data.sig introduction = data.introduction language = data.language theme = data.theme user_info = user.get_user(user_id) change_lang = False if language != user_info[1].language: change_lang = True profile_image = data.profile_image.value delete_profile_image = data.has_key('delete_profile_image') ret = user.modify_user(user_id, locals()) if change_lang: web.ctx.session.lang = language raise web.seeother(util.link('/+u'))
def modify_post(self, board_name, board_id, current_uid = -1): board_info = board.get_board_info(board_id) if not acl.is_allowed('board', board_id, current_uid, 'modify'): return util.render().error(error_message=_('NO_PERMISSION'), help_context='error') data = web.input() comment = 1 if data.has_key('commentable') else 0 write_by_other = 1 if data.has_key('writable') else 0 indexable = 1 if data.has_key('indexable') else 0 show_avatar = 1 if data.has_key('show_avatar') else 0 owner_uid = user._get_uid_from_username(web.input().owner) if owner_uid < 0: return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error') board_info = dict(path = data.path, name = data.name, owner = owner_uid, board_type = int(data.type), can_comment = comment, can_write_by_other = write_by_other, indexable = indexable, show_avatar = show_avatar, stylesheet = data.stylesheet, description = data.description, cover = data.information) result = board.board_edit(current_uid, board_id, board_info) if result[0] == False: return util.render().error(error_message = result[1], help_context='error') else: raise web.seeother(util.link('%s') % result[1])
def login_xdomain_get(self): qs = web.ctx.query if len(qs) > 0: qs = qs[1:] qs = parse_qs(qs) if type(qs) != dict: return util.render().login(title = _('Login'), board_desc=_('Login'), lang="ko", error = _('INVALID_PASSWORD'), referer = util.link('/')) referer = util.link('/') password_hash = '' persistent = False ts = 0 if qs.has_key('t'): ts = int(qs['t'][0]) username = '' if qs.has_key('username'): username = qs['username'][0] if ts < 1 or username == '': return util.render().login(title = _('Login'), board_desc=_('Login'), lang="ko", error = _('INVALID_PASSWORD'), referer = util.link('/')) login_info = user.get_login_info(username, ts) if login_info == None: return util.render().login(title = _('Login'), board_desc=_('Login'), lang="ko", error = _('INVALID_PASSWORD'), referer = util.link('/')) referer = login_info['referer'] password_hash = login_info['password_hash'] persistent = (login_info['persistent'] == 1) user.remove_login_info(username, ts) login = user.login(username, password_hash, True) if not login[0]: err = login[1] return util.render().login(title = _('Login'), board_desc=_('Login'), lang="ko", error = err, referer = referer) u = self.session_set(username) if persistent: web.ctx.session.persistent = True else: web.ctx.session.persistent = False user.update_last_login(u.uSerial, web.ctx.ip) raise web.seeother(referer)
def delete_post(self, board_name, board_id, article_id, current_uid = -1): if not acl.is_allowed('article', article_id, current_uid, 'delete'): return util.render().error(error_message = _('NO_PERMISSION'), help_context='error') ret = article.delete_article(current_uid, article_id) attachment.remove_all_attachment(article_id) if ret[0] == True: raise web.seeother(util.link('/%s') % (board_name)) else: return util.render().error(error_message = ret[1], help_context='error')
def subscribe_get(self, board_name, board_id, current_uid = -1): referer = web.ctx.env.get('HTTP_REFERER', util.link('/')) if user.is_subscribed(current_uid, board_id): user.remove_subscription_board(current_uid, board_id) else: user.add_subscription_board(current_uid, board_id) raise web.seeother(referer)
def __init__(self, plot, start_date=None, end_date=None, parent=None): QtGui.QWidget.__init__(self, parent) self.plot = plot self.layout = QtGui.QHBoxLayout(self) self.left_dt_control = CustomDateTimeEdit(date=start_date, parent=self) self.right_dt_control = CustomDateTimeEdit(date=end_date, parent=self) self.layout.addWidget(self.left_dt_control) self.layout.addWidget(self.right_dt_control) self.setLayout(self.layout) def update_left(dt): self.plot.update_bounds(dt, None) def update_right(dt): self.plot.update_bounds(None, dt) link(self.left_dt_control.pyDateTimeChanged, update_left) link(self.right_dt_control.pyDateTimeChanged, update_right)
def modify_get(self, current_uid = -1): user_id = current_uid usr = user.get_user(user_id)[1] referer = util.link('/+u') return util.render().myinfo_edit(user = user.get_user(user_id)[1], user_id = user_id, title = _('Edit My Information'), board_desc = _('Edit My Information'), referer = web.ctx.env.get('HTTP_REFERER', referer), help_context = 'myinfo')
def __init__(self, *args, **kwargs): QtGui.QWidget.__init__(self, *args, **kwargs) self.layout = QtGui.QHBoxLayout(self) self.patch = QtGui.QImage(QtCore.QSize(64, 32), QtGui.QImage.Format_Indexed8) self.patch.fill(0) self.picker_button = QtGui.QToolButton(self) self.picker_button.setIcon(find_icon("palette-icon.png")) self.picker_button.setAutoRaise(True) ## wrapper = QtGui.QWidget(self) ## wrapper_layout = QtGui.QHBoxLayout(wrapper) ## wrapper_layout.addWidget(self.patch ## wrapper.setLayout(wrapper_layout) ## self.layout.addWidget(self.patch, 1, QtCore.Qt.AlignLeft) self.layout.addWidget(self.picker_button, 0, QtCore.Qt.AlignLeft) self.setLayout(self.layout) self.color_dialog = QtGui.QColorDialog(self) link(self.picker_button.pressed, self.show_dialog)
def comment_post(self, board_name, board_id, article_id, current_uid = -1): if not acl.is_allowed('board', board_id, current_uid, 'comment'): return util.render().error(error_message=_('NO_PERMISSION'), help_context='error') comment = web.input().comment board_info = board.get_board_info(board_id) ret = article.write_comment(current_uid, board_id, article_id, comment) if ret[0] == True: user.update_unreaded_articles_board(current_uid, board_id) user.read_article(current_uid, ret[1]) raise web.seeother(util.link('/%s/+read/%s') % (board_name, article_id)) else: return util.render().error(error_message = ret[1], help_context='error')
def leave_post(self, current_uid = -1): user_id = current_uid usr = user.get_user(user_id)[1] password = web.input().password if not user.verify_password(user_id, password): return util.render().error(error_message= _('INVALID_PASSWORD'), help_context='error') result = user.delete_user(user_id) if not result[0]: return util.render().error(error_message = result[1], help_context='error') web.ctx.session.uid = 0 web.ctx.session.kill() raise web.seeother(util.link('/'))
def contextMenuEvent(self, event): event.accept() axes = self.get_axes_at_point(event.x(), event.y()) if axes is None: menu = QtGui.QMenu(self) menu.addActions([self.tab_bar.rename_action, self.timescale_action]) menu.popup(event.globalPos()) return menu = QtGui.QMenu(self) menu.addAction(axes.set_title_action) menu.addAction(axes.adjust_axes_action) menu.addAction(axes.adjust_signals_action) delete_action = menu.addAction("Delete Plot") menu.addSeparator() menu.addAction(self.tab_bar.rename_action) menu.addAction(self.timescale_action) link(delete_action.triggered, lambda: self.remove_plot(axes)) menu.popup(event.globalPos())
def modify_get(self, board_name, board_id, current_uid = -1): board_info = board.get_board_info(board_id) if not acl.is_allowed('board', board_id, current_uid, 'modify'): return util.render().error(error_message=_('NO_PERMISSION'), help_context='error') if board_id == 1: board_name = '^root' default_referer = posixpath.join(util.link('/'), board_name, '+summary') return util.render().board_edit( action='modify', board_info = board_info, board_path = board_name, board_desc = board_info.bDescription, stylesheet = board_info.stylesheet, title = _('Modify information - %s') % (board_info.bName), referer = web.ctx.env.get('HTTP_REFERER', default_referer))
def delete_message_get(self, current_uid = -1): # XXX: 현재는 메시지 번호를 Query String에 담아서 전달한다. # 차후 정규 표현식을 고쳐서 다른 게시판처럼 만들어야 한다. message_id = -1 qs = web.ctx.query if len(qs) > 0: qs = qs[1:] qs = parse_qs(qs) if qs: message_id = int(qs['message_id'][0]) else: raise web.notfound(util.render().error(error_message=_('NO_SUCH_MESSAGE'), help_context='error')) mail = pm.get_mail(message_id) if mail.mReceiverSerial != current_uid: raise web.unauthorized(util.render().error(error_message=_('NO_PERMISSION'), help_context='error')) default_referer = posixpath.join(util.link('/+u'), '+inbox') action='%s?message_id=%s' % (posixpath.join(util.link('/+u'), '+delete_message'), message_id) return util.render().question( question=_('Do you want to delete the message?'), board_path = '', board_desc = _('Confirmation'), title=_('Confirmation'), action = action, referer=web.ctx.env.get('HTTP_REFERER', default_referer))
def login_post(self): user_input = web.input() username, password = user_input.username.strip(), user_input.password.strip() referer = user_input.url.strip() if referer == '' or referer == 'None': referer = web.ctx.env.get('HTTP_REFERER', 'http://noah.kaist.ac.kr' + util.link('/')) if referer.endswith('/+login'): referer = referer[:-6] err = '' valid = True login = (False, _('UNDEFINED')) autologin = user_input.has_key('autologin') username, password = username.strip(), password.strip() if username == '' or password == '': err = _('No user ID or password specified.') valid = False if not valid: return util.render().login(title = _('Login'), board_desc=_('Login'), lang="ko", error = err, referer = referer) login = user.login(username, password) if login[0]: # 로그인 성공. +login_xdomain에서는 세션 설정 후 referer로 돌아감. ts = user.add_login_info(username, user._generate_noah3k_password(password), referer, autologin) xdomain_qs = urllib.urlencode({'t':ts, 'username':username}) if referer.startswith('https'): pos = referer.find('/', len('https')+3) if pos > 0: host = referer[:pos] else: host = util.https() elif referer.startswith('http'): pos = referer.find('/', len('http')+3) if pos > 0: host = referer[:pos] else: host = 'http://noah.kaist.ac.kr' else: host = 'http://noah.kaist.ac.kr' raise web.seeother('%s/+login_xdomain?%s' % (host, xdomain_qs)) else: # 로그인 실패 err = login[1] return util.render().login(title = _('Login'), board_desc=_('Login'), lang="ko", error = err, referer = referer)
def login_get(self): if web.config.theme == 'm': referer = web.ctx.env.get('HTTP_REFERER', '/m/+u/+new_article') if referer.endswith('/m') or referer.endswith('/m/'): referer = '/m/+u/+new_article' else: referer = web.ctx.env.get('HTTP_REFERER', util.link('/')) try: if web.ctx.session.uid is not 0: web.seeother(referer) except AttributeError: pass return util.render().login(title = _('Login'), board_desc=_('Login'), lang="ko", referer = referer)
def delete_message_post(self, current_uid = -1): # XXX: 현재는 메시지 번호를 Query String에 담아서 전달한다. # 차후 정규 표현식을 고쳐서 다른 게시판처럼 만들어야 한다. message_id = -1 qs = web.ctx.query if len(qs) > 0: qs = qs[1:] qs = parse_qs(qs) if qs: message_id = int(qs['message_id'][0]) else: raise web.notfound(util.render().error(error_message=_('NO_SUCH_MESSAGE'), help_context='error')) mail = pm.get_mail(message_id) result = pm.delete_mail(message_id) if result[0]: raise web.seeother(util.link('/+u/+inbox')) else: return util.render().error(error_message = ret[1], help_context = 'error')
def html_from_cell(x, output_dir): if type(x) == type(''): # text return x elif type(x) == type(np.array([])): return html_from_cell(('img', x), output_dir) elif hasattr(x, '__video__') and x.__video__: return x.make_html(output_dir) elif hasattr(x, '__cycle__') and x.__cycle__: return x.make_html(output_dir) elif type(x) == type((1, )): if x[0] in ('img', 'img_mv', 'img-png'): path = path_from_im(x, output_dir) if len(x) >= 3 and type(x[2]) == type({}): opts = x[2] else: opts = dict(ut.split_n(x[2:], 2)) # for tool-tips maybe_title = ('title = "%s"' % opts['title']) if 'title' in opts else '' html = "<img src = '%s' %s>" % (path, maybe_title) if 'link' in opts: html = ut.link(opts['link'], html) return html elif x[0] == 'animation': # make an animated gif duration = (0.5 if len(x) < 3 else float(x[2])) seq_fname = make_temp_animated_gif(x[1], duration=duration, dir=output_dir) return html_from_cell(('img_mv', seq_fname), output_dir) elif x[0] == 'cycle': # clicking: advance column; number keys: change row; shift-click: move by 10 frames; control-click: query user for column; im_table = x[1] group = None if len(x) < 3 else x[2] # format: [0, 0] (default) | col | [row, col] if len(x) < 4: start = [0, 0] elif np.ndim(x[3]) == 0: start = [0, x[3]] else: start = x[3] if len(im_table) == 0 or type(im_table[0]) != type([]): im_table = [im_table] return cycle_html([[path_from_im(im, output_dir) for im in row] for row in im_table], group, start) elif x[0] == 'table': return '<table border = 1>%s</table>' % ('<tr>'.join( html_from_rows(x[1], output_dir))) #ut.fail("Invalid tuple in table.") elif hasattr(x, '__call__'): # call function; make a cell from the result return html_from_cell(x(), output_dir) # # allow table of tables # elif type(x) == type([]): # return '<table border = 1>%s</table>' % ('<tr>'.join(html_from_rows(x, output_dir))) else: return str(x)
def new(self): """Cria e salva um novo item.""" editpanel = edit_view(link()) if editpanel.has_changes: self.control.save(editpanel.link) self.refresh()