예제 #1
0
파일: projects.py 프로젝트: shuhaowu/spm
def get_member_emails(project_key):
  project = Project.get(project_key)
  participants = project.indexes("participants_bin", [])
  owners = project.indexes("owners_bin", [])
  unregistered = project.indexes("unregistered_bin", [])
  participants_email = []
  owners_email = []
  unregistered_emails = []
  for owner_key in owners:
    try:
      owners_email.append(list(User.get(owner_key).index("email_bin", []))[0])
    except NotFoundError:
      raise Exception("User '%s' does not exist!" % owner_key)

  for participants_key in participants:
    try:
      participants_email.append(list(User.get(participants_key).index("email_bin", []))[0])
    except NotFoundError:
      raise Exception("User '%s' does not exist!" % participants_key)

  for u in unregistered:
    temp = u.split(" ")
    unregistered_emails.append([temp[0], temp[1][:-1]])

  return {"participants_email" : participants_email, "owners_email" : owners_email, "unregistered_emails" : unregistered_emails}
예제 #2
0
파일: projects.py 프로젝트: shuhaowu/spm
def get_members_list(project_key):
  project = Project.get(project_key)
  members = list(project.index("owners_bin", [])) + list(project.index("participants_bin", []))
  members_list = []
  for member in members:
    u = User.get(member)
    members_list.append({"key" : u.key, "name" : u.name if u.name else list(u.index("email_bin"))[0]})
  return members_list
예제 #3
0
파일: projects.py 프로젝트: shuhaowu/spm
def get_project_json(key):
  project = Project.get(key)
  project_json = {
    "key": project.key,
    "name": project.name,
    "desc": project.desc,
    "owners": list(project.index("owners_bin", [])),
    "participants": list(project.index("participants_bin", [])),
  }
  return project_json
예제 #4
0
파일: projects.py 프로젝트: shuhaowu/spm
def set_owners(project_key, emails):
  project = Project.get(project_key)
  project.removeIndex("owners_bin")
  for email in emails:
    user_queries = User.indexLookup("email_bin", email)
    if len(user_queries) == 0:
      add_unregistered_to_project(project, email, "owners")
    else:
      project.addIndex("owners_bin", user_queries.all()[0].key)

  project.save()
  return True
예제 #5
0
파일: projects.py 프로젝트: shuhaowu/spm
def set_participants(project_key, emails):
  project = Project.get(project_key)
  project.removeIndex("participants_bin", silent=True)
  if len(emails) == 1 and emails[0] == "":
    project.save()
    return True

  for email in emails:
    user_queries = User.indexLookup("email_bin", email)
    if len(user_queries) == 0:
      add_unregistered_to_project(project, email, "participants")
    else:
      project.addIndex("participants_bin", user_queries.all()[0].key)

  project.save()
  return True
예제 #6
0
파일: projects.py 프로젝트: shuhaowu/spm
def get_project_json_simple(key):
  project = Project.get(key)
  return {"key" : project.key, "name" : project.name}