Ejemplo n.º 1
0
def getAppAndCommunity(message, user):
    if message.team_key:
        community = Community.getCommunityFromTeamKey(team_key=message.team_key)
        appinfo = getAppInfo(community.key.id())

    elif message.app_name:
        appinfo = AppInfo.get(name=message.app_name, platform=message.platform_type)
        community = None

        if appinfo is None:
            appInfoMessage = AppInfoMessage(name=message.app_name, version=message.app_version,
                                            platform=message.platform_type)
            appinfo = AppInfo.insert(appInfoMessage)
        else:
            app_community = getCommunityForApp(id=appinfo.key.id())
            if app_community and isMember(app_community, user):
                community = app_community

    elif message.community_name:
        community_id = Community.getCommunity(community_name=message.community_name).id
        community = Community.get_by_id(community_id)
        appinfo = getAppInfo(community_id)

    else:
        raise endpoints.BadRequestException("Please specify a community or app")

    return appinfo, community
Ejemplo n.º 2
0
 def community_get(self, request):
     return Community.getCommunity(community_id=request.id)