Пример #1
0
def update(request, docid):
    if request.method == 'POST':
        if not request.is_xhr:
            p = Project.db.get(docid)
            factories = {'active': bool, 'featured': bool, 'tags': lambda x: x.split(' ')}
            keys = ( 'active', 'featured', 'tags'
                   , 'category', 'name', 'text', 'preview_small', 'preview_big'
                   , 'download_mac', 'download_pc')
            
            p['id'] = make_id(request.form.get('name'))
            
            for k in keys:
                v = request.form.get(k)
                
                p[k] = (factories[k](v) if k in factories else v)
            
            Project.update(p)

            return redirect(url_for('update', docid=docid))
        
    elif request.method == 'GET':
        if not request.is_xhr:
            project = Project.db.get(docid)
            project["tags"] = " ".join(project["tags"])

            context = {
                'project': project,
                'user': {
                    'roles': request.session.get('roles', []) 
                },
                'debug': request.debug
            }

            return render_html('projects/update.html',context)
Пример #2
0
def index(request):
    if not request.is_xhr:
            
        context = {
            'featured': [wrap(p) for p in Project.allFeatured()],
            'active': reversed([wrap(p) for p in Project.allActiveNotFeatured()]),
            'user': {
                'roles': request.session.get('roles', []) 
            },
            'debug': request.debug
        }
        
        return render_html('index.html', context)
                                
    else:
        raise NotImplementedError('nothing here')
Пример #3
0
def retrieve(request, docid):
    if request.method == 'GET':
        project = Project.retrieve(docid)
        
        if not request.is_xhr:
            context = {
                "project": project,
                'user': {
                    'roles': request.session.get('roles', []) 
                },
                'debug': request.debug
            }
            
            return render_html('projects/retrieve.html',context)
Пример #4
0
def atom(request):
    if request.method == 'POST':
        activeDocResults = Project.allActive()
        activeResults = [wrap(project) for project in activeDocResults]
    
        context = {
            'active': reversed(activeResults),
            'user': {
                'roles': request.session.get('roles', []) 
            },
            'debug': request.debug
        }
    
        return render_atom('projects/atom.xml', context)
Пример #5
0
def rss(request):
    if request.method == 'GET':
        active_doc_results = Project.allActive()
        active_results = [wrap(project) for project in active_doc_results]

        context = {
            'active': reversed(active_results),
            'user': {
                'roles': request.session.get('roles', []) 
            },
            'debug': request.debug
        }

        return render_xml('projects/rss2.xml', context)
Пример #6
0
def plist(request):
    
    active_results = [wrap(p) for p in Project.allActive()]
    
    
    if not request.is_xhr and request.method == 'GET':
        
        context = {
            'active': reversed(active_results),
            'user': {
                'roles': request.session.get('roles', []) 
            },
            'debug': request.debug
        }
        
        return render_html('/projects/list.html', context)
    
    
    elif request.is_xhr and request.method == 'GET':
        
        return Response(simplejson.dumps(active_results), 
                        mimetype='application/json')
Пример #7
0
def delete(request,docid):
    if not request.is_xhr:
        Project.delete(docid)
        return redirect(url_for('plist'))