]> git.parisson.com Git - telemeta.git/commitdiff
Add payment info on profile page
authorYoan Le Clanche <yoanl@pilotsystems.net>
Mon, 10 Feb 2020 13:17:57 +0000 (14:17 +0100)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Mon, 10 Feb 2020 13:17:57 +0000 (14:17 +0100)
telemeta/views/profile.py

index 8cdfd32c36613db09bc3de767ea726354a47f332..3b89224b84346ff6b4e1e5b6461a2aaaa7ba2134 100644 (file)
@@ -50,8 +50,15 @@ class ProfileView(object):
             profile = None
         playlists = get_playlists(request, user)
         user_revisions = get_revisions(25, user)
-
-        return render(request, template, {'profile' : profile, 'usr': user, 'playlists': playlists,
+        student = user.student.all()
+        payment = None
+        if student and (user.username == request.user.username or request.user.is_superuser):
+            student = user.student.get()
+            payment = student.payments.order_by('-id').all()
+            if payment:
+                payment = payment[0]
+
+        return render(request, template, {'profile' : profile, 'usr': user, 'playlists': playlists, 'payment':payment,
                                           'user_revisions': user_revisions})
 
     @method_decorator(login_required)