예제 #1
0
def AsyncDelCommentPush(topicId, senderId, communityId, commentId,
                        commentCount):
    config = readIni()
    tagSuffix = config.get('topic', "tagSuffix")
    pushContent = str(topicId).encode('utf-8') + ":" \
                 +str(senderId).encode('utf-8') + ":" \
                 +str(communityId).encode('utf-8') + ":" \
                 +str(commentId).encode('utf-8') + ":" \
                 +str(commentCount).encode('utf-8')

    tagSuffix = config.get('topic', "tagSuffix")
    tagNormalName = tagSuffix + str(communityId)
    tagSuffix = config.get('report', "tagSuffix")
    tagAdminName = tagSuffix + str(communityId)
    tagSuffix = config.get('property', "tagSuffix")
    tagPropertyName = tagSuffix + str(communityId)

    apiKey = config.get("SDK", "apiKey")
    secretKey = config.get("SDK", "secretKey")
    _jpush = jpush.JPush(apiKey, secretKey)
    push = _jpush.create_push()
    push.audience = jpush.all_
    push.audience = jpush.audience(
        jpush.tag(tagNormalName, tagAdminName, tagPropertyName), )
    push.message = jpush.message(pushContent, u"push_del_comm", None, None)
    push.options = {
        "time_to_live": 0,
        "sendno": 9527,
        "apns_production": PUSH_STATUS
    }
    push.platform = jpush.all_
    push.send()
예제 #2
0
def setWelcomeTopic(family_city, family_city_id, family_community,
                    family_community_id, user_family_address, user_family_id,
                    user_nick, user_id):
    data = {}
    config = readIni()
    title = config.get(
        'topic', "topic_title1") + user_nick.encode('utf-8') + config.get(
            'topic', "topic_title2")
    topic_content = config.get('topic', "topic_content")
    topic_content_0 = config.get('topic', "topic_content_0")
    topic_content_1 = config.get('topic', "topic_content_1")
    topic_content_2 = config.get('topic', "topic_content_2")
    topic_content = topic_content + '\n' + topic_content_0 + '\n' + topic_content_1 + '\n' + topic_content_2
    topic_time = long(time.time() * 1000)
    forum_name = config.get('topic', "forum_name")
    sender_id = config.get('topic', "sender_id")
    sender_name = config.get('topic', "sender_name")
    userAvatar = settings.RES_URL + 'res/default/avatars/default-avatar.png'
    sender_portrait = userAvatar
    sender_family_id = config.get('topic', "sender_family_id")
    sender_family_address = user_family_address
    display_name = config.get(
        'topic', "sender_name") + "@" + family_community.encode('utf-8')
    sender_city_id = family_city_id
    sender_community_id = family_community_id
    topicObj  = Topic.objects.create(topic_title=title,topic_content=topic_content,topic_category_type=2,topic_time=topic_time,\
                                       forum_id=1, forum_name=forum_name, sender_id=sender_id,sender_name=sender_name, sender_portrait=sender_portrait,\
                                       sender_family_id=sender_family_id,sender_family_address=sender_family_address, display_name=display_name,\
                                       object_data_id=0,circle_type=1,send_status=0,sender_city_id=sender_city_id,sender_community_id=sender_community_id,\
                                       cache_key=user_id,collect_status=0)
    topicId = topicObj.getTopicId()

    AsyncSetWelcome.delay(topicId, sender_id, sender_community_id)
