~thomir-deactivatedaccount/sloecode/error-style

« back to all changes in this revision

Viewing changes to sloecode/lib/helpers.py

  • Committer: Thomi Richards
  • Date: 2011-01-13 22:17:38 UTC
  • mfrom: (32.1.5 help)
  • Revision ID: thomir@gmail.com-20110113221738-tex9bxnz9nvrnixi
Basic help system in place.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
# functions here. That way we can add a bit more intelligence in our web forms.
10
10
from webhelpers.html.tags import form, end_form, text, password, submit, checkbox
11
11
from webhelpers.html.tags import stylesheet_link, ModelTags, hidden, select
12
 
from webhelpers.html.tags import checkbox as checkbox
 
12
from webhelpers.html.tags import checkbox, image
13
13
 
14
 
# a simple patch to the checkbox function that shows the caption value as well
15
 
#def checkbox(name, value='1', checked=False, label=None, **kwargs)
16
14
# a simple link_to implementation that handles a confirm kwarg that prints
17
15
# very simple javascript asking the user if they really want to continue.
18
16
from webhelpers.html.tags import link_to as _link_to
44
42
from sloecode.lib.security import has_site_role, has_project_role
45
43
# import site role names as well:
46
44
from sloecode.model.site_role import USER_ADMIN, PROJECT_ADMIN
 
45
 
 
46
 
 
47
# Help support:
 
48
def help_link(label, target):
 
49
    """
 
50
    Returns HTML code that creates a link to a help topic. Help topics are
 
51
    specified by the 'target' parameter. The topic should be the path of a
 
52
    help file, relative to the help_pages directory, either with, or without
 
53
    the '.html' extension.
 
54
    """
 
55
    if target[-5:].lower != '.html':
 
56
        target += '.html'
 
57
    if target[0] == '/':
 
58
        target = target[1:]
 
59
 
 
60
    # TODO - make this print a nice link, and maybe not open in a new window,
 
61
    # but rather have some JS that only opens one help page at once?
 
62
    img = image('/question-white.png', 'Help Topic', class_='help_icon')
 
63
    return link_to(img + label, 'javascript:help_window("/help/' +
 
64
        target+'")', class_='help_link')