Display how many fleets a user has access to.
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Mon, 21 Feb 2011 10:20:42 +0000 (10:20 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Mon, 21 Feb 2011 10:20:42 +0000 (10:20 +0000)
bin/djais/models.py
html_templates/user_detail.html

index b26c1947d5cd554b69065dfc29995bd00fe7673d..115d402555c6d0831dc65297b479ffd2e5cf8ea4 100644 (file)
@@ -96,6 +96,9 @@ class User(models.Model):
             if source_user:
                 source_user.info("%s was granted access to 'sandbox' fleet" % self.login)
 
+    def fleets_count(self):
+        return FleetUser.objects.filter(user=self.id).count()
+
 
 class Vessel(models.Model):
     mmsi = models.IntegerField(primary_key=True)
index cb35d562cf78d1c7397bbf66abe6a8f8d489fb4f..f99b74d0c45b8bad1cac9b5f4506492d2e0a14ed 100644 (file)
@@ -29,6 +29,10 @@ Last access
 {% endif %}
 <br>
 <br>
+{% with auser.fleets_count as nfleets %}
+Has access to {{ nfleets }} fleet{{ nfleets|pluralize }}.
+{% endwith %}<br>
+<br>
 
 {% if auser.admin_ok %}
 Account administration:<br>