def reset_password(self, password): """Set `password` for creator user and delete itself.""" user = get_sheet_field(self, IMetadata, 'creator') password_sheet = get_sheet( user, adhocracy_core.sheets.principal.IPasswordAuthentication) password_sheet.set({'password': password}, send_event=False) if not user.active: # pragma: no cover user.activate() del self.__parent__[self.__name__] statsd_incr('pwordresets.reset', 1)
def activate(self, active: bool = True): """ Activate or deactivate the user. Inactivate users are always hidden. """ self.active = active sheet = get_sheet(self, IMetadata) appstruct = sheet.get() appstruct['hidden'] = not active statsd_incr('users.activated', 1) sheet.set(appstruct)
def activate(self, active: bool=True): """ Activate or deactivate the user. Inactivate users are always hidden. """ self.active = active sheet = get_sheet(self, IMetadata) appstruct = sheet.get() appstruct['hidden'] = not active statsd_incr('users.activated', 1) sheet.set(appstruct)
def incr_event_metric(name: str, rate: float, event: object): """Increment statsd metric `name`. :param `name`: the metric name send to the stats server :param `rate`: sample rate (>=0 and <= 1) to reduce the number of values :param `event`: object with optional `registry` attribute to retrieve the pyramid registry. """ registry = getattr(event, 'registry', None) if registry is None: registry = get_current_registry() statsd_incr(name, value=1, rate=rate, registry=registry)