templates_people_modules_DATA = \
src/templates/people/modules/accounts-list.html \
+ src/templates/people/modules/accounts-new.html \
src/templates/people/modules/cdr.html \
src/templates/people/modules/channels.html \
src/templates/people/modules/mos.html \
logging.info("Successfully authenticated as %s" % self.ldap.whoami_s())
def _query(self, query, attrlist=None, limit=0, search_base=None):
- logging.debug("Performing LDAP query: %s" % query)
+ logging.debug("Performing LDAP query (%s): %s" \
+ % (search_base or self.search_base, query))
t = time.time()
"""
Fetches all attributes for the given distinguished name
"""
- results = self._query("(objectClass=*)", search_base=dn, limit=1)
+ results = self._query("(objectClass=*)", search_base=dn, limit=1,
+ attrlist=("*", "createTimestamp", "modifyTimestamp"))
for dn, attrs in results:
return attrs
return Account(self.backend, dn, attrs)
+ def get_created_after(self, ts):
+ t = ts.strftime("%Y%m%d%H%M%SZ")
+
+ return self._search("(&(objectClass=person)(createTimestamp>=%s))" % t)
+
def search(self, query):
# Search for exact matches
accounts = self._search(
for value in self._get_strings(key):
yield phonenumbers.parse(value, None)
+ def _get_timestamp(self, key):
+ value = self._get_string(key)
+
+ # Parse the timestamp value and returns a datetime object
+ return datetime.datetime.strptime(value, "%Y%m%d%H%M%SZ")
+
def _modify(self, modlist):
logging.debug("Modifying %s: %s" % (self.dn, modlist))
return groups
+ # Created/Modified at
+
+ @property
+ def created_at(self):
+ return self._get_timestamp("createTimestamp")
+
+ @property
+ def modified_at(self):
+ return self._get_timestamp("modifyTimestamp")
+
# Address
@property
"CDR" : people.CDRModule,
"Channels" : people.ChannelsModule,
"MOS" : people.MOSModule,
+ "NewAccounts" : people.NewAccountsModule,
"Password" : people.PasswordModule,
"Registrations" : people.RegistrationsModule,
"SIPStatus" : people.SIPStatusModule,
self.redirect("/users/%s" % account.uid)
+class NewAccountsModule(ui_modules.UIModule):
+ def render(self, days=14):
+ t = datetime.datetime.utcnow() - datetime.timedelta(days=days)
+
+ # Fetch all accounts created after t
+ accounts = self.backend.accounts.get_created_after(t)
+
+ accounts.sort(key=lambda a: a.created_at, reverse=True)
+
+ return self.render_string("people/modules/accounts-new.html",
+ accounts=accounts, t=t)
+
+
class AccountsListModule(ui_modules.UIModule):
def render(self, accounts=None):
if accounts is None: