Skip to content

Commit

Permalink
Adds a generic reordering function to CTK.SortableList. Basically, it
Browse files Browse the repository at this point in the history
applies common sorting changes to a CTK.cfg sub-tree.

git-svn-id: svn://cherokee-project.com/CTK/trunk@5570 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Sep 28, 2010
1 parent 6197525 commit 5d155e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion CTK/SortableList.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#

from Table import Table
from Server import publish
from PageCleaner import Uniq_Block
from Server import publish, post, cfg, cfg_reply_ajax_ok

HEADER = [
'<script type="text/javascript" src="/CTK/js/jquery.tablednd_0_5.js"></script>'
Expand Down Expand Up @@ -107,3 +107,21 @@ def set_header (self, row_num):

# Let Table do the rest
Table.set_header (self, num=row_num)


def SortableList__reorder_generic (post_arg_name, pre, step=10):
# Process new list
order = post.pop (post_arg_name)
tmp = order.split(',')

# Build and alternative tree
num = step
for v in tmp:
cfg.clone ('%s!%s'%(pre, v), 'tmp!reorder!%s!%d'%(pre, num))
num += step

# Set the new list in place
del (cfg[pre])
cfg.rename ('tmp!reorder!%s'%(pre), pre)

return cfg_reply_ajax_ok()
2 changes: 1 addition & 1 deletion CTK/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from Plugin import PluginSelector
from Refreshable import Refreshable, RefreshableURL
from Image import Image, ImageStock
from SortableList import SortableList
from SortableList import SortableList, SortableList__reorder_generic
from Indenter import Indenter
from Notice import Notice
from Link import Link, LinkWindow, LinkIcon
Expand Down

0 comments on commit 5d155e6

Please sign in to comment.