lib/actions/folder.py
author fabien@tzone.org
Wed, 31 Dec 2008 15:41:32 -0500
changeset 74 6784c4350b41
parent 58 lib/folders.py@004a32370ba5
child 75 4f6b7b48322f
permissions -rw-r--r--
Cleanup of old code, fixes some errors with folders view and make it a standard action.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47
2781ac85b807 [svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff changeset
     1
from templates import Template
74
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
     2
from folders import do_folders
47
2781ac85b807 [svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff changeset
     3
74
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
     4
def add_folder(db, form):
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
     5
	keyword = int(form['selection'].value)
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
     6
	parent = 0
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
     7
	if (form.has_key('folder'):
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
     8
		parent = int(form['folder'].value)
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
     9
	db.add_folder(keyword, parent)
47
2781ac85b807 [svn r1604] Implement default_view preferences, which move things around a lot.
fabien
parents:
diff changeset
    10
74
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    11
def remove_folder(db, form):
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    12
	keyword = int(form['selection'].value)
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    13
	db.remove_folders(keyword)
53
e80160a19653 [svn r1610] Lots of "small" bugs corrected.
fabien
parents: 52
diff changeset
    14
74
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    15
def do_it(action, db, prefs, form):
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    16
	status = 'result'
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    17
	status_msg = 'Unknown action'
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    18
	if form.has_key('step'):
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    19
		step = form['step'].value
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    20
		if (step == 'add'):
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    21
			add_folder(db, form)
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    22
			status_msg = "Folder successfully added."
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    23
		elif (step == 'delete'):
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    24
			remove_folder(db, form)
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    25
			status_msg = "Folder successfully removed."
6784c4350b41 Cleanup of old code, fixes some errors with folders view and make it a
fabien@tzone.org
parents: 58
diff changeset
    26
	do_folders(db, prefs, form, status, status_msg)