From 8fbbdf5fbfe3d1b68f260f3d39eae0788ff57772 Mon Sep 17 00:00:00 2001 From: yomguy Date: Fri, 20 Apr 2012 14:46:15 +0200 Subject: [PATCH] add admin "login as" button and view --- teleforma/locale/fr/LC_MESSAGES/django.mo | Bin 3995 -> 4266 bytes teleforma/locale/fr/LC_MESSAGES/django.po | 28 ++++++++---------- .../templates/telemeta/profile_detail.html | 1 + teleforma/urls.py | 1 + teleforma/views.py | 16 +++++++++- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/teleforma/locale/fr/LC_MESSAGES/django.mo b/teleforma/locale/fr/LC_MESSAGES/django.mo index 8fd358346fd46f1043a95df210570a6006186cb4..d21bea94a79ab8b80b04cdfb0ca85db9299add49 100644 GIT binary patch delta 2132 zcmZXVYiv|S6vu}?*lpPYr9KK;xJ3$55TVuzMNtYZAfSCwi3p^ww`Ie!3%lC{O?1^5 zO(2r!jihR0LZX49d|^XONPMMg0$&>C1F<0`F*PBp2IB93J)4*~ng9IGnYlA_ z?wPr}?=LuApP!sl_Ku_MM0cYrCC=sHNI4B5+gr11=_#4o@y_&J;b#~{^> z8!tnRUxj*p3TnOIAkXLBO?#js>Rbf_Ga=R0(v-q_^BdqS{1uQXZk_oZ#y+Tx2B7Bc zhg6rg{=;xK{)IlYkIz9?JocjbSkaJKGe_{O>q2BP4`B%-qX8s@M--Mc9 zK_k}CDBwD%02|;;*r8aO8@~V*;J9%DvbXyQYNKDR z{|3|x-hx`EoJk6(8s=rp#n3|aG)m2K^IM@Nv_mc21-0tx%C}gk;lo8h1ejG60pS15hc> zLT&sy)cj*m^M|3H`w(iK)5ddfFaDR1_43Xm9Bj7)hAD!Y&<1q`+pWJF>dp2*rFal( z!^779D%8;&g*uvH^Upx7d*1jhRKVZEQhomu7+PpD>~QXy@n@(&euuiFxNBFS8RZ zK?~6ivi-)>U zH_{RGBHi*us1Gee#j-Rs$p51l_oKPR5#z&9-|BLtybRS!M~ zdj)&|HK46%0ct^;5hoh{l(#FgVz~!n8=8-F(bgfArr?+9bwODq6J#PggKr{UbX$5b zk@EVp!Bph=SZ5|ZkVyKjJDomIcqY23B-*snTh-j!+*0_svT<7Z*yyuEx!}@_cO=9os&kXt**O5pCeX-pY?J4iMM8=Qjg0r#3wLQKUPp4A2 ge#Y}tUamit^9~L9!R6SSwzuo)PbU3BylQpHKT;IJ>;M1& delta 1895 zcmYk7ZD@^Q7{~7&8^^X|GcOy%Hf*+;m&3*}ubUb3HZLnAu||xuBRi87c~T06~0FZxP7{MM(HS@%x{1k*o86e)o01T-SYH_w#fv7o5rSUS%bpbl3_s z3|;j(*8*px@W4Lzb}j(FKz03wsW7FFbIC9hrolmwpDQqyK#d2X=1+l&Qw24@J~8gO zwKV$Du>tzwR$~-q;O~L_++p)i7(1X6+Ge z6WKs2tF^NMP=WHyFE+p2{FzVz>WnL4Km2u&P%do!ZN|M&l{;wuQK&qp;VSaG4x8`` zs#HFrivdWN%Yiy+f%O+bohS$uC0V-gp^jt_5Xs3m#q40Vg{Z{mOYW1 zHXdWH3@TsGNm66pX5I?Ck\n" "Language-Team: LANGUAGE \n" @@ -341,7 +341,7 @@ msgstr "Messages" #: templates/postman/base_write.html:20 #: templates/teleforma/course_conference.html:57 #: templates/teleforma/course_detail.html:69 -#: templates/teleforma/course_document.html:45 +#: templates/teleforma/course_document.html:87 #: templates/teleforma/course_media.html:84 #: templates/teleforma/courses.html:102 msgid "Send" @@ -492,7 +492,7 @@ msgstr "Supports écrits" #: templates/teleforma/course.html:18 templates/teleforma/course.html.py:34 #: templates/teleforma/course_conference.html:33 -#: templates/teleforma/course_document.html:21 +#: templates/teleforma/course_document.html:68 #: templates/teleforma/inc/document_list.html:11 #: templates/teleforma/inc/media_list.html:11 templates/telemeta/lists.html:69 #: templates/telemeta/search_criteria.html:97 @@ -522,14 +522,12 @@ msgstr "Conférences" #: templates/teleforma/course.html:51 #: templates/teleforma/course_conference.html:34 -#: templates/teleforma/course_document.html:22 #: templates/teleforma/inc/conference_list.html:13 msgid "Session" msgstr "Session" #: templates/teleforma/course.html:52 #: templates/teleforma/course_conference.html:35 -#: templates/teleforma/course_document.html:23 #: templates/teleforma/course_media.html:51 #: templates/teleforma/inc/conference_list.html:14 #: templates/telemeta/inc/user_list.html:51 @@ -537,23 +535,20 @@ msgid "Professor" msgstr "Professeur" #: templates/teleforma/course_conference.html:36 -#: templates/teleforma/course_document.html:24 msgid "Begin" -msgstr "" +msgstr "Début" #: templates/teleforma/course_conference.html:37 -#: templates/teleforma/course_document.html:25 msgid "End" -msgstr "" +msgstr "Fin" #: templates/teleforma/course_conference.html:38 -#: templates/teleforma/course_document.html:26 msgid "Live" -msgstr "" +msgstr "En direct" #: templates/teleforma/course_conference.html:50 #: templates/teleforma/course_detail.html:62 -#: templates/teleforma/course_document.html:38 +#: templates/teleforma/course_document.html:80 #: templates/teleforma/course_media.html:77 msgid "Local tweeter" msgstr "Tweeter local" @@ -604,7 +599,7 @@ msgstr "" #: templates/teleforma/inc/conference_list.html:12 msgid "Room" -msgstr "" +msgstr "Salle" #: templates/teleforma/inc/conference_list.html:16 msgid "Streaming" @@ -665,9 +660,8 @@ msgid "Admin" msgstr "" #: templates/telemeta/base.html:106 -#, fuzzy msgid "Profile" -msgstr "profil" +msgstr "Profil" #: templates/telemeta/base.html:108 msgid "Lists" @@ -805,6 +799,10 @@ msgstr "" msgid "Apply" msgstr "" +#: templates/telemeta/profile_detail.html:91 +msgid "Login as" +msgstr "Se connecter en tant que" + #: templates/telemeta/search_criteria.html:5 #: templates/telemeta/search_criteria.html:76 msgid "Advanced Search" diff --git a/teleforma/templates/telemeta/profile_detail.html b/teleforma/templates/telemeta/profile_detail.html index 314b0582..be371ffb 100644 --- a/teleforma/templates/telemeta/profile_detail.html +++ b/teleforma/templates/telemeta/profile_detail.html @@ -88,6 +88,7 @@ + diff --git a/teleforma/urls.py b/teleforma/urls.py index 559ab0d2..2a611479 100644 --- a/teleforma/urls.py +++ b/teleforma/urls.py @@ -64,6 +64,7 @@ urlpatterns = patterns('', url(r'^users/by_training/(\w+)/$', UsersTrainingView.as_view(), name="teleforma-training-users"), url(r'^users/all/export/$', user_export.all, name="teleforma-users-xls-export"), url(r'^users/by_training/(?P.*)/export/$', user_export.by_training, name="teleforma-training-users-export"), + url(r'^users/(?P.*)/login/$', UserLoginView.as_view(), name="teleforma-user-login"), # CSS+Images (FIXME: for developement only) url(r'^teleforma/css/(?P.*)$', 'django.views.static.serve', diff --git a/teleforma/views.py b/teleforma/views.py index 6935785c..4a126fed 100755 --- a/teleforma/views.py +++ b/teleforma/views.py @@ -5,7 +5,7 @@ import mimetypes from jsonrpc import jsonrpc_method from django.utils.decorators import method_decorator -from django.contrib.auth import authenticate, login +from django.contrib.auth import authenticate, login, get_backends from django.template import RequestContext, loader from django import template from django.http import HttpResponse, HttpResponseRedirect @@ -229,6 +229,20 @@ class UsersView(ListView): return super(UsersView, self).dispatch(*args, **kwargs) +class UserLoginView(View): + + def get(self, request, id): + user = User.objects.get(id=id) + backend = get_backends()[0] + user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__) + login(self.request, user) + return redirect('teleforma-desk') + + @method_decorator(permission_required('is_superuser')) + def dispatch(self, *args, **kwargs): + return super(UserLoginView, self).dispatch(*args, **kwargs) + + class UsersTrainingView(UsersView): def get_queryset(self): -- 2.39.5