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
""" 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):
""" 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 # ==============================================================================