Example #1
0
def dir(id):
    def tagstring(str,tag):
        return "<%s>%s</%s>"%(tag,str,tag)
    PTYPE2URI = {
        'f':'file',
        'd':'dir'
    }
    from copyright import crtype2csstag
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    assert(path.type=='d')
    children = ScanPathes.filter(ScanPathes.c.parent==path.id)
    
    from forms import ReleaseForm
    rform = ReleaseForm()
    if request.method == 'POST':
        if rform.validate(request.params, request.files):
            release = rform.data['release']
            rnote = rform.data['rnote']
            changed = False
            if release!=path.release:
                path.release=release
                changed = True
                if release:
                    flash("Release this package !")
                else:
                    flash("Do not release this package !")
            if rnote!=path.rnote:
                path.rnote = rnote
                changed = True
            if changed:
                path.save()
    else:
        rform.data['release']=path.release
        rform.data['rnote']=path.rnote
    return {
        'path':path,
        'children':children,
        'crtype2csstag':crtype2csstag,
        'tagstring':tagstring,
        'PTYPE2URI':PTYPE2URI,
        'rform':rform,
    }
Example #2
0
def dir(id):
    def tagstring(str, tag):
        return "<%s>%s</%s>" % (tag, str, tag)

    PTYPE2URI = {'f': 'file', 'd': 'dir'}
    ScanPathes = get_model("scanpathes")
    path = ScanPathes.get(id)
    assert (path.type == 'd')
    children = ScanPathes.filter(ScanPathes.c.parent == path.id)

    from forms import ReleaseForm
    rform = ReleaseForm()
    if request.method == 'POST':
        if rform.validate(request.params, request.files):
            release = rform.data['release']
            rnote = rform.data['rnote']
            changed = False
            if release != path.release:
                path.release = release
                changed = True
                if release:
                    flash("Release this package !")
                else:
                    flash("Do not release this package !")
            if rnote != path.rnote:
                path.rnote = rnote
                changed = True
            if changed:
                path.save()
    else:
        rform.data['release'] = path.release
        rform.data['rnote'] = path.rnote
    return {
        'path': path,
        'children': children,
        'crtype2csstag': crtype2csstag,
        'tagstring': tagstring,
        'PTYPE2URI': PTYPE2URI,
        'rform': rform,
    }