예제 #3
0
def AsyncForcedReturn():
    config = readIni()
    ListApkInfo = []
    from core.settings import NEW_VERSION_URL
    from web.models import APK
    QuerySet = APK.objects.filter().order_by('-v_id')[:1]
    apkObj = QuerySet[0]
    valCode  = apkObj.v_name
    valSize  = str(apkObj.v_size) + 'MB'
    valURL   = NEW_VERSION_URL
    valForce = apkObj.v_force
    function = apkObj.v_function
    bug      = apkObj.v_bug
    dicts = {}
    dicts.setdefault('fun',function)
    dicts.setdefault('bug',bug)
    ListApkInfo.append(dicts)
    response_data = {}
    response_data['flag']    = 'ok'
    response_data['vcode']   = valCode
    response_data['size']    = valSize
    response_data['url']     = valURL
    response_data['srv_url'] = 'none'
    response_data['force']   = valForce
    response_data['detail']  = ListApkInfo
    pushContent = response_data
    apiKey = config.get("SDK", "apiKey")
    secretKey = config.get("SDK", "secretKey")
    tagSuffixWithTopic = config.get('topic', "tagSuffix")
    tagSuffixWithReport = config.get('report', "tagSuffix")
    tagSuffixWithProperty = config.get('property', "tagSuffix")
    _jpush = jpush.JPush(apiKey,secretKey)
    from addrinfo.models import Community
    commQuerySet = Community.objects.all()
    for i in range(0,commQuerySet.count(),1):
        commId = commQuerySet[i].getCommunityId()
        tagNormalName = tagSuffixWithTopic + str(commId)
        tagAdminName = tagSuffixWithReport+str(commId)
        tagPropertyName = tagSuffixWithProperty+str(commId)
        push = _jpush.create_push()
        push.audience = jpush.all_
        push.audience = jpush.audience(
                    jpush.tag(tagNormalName,tagAdminName,tagPropertyName),
                )
        push.message = jpush.message(
                    pushContent,
                    u"push_force_return",
                    None,
                    None
                )
        push.options = {"time_to_live":0, "sendno":9527, "apns_production":PUSH_STATUS}
        push.platform = jpush.all_
        push.send() 
예제 #4
0
def AsyncDelBlackList(user_id,black_user_id):
    from users.models import User
    userObj = User.objects.get(user_id = long(user_id))
    try:
        from users.models import Remarks
        remObj = Remarks.objects.get(target_id=long(black_user_id),remuser_id=long(user_id))
        user_name = remObj.user_remarks
    except:
        user_name = userObj.user_nick
    user_type = userObj.user_type
    user_portrait = userObj.user_portrait
    user_public_status = userObj.user_public_status
    user_profession = userObj.user_profession
    user_signature = userObj.user_signature
    user_level = userObj.user_level
    user_phone_number = userObj.user_phone_number
    familyId = userObj.user_family_id
    try:
        from users.models import FamilyRecord
        frObj = FamilyRecord.objects.get(family_id=familyId)
        building_num = frObj.family_building_num
        aptnum = frObj.family_apt_num
    except:
        building_num = None
        aptnum = None
    from users.views import genNeighborDict
    userInfo = genNeighborDict(user_id,user_name,user_portrait,building_num,aptnum,familyId,user_type,\
                               user_phone_number,user_profession,user_signature,user_level,user_public_status)
    config = readIni()
    pushContent = userInfo
    alias = config.get("SDK", "youlin")
    apiKey = config.get("SDK", "apiKey")
    secretKey = config.get("SDK", "secretKey")
    currentAlias = alias + str(black_user_id)
    _jpush = jpush.JPush(apiKey,secretKey) 
    push = _jpush.create_push()
    push.audience = jpush.all_
    push.audience = jpush.audience(
        jpush.alias(currentAlias),
    )
    push.message = jpush.message(
                pushContent,
                u"push_del_black",
                None,
                None
            )
    push.options = {"time_to_live":3600, "sendno":9527, "apns_production":PUSH_STATUS}
    push.platform = jpush.all_
    push.send()
예제 #5
0
def AsyncAddBlackList(user_id,black_user_id):
    config = readIni()
    pushContent = str(user_id).encode('utf-8') + ":" \
                 +str(black_user_id).encode('utf-8')
    alias = config.get("SDK", "youlin")
    apiKey = config.get("SDK", "apiKey")
    secretKey = config.get("SDK", "secretKey")
    currentAlias = alias + str(black_user_id)
    _jpush = jpush.JPush(apiKey,secretKey) 
    push = _jpush.create_push()
    push.audience = jpush.all_
    push.audience = jpush.audience(
        jpush.alias(currentAlias),
    )
    push.message = jpush.message(
                pushContent,
                u"push_add_black",
                None,
                None
            )
    push.options = {"time_to_live":3600, "sendno":9527, "apns_production":PUSH_STATUS}
    push.platform = jpush.all_
    push.send()
