Commit d5fd872e authored by Baptiste Jonglez's avatar Baptiste Jonglez
Browse files

Fix example of static counters for member count and subscriber count

parent 54186cad
......@@ -36,6 +36,17 @@ class ISPInfo(SingleInstanceMixin, models.Model):
The naming convention is different from Python/django so that it
matches exactly the format (which uses CamelCase...)
"""
# These two properties can be overriden with static counters, see below.
@property
def memberCount(self):
"""Number of members"""
return count_active_members()
@property
def subscriberCount(self):
"""Number of subscribers to an internet access"""
return count_active_subscriptions()
name = models.CharField(max_length=512,
help_text="The ISP's name")
# Length required by the spec
......@@ -70,10 +81,14 @@ class ISPInfo(SingleInstanceMixin, models.Model):
longitude = models.FloatField(blank=True, null=True,
help_text="Coordinates of the registered office (longitude)")
# Uncomment this if you want to manage these counters by hand.
#member_count = models.PositiveIntegerField(help_text="Number of members")
#subscriber_count = models.PositiveIntegerField(
# help_text="Number of subscribers to an internet access")
# Uncomment this (and handle the necessary migrations) if you want to
# manage one of the counters by hand. Otherwise, they are computed
# automatically, which is probably what you want.
#memberCount = models.PositiveIntegerField(help_text="Number of members",
# default=0)
#subscriberCount = models.PositiveIntegerField(
# help_text="Number of subscribers to an internet access",
# default=0)
# field outside of db-ffdn format:
administrative_email = models.EmailField(
......@@ -88,16 +103,6 @@ class ISPInfo(SingleInstanceMixin, models.Model):
verbose_name="serveur de listes", blank=True,
help_text="URL du serveur de listes de discussions/diffusion")
@property
def memberCount(self):
"""Number of members"""
return count_active_members()
@property
def subscriberCount(self):
"""Number of subscribers to an internet access"""
return count_active_subscriptions()
@property
def version(self):
"""Version of the API"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment