Ejemplo n.º 1
0
def sanitizeShift(shift):
    """
    Sanitize a shift. Will also sanitize the shift summary.
    Reads the space attrs out of the data or defaults to
    just sanitizing the summary.
    """
    from server.models import core
    master = core.connect()
    attrs = master[shift["space"]["name"]]
    filters = attrs.get("sanitize") or []
    filters.append("summary")
    for k in filters:
        utils.sanitize(shift, k)
    return shift
Ejemplo n.º 2
0
    """
    Sanitize a shift. Will also sanitize the shift summary.
    Reads the space attrs out of the data or defaults to
    just sanitizing the summary.
    """
    from server.models import core
    master = core.connect()
    try:
        attrs = master[shift["space"]["name"]]
    except Exception, err:
        # space not in db
        return shift
    filters = attrs.get("sanitize") or []
    filters.append("summary")
    for k in filters:
        utils.sanitize(shift, k)
    return shift


@simple_decorator
def shift_join(func):
    def afn(*args, **kwargs):
        return Shift.joinData(func(*args, **kwargs), userId=kwargs.get("userId"))
    return afn

# ==============================================================================
# Shift Model
# ==============================================================================

class Shift(SSDocument):
Ejemplo n.º 3
0
    """
    Sanitize a shift. Will also sanitize the shift summary.
    Reads the space attrs out of the data or defaults to
    just sanitizing the summary.
    """
    from server.models import core
    master = core.connect()
    try:
        attrs = master[shift["space"]["name"]]
    except Exception, err:
        # space not in db
        return shift
    filters = attrs.get("sanitize") or []
    filters.append("summary")
    for k in filters:
        utils.sanitize(shift, k)
    return shift


@simple_decorator
def shift_join(func):
    def afn(*args, **kwargs):
        return Shift.joinData(func(*args, **kwargs),
                              userId=kwargs.get("userId"))

    return afn


# ==============================================================================
# Shift Model
# ==============================================================================