Added login access time update
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 7 Aug 2010 14:00:39 +0000 (14:00 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sat, 7 Aug 2010 14:00:39 +0000 (14:00 +0000)
bin/djais/models.py
bin/djais/views.py
html_templates/fleet.html

index e88b1268a4d77f4ba7042636c3c2fa256d458294..813e6b5319fd7973f51b36d916ec7693f8b112bf 100644 (file)
@@ -1,4 +1,6 @@
 # -*- coding: utf-8 -*-
+
+from datetime import datetime
 from django.db import models
 from django.contrib.auth.models import get_hexdigest
 
@@ -26,6 +28,7 @@ class User(models.Model):
     father = models.ForeignKey('User')
     creation_datetime = models.DateTimeField(auto_now_add=True)
     phone = models.CharField(max_length=20, blank=True)
+    access_datetime = models.DateTimeField(blank=True, null=True)
     class Meta:
         db_table = u'user'
         ordering = ('id',)
@@ -45,6 +48,11 @@ class User(models.Model):
         algo, salt, hsh = self.password_hash.split('$')
         return hsh == get_hexdigest(algo, salt, raw_password)
 
+
+    def update_access_datetime(self):
+        self.access_datetime = datetime.utcnow()
+        self.save()
+
     def get_and_delete_messages(self):
         return None
 
index 90f8b3c89e6e0de38ffc1af03aba15297274a3cb..f1b5cd45157a26e912362bd66f9941b5fdc0aa18 100644 (file)
@@ -34,6 +34,7 @@ def auth(username, raw_password):
     if not user.check_password(raw_password):
         return None
     # TODO: update access_datetime
+    user.update_access_datetime()
     return user
 
 
@@ -59,8 +60,8 @@ class VesselSearchForm(forms.Form):
     name = forms.CharField(max_length=20, required=False)
     imo = forms.IntegerField(required=False)
     callsign = forms.CharField(max_length=7, required=False)
-    destination = forms.CharField(max_length=20, required=False)
     flag = forms.ChoiceField(choices=country_choices(), required=False)
+    destination = forms.CharField(max_length=20, required=False)
 
 
     def clean(self):
index 6b5a87a832dc0ba047813994b09665260e91d40e..5f4779c3a686826a44699ac597d075bfcb48e344 100644 (file)
@@ -8,7 +8,7 @@
 {% block content %}
 <h3>Details of fleet {{ fleet.name }}</h3>
 {{ fleet.description }}<br><br>
-<a href=lastpos class=button>Last positions</a><br>
+<a href=lastpos class=button>Last positions in Google Earth</a><br>
 <a href=list class=button>Vessel list</a> ({{ fleet.vessel_count }} vessels)<br>
 <a href=users class=button>User list</a> ({{ fleet.user_count }} users)<br>
 {% endblock %}