allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [04/27] git commit: [#7657] ticket:649 Display basic user info
Date Mon, 29 Sep 2014 16:17:35 GMT
[#7657] ticket:649 Display basic user info


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/f54be441
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/f54be441
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/f54be441

Branch: refs/heads/db/7657
Commit: f54be4410cfd44723bd1550673549c8ac36f705b
Parents: da05789
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Sep 12 11:36:29 2014 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Sep 26 16:39:43 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py         | 15 ++++
 Allura/allura/model/auth.py                     |  5 ++
 .../templates/site_admin_user_details.html      | 75 ++++++++++++++++++++
 3 files changed, 95 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f54be441/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 8c56f9f..b61db8b 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -62,6 +62,7 @@ class SiteAdminController(object):
     def __init__(self):
         self.task_manager = TaskManagerController()
         c.site_admin_sidebar_menu = self.sidebar_menu()
+        self.user = AdminUserDetailsController()
 
     def _check_security(self):
         with h.push_context(config.get('site_admin_project', 'allura'),
@@ -501,6 +502,20 @@ class StatsController(object):
         return dict(neighborhoods=neighborhoods)
 
 
+class AdminUserDetailsController(object):
+
+    @expose('jinja:allura:templates/site_admin_user_details.html')
+    def _default(self, username):
+        user = M.User.by_username(username)
+        if not user:
+            raise HTTPNotFound()
+        projects = user.my_projects().all()
+        return {
+            'user': user,
+            'projects': projects,
+        }
+
+
 class StatsSiteAdminExtension(SiteAdminExtension):
     controllers = {'stats': StatsController}
 

http://git-wip-us.apache.org/repos/asf/allura/blob/f54be441/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 4460636..d110412 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -22,6 +22,7 @@ import logging
 import urllib
 import hmac
 import hashlib
+import calendar
 from urlparse import urlparse
 from email import header
 from hashlib import sha256
@@ -731,6 +732,10 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             url=h.absurl(self.url()),
         )
 
+    def registration_date(self):
+        p = plugin.AuthenticationProvider.get(request)
+        return p.user_registration_date(self)
+
 
 class OldProjectRole(MappedClass):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/f54be441/Allura/allura/templates/site_admin_user_details.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_user_details.html b/Allura/allura/templates/site_admin_user_details.html
new file mode 100644
index 0000000..9aba434
--- /dev/null
+++ b/Allura/allura/templates/site_admin_user_details.html
@@ -0,0 +1,75 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+{% set page = 'user_details' %}
+{% extends 'allura:templates/site_admin.html' %}
+{% set hide_left_bar=True %}
+
+{% block title %}User Details{% endblock %}
+{% block header %}User Details{% endblock %}
+
+{% block content %}
+  {% block general_info %}
+    <div class="grid-23">
+      <fieldset>
+        <legend>General</legend>
+        <ul>
+          <li>Username: {{ user.username }}</li>
+          <li>Full name: {{ user.get_pref('display_name') }}</li>
+          <li>Registered: {{ user.registration_date() }}</li>
+        </ul>
+      </fieldset>
+    </div>
+  {% endblock general_info %}
+
+  {% block session_info %}
+    <div class="grid-23">
+      <fieldset>
+        <legend>Session</legend>
+        <h3>Last login</h3>
+        <ul>
+          <li>Date: {{ user.last_access.login_date }}</li>
+          <li>IP: {{ user.last_access.login_ip }}</li>
+          <li>UA: {{ user.last_access.login_ua }}</li>
+        </ul>
+        <h3>Last page access</h3>
+        <ul>
+          <li>Date: {{ user.last_access.session_date }}</li>
+          <li>IP: {{ user.last_access.session_ip }}</li>
+          <li>UA: {{ user.last_access.session_ua }}</li>
+        </ul>
+      </fieldset>
+    </div>
+  {% endblock session_info %}
+
+  {% block extra_info %}
+  {% endblock extra_info %}
+
+  {% block user_projects %}
+    <div class="grid-23">
+      <fieldset>
+        <legend>Projects</legend>
+        <ul>
+          {% for p in projects %}
+            <li><a href="{{ p.url() }}">{{p.name}}</a></li>
+          {% endfor %}
+        </ul>
+      </fieldset>
+    </div>
+  {% endblock user_projects %}
+{% endblock %}


Mime
View raw message