Exemple #1
0
def GateToProto(gate, full=False):
  ret = AttrDict()
  ret.id = str(gate.seqn)
  ret.name = gate.name
  if gate.description:
    ret.description = gate.description
  return ret
Exemple #2
0
def EntryToProto(entry, full=False):
  ret = AttrDict()
  ret.id = entry.seqn
  ret.pour_time = entry.starttime
  if entry.duration is not None:
    ret.duration = entry.duration
  ret.status = entry.status
  ret.is_valid = (entry.status == 'valid')
  if entry.user:
    ret.user_id = entry.user.username
  else:
    ret.user_id = None
  if entry.auth_token:
    ret.auth_token = entry.auth_token
  return ret
Exemple #3
0
def SystemEventToProto(record, full=False):
  ret = AttrDict()
  ret.id = record.seqn
  ret.kind = record.kind
  ret.time = record.when
  if record.entry:
    ret.entry = record.entry.seqn
  if record.user:
    ret.user = record.user.username
  return ret
Exemple #4
0
def UserToProto(user, full=False):
  ret = AttrDict()
  ret.username = user.username
  ret.mugshot_url = user.get_profile().MugshotUrl()
  ret.is_active = user.is_active
  if full:
    ret.first_name = user.first_name
    ret.last_name = user.last_name
    ret.email = user.email
    ret.password = user.password
    ret.is_staff = user.is_staff
    ret.is_active = user.is_active
    ret.is_superuser = user.is_superuser
    ret.last_login = user.last_login
    ret.date_joined = user.date_joined
  return ret
Exemple #5
0
def AuthTokenToProto(record, full=False):
  ret = AttrDict()
  ret.id = record.seqn
  ret.auth_device = record.auth_device
  ret.token_value = record.token_value
  if record.user:
    ret.username = str(record.user.username)
  else:
    ret.username = None
  ret.nice_name = record.nice_name
  if full:
    ret.enabled = record.enabled
    ret.created_time = record.created
    if record.expires:
      ret.expire_time = record.expires
    if record.pin:
      ret.pin = record.pin
  return ret
Exemple #6
0
def UserProfileToProto(record, full=False):
  ret = AttrDict()
  ret.username = record.user.username
  ret.gender = record.gender
  ret.weight = record.weight
  return ret