예제 #6
0
def AsyncSetNotice(apiKey, secretKey, currentCommunityId, custom_content, tagSuffix,\
                   tagSuffix1, message, customTitle, topicId,user_id):
    #     import sys
    #     default_encoding = 'utf-8'
    #     if sys.getdefaultencoding() != default_encoding:
    #         reload(sys)
    #         sys.setdefaultencoding(default_encoding)
    try:
        config = readIni()
        apiKey = config.get("SDK", "apiKey")
        secretKey = config.get("SDK", "secretKey")
        tagSuffix = config.get('topic', "tagSuffix")
        tagNormalName = tagSuffix + str(currentCommunityId)
        tagSuffix = config.get('report', "tagSuffix")
        tagAdminName = tagSuffix + str(currentCommunityId)
        _jpush = jpush.JPush(apiKey, secretKey)
        pushExtra = {'pTitle': customTitle}
        pushExtra.update(custom_content)
        #    pushExtra = custom_content
        push = _jpush.create_push()
        push.audience = jpush.all_
        push.audience = jpush.audience(jpush.tag(tagNormalName,
                                                 tagAdminName), )
        push.notification = jpush.notification(
            ios=jpush.ios(alert=message.encode('utf-8'),
                          badge="+1",
                          extras=pushExtra),
            android=jpush.android(message, customTitle, None, pushExtra))
        push.options = {
            "time_to_live": 86400,
            "sendno": 9527,
            "apns_production": PUSH_STATUS
        }
        push.platform = jpush.all_
        push.send()
    except Exception, e:
        return str(e)
예제 #7
0
def AsyncUpdatePasswd(userId,imei):
    config = readIni()
    pushContent = imei
    alias = config.get("SDK", "youlin")
    apiKey = config.get("SDK", "apiKey")
    secretKey = config.get("SDK", "secretKey")
    currentAlias = alias + str(userId)
    _jpush = jpush.JPush(apiKey,secretKey) 

    
    push = _jpush.create_push()
    push.audience = jpush.all_
    push.audience = jpush.audience(
        jpush.alias(currentAlias),
    )
    push.message = jpush.message(
                pushContent,
                u"push_new_passwd",
                None,
                None
            )
    push.options = {"time_to_live":86400, "sendno":9527, "apns_production":PUSH_STATUS}
    push.platform = jpush.all_
    push.send()
예제 #8
0
@youlinapp.task
def AsyncAddTopic(topicId, user_id, curComId, currentCommunityId):
    blackList = ''
    try:
        blkListOtherQuerySet = BlackList.objects.filter(black_id=long(user_id))
        blkListSize = blkListOtherQuerySet.count()
        for i in range(0, blkListSize, 1):
            blackList = blackList + str(blkListOtherQuerySet[i].user_id) + '-'
        blkListOwnQuerySet = BlackList.objects.filter(user_id=long(user_id))
        blkListSize = blkListOwnQuerySet.count()
        for i in range(0, blkListSize, 1):
            blackList = blackList + str(blkListOwnQuerySet[i].black_id) + '-'
    except Exception, e:
        blackList = str(Exception) + "=====" + str(e)
    config = readIni()
    tagSuffix = config.get('topic', "tagSuffix")
    pushContent = str(topicId).encode('utf-8') + ":" \
                 +str(user_id).encode('utf-8') + ":" \
                 +str(curComId).encode('utf-8')

    tagSuffix = config.get('topic', "tagSuffix")
    tagNormalName = tagSuffix + str(currentCommunityId)
    tagSuffix = config.get('report', "tagSuffix")
    tagAdminName = tagSuffix + str(currentCommunityId)
    tagSuffix = config.get('property', "tagSuffix")
    tagPropertyName = tagSuffix + str(currentCommunityId)

    apiKey = config.get("SDK", "apiKey")
    secretKey = config.get("SDK", "secretKey")
    _jpush = jpush.JPush(apiKey, secretKey)
