def album(request): username = request.session['username'] menu=1 try: passwd = cass.get_passwd(username) except cass.DatabaseError: raise Http404 """ # Query for the friend ids friend_usernames = [] friend_usernames = cass.get_friend(username) + [username] # Add a property on the user to indicate whether the currently logged-in # user is friends with the user user['friend'] = username in friend_usernames """ limit = request.GET.get('start') if not limit: limit='20' photos,next = cass.get_photos(username, limit=limit) context = { 'user': username, 'username': username, 'photos': photos, 'next': next, 'menu':menu, } return render_to_response('photo/album.html', context, context_instance=RequestContext(request))
def clean(self): username = self.cleaned_data['username'] password = self.cleaned_data['password'] try: passwd = cass.get_passwd(username) except cass.DatabaseError: raise forms.ValidationError(u'Invalid username and/or password') if passwd != password: raise forms.ValidationError(u'Invalid username and/or password') return self.cleaned_data
def get_user(request): if 'username' in request.session: try: ''' passwd = cass.get_passwd(request.session['username']) #user=request.session['username'] request.session['username']['is_authenticated'] = True return passwd ''' user = cass.get_user_by_username(request.session['username']) passwd = cass.get_passwd(request.session['username']) user['passwd']=passwd return user except cass.DatabaseError: pass return { 'password': None, 'is_authenticated': False, }