Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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)