Add user info panel 87/20887/1
authormaxbr <maxbr@mi.fu-berlin.de>
Mon, 12 Sep 2016 09:19:18 +0000 (11:19 +0200)
committermaxbr <maxbr@mi.fu-berlin.de>
Mon, 12 Sep 2016 09:19:18 +0000 (11:19 +0200)
JIRA: PHAROS-264

Change-Id: I5404812a78755ce1026401b8dda1f0d167dc6fda
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
tools/pharos-dashboard/account/urls.py
tools/pharos-dashboard/account/views.py
tools/pharos-dashboard/pharos_dashboard/urls.py
tools/pharos-dashboard/templates/account/user_list.html [new file with mode: 0644]
tools/pharos-dashboard/templates/base.html

index b837814..7289da6 100644 (file)
@@ -21,5 +21,6 @@ urlpatterns = [
     url(r'^settings/', AccountSettingsView.as_view(), name='settings'),
     url(r'^authenticated/$', JiraAuthenticatedView.as_view(), name='authenticated'),
     url(r'^login/$', JiraLoginView.as_view(), name='login'),
-    url(r'^logout/$', JiraLogoutView.as_view(), name='logout')
+    url(r'^logout/$', JiraLogoutView.as_view(), name='logout'),
+    url(r'^users/$', UserListView.as_view(), name='users'),
 ]
index 7d2c9bd..fd1762e 100644 (file)
@@ -10,13 +10,14 @@ from django.contrib.auth.models import User
 from django.urls import reverse
 from django.utils.decorators import method_decorator
 from django.views.generic import RedirectView
+from django.views.generic import TemplateView
 from django.views.generic import UpdateView
 from jira import JIRA
 
 from account.forms import AccountSettingsForm
 from account.jira_util import SignatureMethod_RSA_SHA1
 from account.models import UserProfile
-from pharos_dashboard import settings
+from django.conf import settings
 
 consumer = oauth.Consumer(settings.OAUTH_CONSUMER_KEY, settings.OAUTH_CONSUMER_SECRET)
 
@@ -50,7 +51,8 @@ class JiraLoginView(RedirectView):
         self.request.session['request_token'] = dict(urllib.parse.parse_qsl(content.decode()))
         # Step 3. Redirect the user to the authentication URL.
         url = settings.OAUTH_AUTHORIZE_URL + '?oauth_token=' + \
-              self.request.session['request_token']['oauth_token']
+                self.request.session['request_token']['oauth_token'] + \
+              '&oauth_callback=' + settings.OAUTH_CALLBACK_URL
         return url
 
 
@@ -109,3 +111,12 @@ class JiraAuthenticatedView(RedirectView):
         login(self.request, user)
         # redirect user to settings page to complete profile
         return url
+
+class UserListView(TemplateView):
+    template_name = "account/user_list.html"
+
+    def get_context_data(self, **kwargs):
+        users = User.objects.all()
+        context = super(UserListView, self).get_context_data(**kwargs)
+        context.update({'title': "Dashboard Users", 'users': users})
+        return context
index 26ab367..d8bf560 100644 (file)
@@ -13,13 +13,18 @@ Including another URLconf
     1. Import the include() function: from django.conf.urls import url, include
     2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
 """
+from django.conf import settings
 from django.conf.urls import url, include
+from django.conf.urls.static import static
 from django.contrib import admin
 
 urlpatterns = [
     url(r'^', include('dashboard.urls', namespace='dashboard')),
     url(r'^booking/', include('booking.urls', namespace='booking')),
-    url(r'^account/', include('account.urls', namespace='account')),
+    url(r'^accounts/', include('account.urls', namespace='account')),
 
     url(r'^admin/', admin.site.urls),
-]
\ No newline at end of file
+]
+
+if settings.DEBUG is True:
+    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
diff --git a/tools/pharos-dashboard/templates/account/user_list.html b/tools/pharos-dashboard/templates/account/user_list.html
new file mode 100644 (file)
index 0000000..7618dc9
--- /dev/null
@@ -0,0 +1,42 @@
+{% extends "dashboard/table.html" %}
+{% load staticfiles %}
+
+{% block table %}
+    <thead>
+    <tr>
+        <th>Username</th>
+        <th>Company</th>
+        <th>SSH Key</th>
+        <th>GPG Key</th>
+    </tr>
+    </thead>
+    <tbody>
+    {% for user in users %}
+        <tr>
+            <th>
+                {{ user.username }}
+            </th>
+            <th>
+                {{ user.userprofile.company }}
+            </th>
+            <th>
+                <a href={{ user.userprofile.ssh_public_key.url }}>Download</a>
+            </th>
+            <th>
+                <a href={{ user.userprofile.pgp_public_key.url }}>Download</a>
+            </th>
+        </tr>
+    {% endfor %}
+    </tbody>
+{% endblock table %}
+
+
+{% block tablejs %}
+    <script type="text/javascript">
+        $(document).ready(function () {
+            $('#table').DataTable({
+                "order": [[0, "asc"]]
+            });
+        });
+    </script>
+{% endblock tablejs %}
\ No newline at end of file
index 64174a1..42156e3 100644 (file)
                                     class="fa fa-fw"></i>Resources
                             </a>
                         </li>
+                        <li>
+                            <a href="{% url 'account:users' %}"><i
+                                    class="fa fa-fw"></i>Users
+                            </a>
+                        </li>
                     </ul>
                 </div>
                 <!-- /.sidebar-collapse -->