Last login patch for Trac UserManager plugin

I just have added a visit motivation feature to the Trac Usermanager plugin. With the included patch set you will get an additional column Last Login in the “UserProfilesList” macro.

This patch applies to UserManager plugin rev 5520  🙂

--- macros.py	(revision 300)
+++ macros.py	(revision 301)
@@ -10,6 +10,8 @@
 from trac.wiki.macros import WikiMacroBase
 from trac.wiki.formatter import wiki_to_html
 from trac.web.chrome import Chrome, add_stylesheet, add_script
-from trac.util.datefmt import format_datetime
+from trac.util.datefmt import format_datetime, to_datetime
+from datetime import datetime

 from tracusermanager.api import UserManager, User
 from tracusermanager.profile.api import UserProfileManager, IUserProfilesListMacroCellContributor
@@ -72,9 +73,29 @@
             data['user_profiles'] = UserManager(self.env).search_users(user_profile_templates)
         else:
             data['user_profiles'] = UserManager(self.env).get_active_users()
-
+
+        db = self.env.get_db_cnx()
+        cursor = db.cursor()
+        cursor.execute("SELECT sid,last_visit FROM session WHERE authenticated=1")
+        last_visits={}
+        for username, last_visit in cursor:
+          for user in  data['user_profiles']:
+              date_diff = datetime.now().date()  - datetime.date(to_datetime(last_visit))
+              if date_diff.days > 1:
+                user['last_visit'] = "%d days ago" % date_diff.days
+              elif date_diff.days == 1:
+                  user['last_visit'] = "%d day ago" % date_diff.days
+              else:
+                  user['last_visit'] = "today"
+
+              #user['last_visit'] = format_datetime(last_visit,"%b %d.%m.%Y %H:%M:%S")
+
+
         data['cells']=list(self._get_cells(data['user_profiles']))
-
+
         # add stylesheet&script
         add_stylesheet(formatter.req,'tracusermanager/css/macros_um_profile.css')
         add_script(formatter.req,'tracusermanager/js/macros_um_profile.js')
@@ -102,8 +113,9 @@
         yield ('name', _('Name'),0)
         yield ('email', _('Email'),1)
         yield ('role', _('Role'),2)
+        yield ('last_visit', _('Last login'),3)
     def render_userlistmacro_cell(self, cell_name, user):
-        """Should render user cell"""
+        """Should render user cell"""
         return user[cell_name]

 class TeamRosterMacro(UserProfilesListMacro):

have fun

How to solve Android adb device not found errors

To get your newly build Apps down to your device you have to use the ADB (Android Debug Bridge). The common way to  make your device ready for playing is to download the USB driver package which is included in the SDK Manager.

But these drivers are only for a couple of common mobile devices, so what if you have an ARCHOS 8 like me…. you still getting stuck with a nice…. device not found ….

The first part is easy, Archos in my case, offers his own usb drivers .

After downloading the USB driver I got a shiny “Archos 7 ADB” item under “Android Phone” in my windows device manager. But what the hell,…. after restarting the ADB daemon,…. “ADB devices” was only showing annoying … device not found….   mannnn.

Hmm, google is your best friend :-)…… The solution is that the ADB daemon needs also your USB device vendor ID (VID)

If you cannot get it from your device vendor you may look under device manager -> device details -> hardware ID -> USB\VID_xxxx.

The VID for the adb should be placed in a file under {user home}/.android/adb_usb.ini.

Insert the VID in HEX notation {0x0e79}

If this file does not exist, just create it!

have fun

World of Quadrocopters

A brave student have just sent a few amazing Videos about some very interesting projects using Quadrocopter-Technology.

ETH Zurich, Institute of dynamic systems and control

Flying Machine Arena – Overview 2010

[youtube JDj5jtDUD8k]

Quadrotor Ball Juggling

[youtube g8O5RBcwmjY]

GRASP Lab, University of Pennsylvania

[youtube YBsJwapanWI]

TARMAC Project in the Hybrid Systems Lab at UC Berkeley (EECS department)

Autonomous Flight and Obstacle Avoidance with Kinect Sensor

[youtube eWmVrfjDCyw]

iPhone Apps III or ….hurray its a …. StudentsLife app

 

Let me introduce you our first iPhone app. called StudentsLife (v1.0.0) 🙂

StudentsLife is the must have iPhone Gadged for all Students of the FH-Kärnten.  … just try it out.

Our first release can be tested at the fair BeSt in Klagenfurt.

Get it at the App-Store

…. to cut to the chase …..

The Feature set :

  • your personal timetable
  • detailed course overview
  • news ticker
  • university contact list
  • course overview
  • location based service
    • amenities
    • current party locations
    • study locations
    • locations every student should know of 🙂
  • personal list of grades

But take a look for yourself….

 

And … Daniel big thx for your hard work!!!! 🙂

By the way, we are also working on an Android version…. so stay tuned…