✏️ 编辑:cell_change.py
路径:
/virtual/bigbrother/public_html/edream-c.com/cr/PLUGINS/cell_change.py
大小:3.04 KB · 修改:2013-10-23 19:47:15 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
#!/usr/bin/env python # -*- coding: utf-8 -*- # TOMUSS: The Online Multi User Simple Spreadsheet # Copyright (C) 2008 Thierry EXCOFFIER, Universite Claude Bernard # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Contact: Thierry.EXCOFFIER@bat710.univ-lyon1.fr from .. import utilities from .. import plugin from .. import document def cell_change(server): col = server.the_path[0] lin = server.the_path[1] value = server.the_path[2] table = document.table(server.the_year, server.the_semester, server.the_ue, create=False) column = table.columns.from_id(col) if lin not in table.lines or column is None: return 'bad.png' # Test if the column is modifiable in the 'suivi' if not column.is_modifiable(server.ticket.is_a_teacher, server.ticket, table.lines[lin][column.data_col]): return 'bad.png' # The student can only modify its line if (not server.ticket.is_a_teacher and table.the_keys()[server.ticket.user_name][0] != lin): return 'bad.png' year, semester, ue = server.the_year, server.the_semester, server.the_ue if table.is_extended: year, semester, ue = table.link_to() table, page = document.table(year, semester, ue, None, server.ticket, do_not_unload='cell_change') try: table.lock() try: try: return table.cell_change(page, col, lin, value) except ValueError: return 'bad.png' finally: table.unlock() finally: table.do_not_unload_remove('cell_change') def cell(server): """Modify an unique cell in a table. It is used by the 'suivi' page""" r = cell_change(server) if r == 'bad.png': server.the_file.write( '<body style="background:red"><script>alert(%s)</script>' % utilities.js(server._("ERROR_value_not_modifiable"))) elif r == 'ok.png': server.the_file.write('<body style="background:green">') else: server.the_file.write( '<body style="background:#F0F"><script>alert(%s)</script>' % utilities.js(server._("TIP_violet_square"))) plugin.Plugin('cell', '/{Y}/{S}/{U}/cell/{*}', function=cell, priority = -10 # Before student_redirection )
💾 保存
取消
保存为 UTF-8,换行统一为 LF