Exemplo n.º 1
0
def user_profile(request, email):
    User = get_user_model()
    userprofile = User.objects.get(email=email).userprofile
    # lease__lesee looks at workspaces connected to leases (e.g. foreign key)
    # and effectively returns all workspaces where request.user is a tenent 
    leased_workspaces = Workspace.objects.filter(lease__lessee=request.user) 
    reviews = UserReview.objects.filter(reviewee=userprofile.user)
    average_rating = services.get_average_review_rating(reviews)
    
    return render(request, 'userprofile/userprofile.html', {'profile': userprofile,
                                                            'leased_workspaces': leased_workspaces,
                                                            'reviews': reviews,
                                                            'average_rating': average_rating})
Exemplo n.º 2
0
def get_average_rating(reviews):
  """
    Returns average rating of reviews
  """
  return services.get_average_review_rating(reviews)