]> git.parisson.com Git - teleforma.git/commitdiff
Override telemeta profile to add payment
authorYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 13 Feb 2020 09:06:33 +0000 (10:06 +0100)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 13 Feb 2020 09:06:33 +0000 (10:06 +0100)
teleforma/urls.py
teleforma/views/crfpa.py

index cc5d807579ac3352a291609d9e80b685452c1c81..2c547732cafa43a35c867546fdc2ad3cf2b8ac8d 100644 (file)
@@ -45,7 +45,7 @@ from registration.views import *
 from jsonrpc import jsonrpc_site
 
 htdocs_forma = os.path.dirname(__file__) + '/static/teleforma/'
-profile_view = ProfileView()
+profile_view = CRFPAProfileView()
 document = DocumentView()
 media = MediaView()
 
@@ -59,12 +59,17 @@ urlpatterns = patterns('',
     url(r'^accounts/register/(?P<username>.*)/complete/$', UserCompleteView.as_view(), name="teleforma-register-complete"),
     url(r'^accounts/register/(?P<username>.*)/download/$', RegistrationPDFViewDownload.as_view(), name="teleforma-registration-download"),
     url(r'^accounts/register/(?P<username>.*)/view/$', RegistrationPDFView.as_view(), name="teleforma-registration-view"),
-    
+        
     url(r'^correctors/register/$', CorrectorAddView.as_view(), name="teleforma-corrector-register"),
     url(r'^correctors/register/(?P<username>.*)/complete/$', CorrectorCompleteView.as_view(), name="teleforma-corrector-register-complete"),
     url(r'^correctors/register/(?P<username>.*)/download/$', CorrectorRegistrationPDFViewDownload.as_view(), name="teleforma-corrector-registration-download"),
     url(r'^correctors/register/(?P<username>.*)/view/$', CorrectorRegistrationPDFView.as_view(), name="teleforma-corrector-registration-view"),
 
+    url(r'^users/(?P<username>[A-Za-z0-9+@._-]+)/profile/$', profile_view.profile_detail,
+                               name="teleforma-profile-detail"),
+    url(r'^accounts/(?P<username>[A-Za-z0-9._-]+)/profile/$', profile_view.profile_detail, name="telemeta-profile-detail"),
+    url(r'^accounts/(?P<username>[A-Za-z0-9._-]+)/profile/edit/$', profile_view.profile_edit, name="telemeta-profile-edit"),
+    
     url(r'^captcha/', include('captcha.urls')),
 
     # Help
@@ -127,9 +132,6 @@ urlpatterns = patterns('',
     url(r'^users/training/(?P<training_id>.*)/iej/(?P<iej_id>.*)/course/(?P<course_id>.*)/export/$',
         UsersExportView.as_view(), name="teleforma-users-export"),
 
-    url(r'^users/(?P<username>[A-Za-z0-9+@._-]+)/profile/$', profile_view.profile_detail,
-                               name="teleforma-profile-detail"),
-
     url(r'^users/(?P<id>.*)/login/$', UserLoginView.as_view(), name="teleforma-user-login"),
 
     # Ajax update training
index a40c17217a89fb4721d4d952aa0dfc33c4840e25..a749ab387ae8d6a63c783f8a8adbf55da47ebd6d 100644 (file)
@@ -35,6 +35,7 @@ from teleforma.models.crfpa import Parameters
 from teleforma.models.core import Period
 from teleforma.views.core import *
 from teleforma.forms import WriteForm
+from telemeta.views import ProfileView
 from registration.views import *
 from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet
 from postman.views import WriteView as PostmanWriteView
@@ -836,3 +837,25 @@ class WriteView(PostmanWriteView):
     form_classes = (WriteForm, AnonymousWriteForm)
     success_url = "postman_sent"
 
+class CRFPAProfileView(ProfileView):
+    """Provide Collections web UI methods"""
+
+    @method_decorator(login_required)
+    def profile_detail(self, request, username, template='telemeta/profile_detail.html'):
+        user = User.objects.get(username=username)
+        try:
+            profile = user.get_profile()
+        except:
+            profile = None
+        playlists = get_playlists(request, user)
+        user_revisions = get_revisions(25, user)
+        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})