예제 #9
0
def PushCommunityWeather():
    import sys
    default_encoding = 'utf-8'
    if sys.getdefaultencoding() != default_encoding:
        reload(sys)
        sys.setdefaultencoding(default_encoding)
    from addrinfo.models import City, Community

    community_list = Community.objects.all()

    city_list = City.objects.all()

    for cityIndex in range(0, city_list.count(), 1):
        pass
        cityObj = city_list[cityIndex]
        commQuerySet = Community.objects.filter(city=cityObj)
        if commQuerySet.count() <= 0:
            pass
        else:
            response_data = {}
            argv_city_name = cityObj.city_name
            urlWea = "http://op.juhe.cn/onebox/weather/query?cityname="\
                     +argv_city_name+"&key=d9524c5e03f51388151c941d65166ec6"
            res = requests.get(urlWea).content
            jsonobj = json.loads(res)
            if long(jsonobj['error_code']) == 207301:
                response_data['flag'] = 'error'
                response_data['yl_msg'] = u'错误的查询城市名'
                return response_data
            elif long(jsonobj['error_code']) == 207302:
                response_data['flag'] = 'error'
                response_data['yl_msg'] = u'查询不到该城市的相关信息'
                return response_data
            elif long(jsonobj['error_code']) == 207303:
                response_data['flag'] = 'error'
                response_data['yl_msg'] = u'网络错误,请重试'
                return response_data
            else:  #正常
                zodiacDetailList = []
                zodiacList = [
                    u'水瓶座', u'双鱼座', u'白羊座', u'金牛座', u'双子座', u'巨蟹座', u'狮子座',
                    u'处女座', u'天秤座', u'天蝎座', u'射手座', u'摩羯座'
                ]
                from core.settings import RES_URL
                zodiacImgList = [
                    'res/default/xingzuo/01.png', 'res/default/xingzuo/02.png',
                    'res/default/xingzuo/03.png', 'res/default/xingzuo/04.png',
                    'res/default/xingzuo/05.png', 'res/default/xingzuo/06.png',
                    'res/default/xingzuo/07.png', 'res/default/xingzuo/08.png',
                    'res/default/xingzuo/09.png', 'res/default/xingzuo/10.png',
                    'res/default/xingzuo/11.png', 'res/default/xingzuo/12.png'
                ]
                for indexZodiat in range(len(zodiacList)):
                    resultBody = requests.get(
                        "http://apis.baidu.com/bbtapi/constellation/constellation_query",
                        params={
                            'consName': zodiacList[indexZodiat],
                            'type': 'today'
                        },
                        headers={'apikey': 'f2f2251558ce7cadaeee02d477baf40b'})
                    resultWihtZod = resultBody.content
                    jsonobjWihtZod = json.loads(resultWihtZod)
                    #                     zodiacDetailDict = {}
                    #                     zodiacDetailDict[zodiacList[indexZodiat]] = jsonobjWihtZod
                    zodiacDetailList.append(jsonobjWihtZod)
                for indexZodiaWeek in range(len(zodiacList)):
                    resultWeekBody = requests.get(
                        "http://apis.baidu.com/bbtapi/constellation/constellation_query",
                        params={
                            'consName': zodiacList[indexZodiaWeek],
                            'type': 'week'
                        },
                        headers={'apikey': 'f2f2251558ce7cadaeee02d477baf40b'})
                    resultWihtWeekZod = resultWeekBody.content
                    jsonobjWihtWeekZod = json.loads(resultWihtWeekZod)
                    import copy
                    weekZodDict = copy.deepcopy(jsonobjWihtWeekZod)
                    weekZodDict['money'] = jsonobjWihtWeekZod['money'][3:]
                    weekZodDict['work'] = jsonobjWihtWeekZod['work'][3:]
                    weekZodDict['job'] = jsonobjWihtWeekZod['job'][3:]
                    if jsonobjWihtWeekZod['health'][3:][-6:] == u'作者:马子晴':
                        weekZodDict['health'] = jsonobjWihtWeekZod['health'][
                            3:][:-6]
                    else:
                        weekZodDict['health'] = jsonobjWihtWeekZod['health'][
                            3:]
                    weekZodDict['love'] = jsonobjWihtWeekZod['love'][3:]
                    zodiacDetailWeekDict = {}
                    zodiacDetailWeekDict['week'] = weekZodDict
                    zodiacDetailList[indexZodiaWeek].update(
                        zodiacDetailWeekDict)
                weatherInfoDict = {}
                response_data['flag'] = 'ok'
                #             response_data['result'] = jsonobj['result']['data']
                weatherList = (
                    jsonobj['result']['data']['weather'])[0]['info']['day']
                weatherDetail = weatherList[1] + ' ' + weatherList[
                    2] + '°' + weatherList[4] + weatherList[3]
                weatherInfo = '【' + argv_city_name + '】 ' + weatherDetail
                import time
                wprTime = long(time.time() * 1000)
                wprTimestamp = long(wprTime) / 1000
                wprtime = time.localtime(wprTimestamp)
                wprMon = int(wprtime[1])
                zodIndex = wprMon - 1
                #                 zodName = zodiacList[zodIndex]
                zodDicts = {}
                zodInfo = GetCurrentZodiac(zodiacList, zodiacImgList)
                #                 zodDicts['zodiac_name'] = zodName
                zodDicts['zodiac_name'] = zodInfo['name']
                #                 zodDicts['zodiac_imgurl'] = RES_URL + zodiacImgList[zodIndex]
                zodDicts['zodiac_imgurl'] = zodInfo['url']
                zodDicts['zodiac_summary'] = ' 【星座运势】' + (
                    zodiacDetailList[zodIndex])['summary']
                commQuerySet[1].getCommunityId()
                commSize = commQuerySet.count()
                for commIndex in range(0, commSize, 1):
                    communityId = commQuerySet[commIndex].getCommunityId()
                    if int(communityId) == 3 or int(communityId) == 4:
                        continue
                    weaObj = WeatherPushRecord(wpr_detail=json.dumps(jsonobj['result']['data']),zod_detail=json.dumps(zodiacDetailList),\
                                               wpr_time=wprTime,zod_info=json.dumps(zodDicts),community_id=long(communityId))
                    weaObj.save()
                    weaId = weaObj.getWeatherPushId()
                    weatherInfoDict['time'] = wprTime
                    weatherInfoDict['content'] = weatherInfo
                    weatherInfoDict['community_id'] = communityId
                    weatherInfoDict['weaorzoc_id'] = weaId
                    import jpush as jpush
                    from push.views import createPushRecord, readIni
                    config = readIni()
                    pushTitle = '天气快报'
                    pushContent = weatherInfoDict['content']
                    apiKey = config.get("SDK", "apiKey")
                    secretKey = config.get("SDK", "secretKey")
                    _jpush = jpush.JPush(apiKey, secretKey)
                    tagSuffix = config.get('topic', "tagSuffix")
                    tagNormalName = tagSuffix + str(
                        weatherInfoDict['community_id'])
                    tagSuffix = config.get('report', "tagSuffix")
                    tagAdminName = tagSuffix + str(
                        weatherInfoDict['community_id'])
                    tagSuffix = config.get('property', "tagSuffix")
                    tagPropertyName = tagSuffix + str(
                        weatherInfoDict['community_id'])

                    from core.settings import HOST_IP, RES_URL, PUSH_STATUS
                    currentPushTime = long(time.time() * 1000)
                    evaDict = {}
                    evaDict['title'] = pushTitle
                    evaDict['content'] = pushContent
                    evaDict['pushTime'] = currentPushTime
                    evaDict['wprTime'] = weatherInfoDict['time']
                    evaDict['weaId'] = weatherInfoDict['weaorzoc_id']
                    evaDict['pushType'] = 8
                    evaDict['contentType'] = 1
                    evaDict['communityId'] = communityId
                    evaDict[
                        'userAvatar'] = RES_URL + 'res/default/avatars/default-weather.png'
                    recordId = createPushRecord(8, 1, pushTitle, pushContent,
                                                currentPushTime, 8001,
                                                json.dumps(evaDict),
                                                communityId, 8001)
                    evaDict['recordId'] = recordId
                    pushExtra = evaDict
                    push = _jpush.create_push()
                    push.audience = jpush.all_
                    push.audience = jpush.audience(
                        jpush.tag(tagNormalName, tagAdminName,
                                  tagPropertyName), )
                    push.notification = jpush.notification(
                        ios=jpush.ios(alert=pushContent.encode('uft-8'),
                                      badge="+1",
                                      extras=pushExtra),
                        android=jpush.android(pushContent, pushTitle, None,
                                              pushExtra))
                    push.options = {
                        "time_to_live": 86400,
                        "sendno": 9527,
                        "apns_production": PUSH_STATUS
                    }
                    push.platform = jpush.all_
                    push.send()
