示例#1
0
    if(request.method == 'POST') and listing.user == users.get_current_user():
        listing.delete()
        flash(u'Listing deleted successfully', 'success')
        return redirect(url_for('manage_listings'))
    else:
        flash(u'You do not have permissions to perform that operation', 'error')
        return redirect(url_for('profile'))
        
@account_required
def profile():
    '''Landlord management dashboard.'''
    user = users.get_current_user()
<<<<<<< HEAD
    landlord = Landlord.get_by_user(user)
=======
    landlord = Contact.get_by_user(user)
>>>>>>> d76fc545aab7b1e1556c2efea62c18d4a20978f6
    #Generate statistics for the landlord's listings
    listings = Listing.gql('WHERE user = :1', user).count()
    available = Listing.gql('WHERE user = :1 AND occupied = False', user).count()
    occupied = listings - available
    stats = { 'listings' : listings, 'available' : available, 'occupied' : occupied }
    return render_template('dashboard.html', landlord=landlord, stats=stats)
    
@account_required
<<<<<<< HEAD
def update_landlord():
    '''Allow user to update their landlord information'''
    landlord = Landlord.get_by_user(users.get_current_user())
=======
def update_contact():