def getCommunityApps(community_id=None, team_key=None, app_count=None): if community_id: community = Community.get_by_id(community_id) elif team_key: community = Community.query(Community.team_key == team_key).get() return community.apps[0:app_count] if app_count else community.apps
def create_community_circle(): communities = Community.query().filter(Community.team_key != None).fetch() for community in communities: community.circles = { CircleValue.CONTRIBUTOR : CircleType.CONTRIBUTOR, CircleValue.BETA_TESTER : CircleType.BETA_TESTER, CircleValue.ALPHA_TESTER : CircleType.ALPHA_TESTER, CircleValue.DEVELOPER : CircleType.DEVELOPER } community.plan = PlanType.BASIC community.put()
def list_community(self, request): community_value_list = [] if request.team_hash == "us3rs0urc3": community_list = Community.query().filter(Community.team_key != None).fetch() for community in community_list: community_value_list.append(CommunityValueMessage(name=community.name, key=community.team_key, secret=community.team_secret)) return CommunityValueListMessage(teams=community_value_list)
def add_teamhash(cursor=None): community_list, cursor, more = Community.query().fetch_page(BATCH_SIZE, start_cursor=cursor) community_update_list = [] for community in community_list: if (not community.team_hash) and community.team_key: community.team_hash = md5(community.team_key)[-8:] community_update_list.append(community) if len(community_update_list): ndb.put_multi(community_update_list) if more: add_teamhash(cursor=cursor)
def getCommunityForApp(id=None, app_name=None): if id: app = AppInfo.get_by_id(id) elif app_name: app = AppInfo.get(name=app_name) app_community = None if app: communities = Community.query().fetch() for community in communities: if app.key in community.apps: app_community = community break return app_community
def get_admin_master_data(self, request): communities_message = [] query = Community.query().filter(Community.team_secret != None) if request.team_key: query = query.filter(Community.team_key == request.team_key) communities = query.fetch() for community in communities: community_message = CommunityAdminMasterMessage() community_message.community_name = community.name community_message.team_key = community.team_key community_message.team_secret = community.team_secret community_message.team_hash = community.team_hash community_message.plan = community.plan app = community.apps[0].get() if app: community_message.app_name = app.name community_message.app_icon = app.icon_url community_message.users = [] if request.get_user_list: for userrole in UserRole.community_user_list(community_key=community.key): user = userrole.user.get() if user and (user.account_type == community.team_key): if user.user_email.split("@")[1] == "devnull.usersource.io": break user_message = UserAdminMasterMessage() user_message.display_name = user.display_name user_message.user_email = user.user_email user_message.password_present = True if user.password else False user_message.role = userrole.role user_message.image_url = user.image_url if community.circles: user_message.circle = community.circles.get(str(userrole.circle_level)) community_message.users.append(user_message) communities_message.append(community_message) return CommunityAdminMasterListMessage(communities=communities_message)