コード例 #1
0
ファイル: frontend.py プロジェクト: JOSMANC/nyan
def ajax_subscripe():
    '''
    Called remotely to subscripe current user to a vendor
    '''
    if not current_user.is_authenticated():
        abort(403)     
        
    vendor_id = request.form['vendor_id']        
    app.logger.error("Subscribe user to %s" % vendor_id)
    try:
        new_vendor = Vendor.objects(id=vendor_id).first()
        current_user.add_vendor_to_subscriptions(new_vendor)
    except Exception as inst:
        app.logger.error("Could not subscribe user %s: %s" % (type(inst), type))
        abort(500)
        
    return ""
コード例 #2
0
ファイル: frontend.py プロジェクト: JOSMANC/nyan
def ajax_unsubscripe():
    '''
    Called remotely to unsupscribe current user from vendor 
    '''
    if not current_user.is_authenticated():
        abort(403)
        
    vendor_id = request.form['vendor_id']
        
    app.logger.error("Unsubscribe user from %s" % vendor_id)
    try:
        vendor = Vendor.objects(id=vendor_id).first()
        current_user.remove_vendor_from_subscriptions(vendor)
    except Exception as inst:
        app.logger.error("Could not unsubscribe user %s: %s" % (type(inst), type))
        abort(500)
        
    return ""
コード例 #3
0
ファイル: frontend.py プロジェクト: JOSMANC/nyan
def subscriptions():
    return render_template('subscriptions.html', 
                           tab="subscriptions", date = datetime.now(),
                           vendors = Vendor.objects())