예제 #10
0
def TimingTaskWithEvaluatiorRecord(uid, userId, communityId):
    import sys
    default_encoding = 'utf-8'
    if sys.getdefaultencoding() != default_encoding:
        reload(sys)
        sys.setdefaultencoding(default_encoding)
    from addrinfo.models import UserEvaluatiorRecord, BusinessCircle
    uerQuerySet = UserEvaluatiorRecord.objects.filter(uer_uid=str(uid),
                                                      user_id=long(userId),
                                                      uer_status=2)
    if int(uerQuerySet.count()) > 10:
        pass
    else:
        uerQuerySet = UserEvaluatiorRecord.objects.filter(uer_uid=str(uid),
                                                          user_id=long(userId),
                                                          uer_status=0)  #
        userSize = uerQuerySet.count()
        if int(userSize) <= 0:  #说明该商家还没有评论过
            userEvaObj = UserEvaluatiorRecord(uer_uid=str(uid),
                                              user_id=long(userId))
            userEvaObj.save()
            config = readIni()
            pushTitle = config.get("evaluation", "title")
            pushContent = config.get("evaluation", "content0")
            alias = config.get("SDK", "youlin")
            apiKey = config.get("SDK", "apiKey")
            secretKey = config.get("SDK", "secretKey")
            _jpush = jpush.JPush(apiKey, secretKey)
            currentAlias = alias + str(userId)
            bcObj = BusinessCircle.objects.get(bc_uid=str(uid),
                                               community_id=long(communityId))
            from core.settings import HOST_IP, RES_URL
            currentPushTime = long(time.time() * 1000)
            import re
            targetTag = str(bcObj.bc_tag)
            targetIndex = 0
            #0美食 1 宾馆 2 生活娱乐
            pattern = re.compile('酒店', re.UNICODE)
            if pattern.match(targetTag):
                targetIndex = 1
            else:
                pattern = re.compile('美食', re.UNICODE)
                if pattern.match(targetTag):
                    targetIndex = 0
                else:
                    pattern0 = re.compile('美食', re.UNICODE)
                    pattern1 = re.compile('酒店', re.UNICODE)
                    if pattern0.match(targetTag) is None and pattern1.match(
                            targetTag) is None:
                        targetIndex = 2
            evaDict = {}
            evaDict['uid'] = uid
            evaDict['userId'] = userId
            evaDict['communityId'] = communityId
            evaDict['tag'] = targetIndex
            evaDict['title'] = pushTitle
            evaDict['content'] = pushContent
            evaDict['pushTime'] = currentPushTime
            evaDict['uerId'] = userEvaObj.getBizCirRecordId()
            evaDict['pushType'] = 7
            evaDict['contentType'] = 1
            evaDict['shopName'] = bcObj.bc_name
            evaDict[
                'userAvatar'] = RES_URL + 'res/default/avatars/bizcir-eval.png'
            recordId = createPushRecord(7, 1, pushTitle, pushContent,
                                        currentPushTime, 7001,
                                        json.dumps(evaDict), communityId, 7001)
            evaDict['recordId'] = recordId
            pushExtra = evaDict

            push = _jpush.create_push()
            push.audience = jpush.all_
            push.audience = jpush.audience(jpush.alias(currentAlias), )
            push.notification = jpush.notification(
                ios=jpush.ios(alert=pushContent.encode('utf-8'),
                              badge="+1",
                              extras=pushExtra),
                android=jpush.android(pushContent, pushTitle, None, pushExtra))
            push.options = {
                "time_to_live": 86400,
                "sendno": 9527,
                "apns_production": PUSH_STATUS
            }
            push.platform = jpush.all_
            push.send()
예제 #11
0
def pushView(request):
    if request.method == 'POST':
        uf = PushForms(request.POST)
        if uf.is_valid():
            admin_id = uf.cleaned_data['admin_id'].admin_id
            city_id = uf.cleaned_data['city_id'].city_id
            community_id = uf.cleaned_data['community_id'].community_id
            #获取的表单数据与数据库进行比较
            adminObj = Admin.objects.get(admin_type=1,
                                         admin_id=admin_id,
                                         community_id=community_id,
                                         city_id=city_id)
            ListAdmin = []
            config = readIni()
            if adminObj:
                userId = adminObj.user.user_id
                userObj = adminObj.user
                #baidu_channel_id = userObj.user_push_channel_id.encode('utf-8')
                pushTitle = config.get("users", "title")
                communityObj = adminObj.community
                cityName = communityObj.city.city_name
                communityName = communityObj.community_name
                address = cityName + communityName
                familyAddr = address.encode('utf-8')
                pushContent = config.get("users",
                                         "content1") + familyAddr + config.get(
                                             "users", "content3")
                ListAdmin.append(
                    genAdminDetailDict(userId, cityName, community_id,
                                       communityName, address, 2))
                userObj.user_json = json.dumps(ListAdmin)
                adminObj.admin_info = json.dumps(ListAdmin)
                userAvatar = settings.RES_URL + 'res/default/avatars/default-avatar.png'
                currentPushTime = long(time.time() * 1000)
                customContent = genAdminContentDict(userId, userAvatar,
                                                    pushTitle, pushContent, 2,
                                                    currentPushTime, 1,
                                                    ListAdmin, community_id)
                recordId = createPushRecord(1, 2, pushTitle, pushContent,
                                            currentPushTime, userId,
                                            json.dumps(customContent), 1)
                customContent = genAdminContentDict(userId, userAvatar,
                                                    pushTitle, pushContent, 2,
                                                    currentPushTime, 1,
                                                    ListAdmin, community_id,
                                                    recordId)
                config = readIni()
                apiKey = config.get("SDK", "apiKey")
                secretKey = config.get("SDK", "secretKey")
                alias = config.get("SDK", "youlin")
                _jpush = jpush.JPush(apiKey, secretKey)
                currentAlias = alias + str(userId)
                pushExtra = customContent
                push = _jpush.create_push()
                push.audience = jpush.all_
                push.audience = jpush.audience(jpush.alias(currentAlias), )
                push.notification = jpush.notification(android=jpush.android(
                    pushContent, pushTitle, None, pushExtra))
                push.options = {
                    "time_to_live": 86400,
                    "sendno": 9527,
                    "apns_production": True
                }
                push.platform = jpush.all_
                try:
                    push.send()
                except:
                    pass
                adminObj.admin_type = 2
                adminObj.app_time = currentPushTime
                adminObj.save()
                userObj.user_type = 2
                userObj.user_time = currentPushTime
                userObj.save()
                #比较成功,跳转index
                return render_to_response(
                    'success.html',
                    RequestContext(request, {
                        'createtask_success': True,
                    }))

            else:
                #小区没有管理员申请
                return render_to_response(
                    'fail.html',
                    RequestContext(request, {
                        'createtask_fail': True,
                    }))
    else:
        uf = PushForms()
    return render_to_response('pushView.html', {'uf': uf},
                              context_instance=RequestContext(request))