コード例 #1
0
ファイル: ttag.py プロジェクト: ttagit/website
def ttagRemove(request, ttag_id):
    try:
        thereturn = loginscreen(request)
        authed, user = ttagServiceAuth(request)
        if authed:
            if request.method == "POST":
                response = ttagPost(
                    "/user-data/remove-ttag",
                    {"ttag_id": ttag_id, "user_id": user["_id"], "access_token": request.COOKIES["access_token"]},
                )
                location = request.POST["location"]
                if request.is_ajax():
                    thereturn = HttpResponse(mark_safe('<article class="deleted">Ttag deleted</article>'))
                else:
                    thereturn = HttpResponseRedirect(location)
            else:
                location = request.META["HTTP_REFERER"] if "location" not in request.GET else request.GET["location"]
                user_name = user["user_name"]
                thereturn = render_to_response(
                    "partial_ttag_confirmdelete.html", locals(), context_instance=RequestContext(request)
                )
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #2
0
ファイル: newsletter.py プロジェクト: ttagit/website
def join(request):
    try :
        thereturn = HttpResponse(mark_safe('<p>Sorry, we were not able to handle your request</p>'))
        showPopup = True
        if request.method == 'GET' :
            loggedin, data = ttagServiceAuth(request)
            if request.is_ajax() :
                thereturn = render_to_response('partial_newsletter_joinform.html',locals(),context_instance=RequestContext(request))
            else :
                thereturn = render_to_response('newsletter_joinform.html',locals(),context_instance=RequestContext(request))
        else :
            form = Newsletter(request.POST)
            if form.is_valid() :
                news = ttagPost('/socialnetwork/save-email',{'email':form.clean_Email(),'ip_address':request.META['REMOTE_ADDR']})
                # send email notification
                from webapp.views.email import notifyOfNewsletterSuscribe
                notifyOfNewsletterSuscribe(request, form.clean_Email())
                if request.is_ajax() :
                    thereturn = render_to_response('partial_newsletter_joinform.html',locals(),context_instance=RequestContext(request))
                else :
                    thereturn = render_to_response('newsletter_joinform.html',locals(),context_instance=RequestContext(request))
            elif request.is_ajax() :
                thereturn = render_to_response('partial_newsletter_joinform.html',locals(),context_instance=RequestContext(request))
            else :
                thereturn = render_to_response('newsletter_joinform.html',locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #3
0
ファイル: hubold.py プロジェクト: ttagit/website
def findHubs(request):
    authed, data = ttagServiceAuth(request)
    response = ttagRequestCount(data['_id'])
    counts = response['counts']
    if authed: 
        access_token = request.COOKIES['access_token']
        user_id = data["_id"]
        if 'hub_name' in request.POST and 'hub_desc' in request.POST:
            hub_name = request.POST["hub_name"]
            hub_desc = request.POST["hub_desc"]
            response = ttagCreateHub(user_id, access_token, hub_name, hub_desc,"true", "0")
            if response["result"] == "OK":
                #context = {"status":"created","hub":response["data"]["hub"]}
                status = "created"
                hub = response["data"]["hub"]
                return render_to_response('hub/hub_create.html', locals(), context_instance=RequestContext(request))
            else:
                status = "error"
                error_msg = response["msg"]                
                #context = {"status":"error","hub_name":hub_name,"hub_desc":hub_desc,"error_msg":response["msg"]}
                return render_to_response('hub/hub_create.html', locals(), context_instance=RequestContext(request))
        else:
            #context = {"status":"new"}
            status = "new"
            return render_to_response('hub/hub_create.html', locals(), context_instance=RequestContext(request))
    else:
        
        return HttpResponse("Invalid request")
コード例 #4
0
ファイル: hubold.py プロジェクト: ttagit/website
def getHubTags(request, data_type,data_value):
    loggedin, data = ttagServiceAuth(request)
    response_count = ttagRequestCount(data['_id'])
    counts = response_count['counts']
    
    if data_type == "id":
        
        hub_response = ttagGetHubByHubId(data_value)
        
        if hub_response["result"] == "OK":
            hub = hub_response["data"]["hub"]
            from_time = 0 if 'from_time' not in request.POST else request.POST['from_time']
            to_time = 4116171410000 if 'to_time' not in request.POST else request.POST['to_time']
            items_per_page = 10000 if 'items_per_page' not in request.POST else request.POST['items_per_page']
            page_number = 0 if 'page_number' not in request.POST else request.POST['page_number']
            response = ttagGetHubTtags(data_value,from_time,to_time,items_per_page,page_number)
        else:
            return HttpResponse(hub_response["msg"])
    else:
        return HttpResponse("Invalid data type")
    
    if response["result"] == "OK":
        ttags =  response["data"]["hub_ttags"]
        spraycan = True
        loggedin_user = data['_id']
        servertime = datetime.datetime.fromtimestamp(int(response['time'])/1000)
        
        thereturn = render_to_response('hub/hub_ttags.html', locals(), context_instance=RequestContext(request))
        return thereturn   
    else:
        return HttpResponse(response["msg"])
コード例 #5
0
ファイル: user.py プロジェクト: ttagit/website
def userFavorite(request):
    try :
        authed, user = ttagServiceAuth(request)
        thereturn = loginscreen(request)
        if authed and 'favorite_id' in request.POST :
            thereturn = custompopup(request,'<p>Could not complete request</p>')
            form = Favorite(request.POST)
            if form.is_valid() :
                access_token = request.COOKIES['access_token']
                faves = ttagRequestLists(user['_id'])
                id = ''
                if faves['data']['favorites'] :
                    for item in faves['data']['favorites'] :
                        if 'favorite_id' in item and item['favorite_id'] == form.getFavorite_Id() and item['favorite_type'] == form.getFavorite_Type() :
                            id = item['_id']
                            break;
                postData = {'access_token': access_token, 'user_id': user['_id'], 'type': form.getFavorite_Type()}
                postURL = "/action/favorite"
                if len(id) == 0 :
                    postData['favorite_id'] = form.getFavorite_Id()
                    postData['values'] = {'title': form.getFavorite_Title(), 'category': form.getFavorite_Category(), 'description': form.getFavorite_Description()}
                else :
                    postData['id'] = id
                    postURL = "/action/unfavorite"
                response = ttagPost(postURL,postData)
                if request.is_ajax() :
                    thereturn = render_to_response("follow_ajax.html",{'request': request, 'response': response, 'id': id}, context_instance=RequestContext(request))
                else :
                    thereturn = HttpResponseRedirect(request.META['HTTP_REFERER'])
            else :
                thereturn = custompopup(request,'<p>'+str(form.errors)+'</p>')
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #6
0
ファイル: marketing.py プロジェクト: ttagit/website
def view(request):
    try :
        thereturn = HttpResponse('You are not authorized to view this area of the website')
        loggedin, data = ttagServiceAuth(request)
        if loggedin :
            usertemplate = 'base_marketing.html'
            follow = -1
            hidebadges = True
            hidefooter = True
            hideproinfo = True
            user_id = data["_id"]
            angularapp = "ttagitMarketing"
            paypal_dict = {
                "business":settings.PAYPAL_RECEIVER_EMAIL,
                "custom":user_id,
                "item_number": request.COOKIES['access_token'],
                "item_name":"Ttagit Ad Credits",
                "notify_url": paths.HTTPS+request.get_host() + "/3f2cf0fe3d994fb8dfe6d8f9g2h5",
                "return_url": paths.HTTPS+request.get_host() + reverse('marketing-thankyou'),
                "cancel_return": paths.HTTPS+request.get_host()+ reverse('marketing'),
            }
            form = PayPalPaymentsForm(initial=paypal_dict)
            formaction = conf.POSTBACK_ENDPOINT if not debug.DEBUG else conf.SANDBOX_POSTBACK_ENDPOINT
            thereturn = render_to_response('marketing_details.html',locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #7
0
ファイル: hubold.py プロジェクト: ttagit/website
def MainHub(request):
    loggedin, data = ttagServiceAuth(request)
    #"owner_id":"5064dd00559ae9da2b9e38b8","location_type":"HUB","user_id":"5064dd00559ae9da2b9e38b8","access_token":"ff891baeb4106593b40a5b9110c90f44"
    if loggedin:
        user_id = data["_id"]
        user_name = data["user_name"]
        response_hubs = ttagGetHubsByUserName(data['user_name'])
        #print response_hubs
        response_count = ttagRequestCount(data['_id'])
        counts = response_count['counts']
        block_title = "My Hubs"
        if response_hubs["result"] == "OK":
            hubs = response_hubs["data"]["hubs"]
            logined_and_different = False
            joined_hubs = ttagGetJoinedHubsByUserName(user_name)["data"]["hubs"]
            for hub in response_hubs["data"]["hubs"]:
                if hub["creater_id"] == user_id:
                    hub["owner"] = True
                else:
                    hub["owner"] = False
                hububub = ttagGetHubByHubId(hub["hub_id"])
                #print hububub
                hub["joined"] = False
                for joined_hub in joined_hubs:
                    #print "Joined Hub:" + hub["hub_name"]+":" + joined_hub["_id"] + "======" + hub["_id"]+":"+hub["hub_name"]
                    if joined_hub["_id"] == hub["_id"]:
                        hub["joined"] = True
                        break
            
            return render_to_response('hub/user_hubs.html', locals(), context_instance=RequestContext(request))
        else:
            return HttpResponse(response_hubs["msg"])
    else:
        return HttpResponseRedirect('/')
コード例 #8
0
ファイル: hubold.py プロジェクト: ttagit/website
def getHubMembers(request,data_type,data_value):
    loggedin, data = ttagServiceAuth(request)
    #"owner_id":"5064dd00559ae9da2b9e38b8","location_type":"HUB","user_id":"5064dd00559ae9da2b9e38b8","access_token":"ff891baeb4106593b40a5b9110c90f44"
    if loggedin:
        user_id = data["_id"]
        user_name = data["user_name"]
        response_hubs = ttagGetHubsByOwnerId(data['_id'], request.COOKIES['access_token'])
        response_count = ttagRequestCount(data['_id'])
        counts = response_count['counts']
        
        key_name = "hub_id"
        if data_type == "id":
            from_time = 0 if 'from_time' not in request.POST else request.POST['from_time']
            to_time = 4116171410000 if 'to_time' not in request.POST else request.POST['to_time']
            items_per_page = 10000 if 'items_per_page' not in request.POST else request.POST['items_per_page']
            page_number = 0 if 'page_number' not in request.POST else request.POST['page_number']
            response = ttagGetHubUsers(data_value, from_time, to_time, items_per_page, page_number)
        
        if response["result"] == "OK":
            hub_users= response["data"]["hub_users"]
            #context = {'hub_users': response["data"]["hub_users"],key_name:data_value}
            thereturn = render_to_response('hub/hub_members.html', locals(), context_instance=RequestContext(request))
            return thereturn
        else:
            return HttpResponse(response["msg"])
    else:
        return HttpResponseRedirect('/')
コード例 #9
0
ファイル: ttag.py プロジェクト: ttagit/website
def ttagShow(request, ttag_id, useHTML, appendCode=""):
    try:
        loggedin, data = ttagServiceAuth(request)
        thereturn = custompopup(request, '<p>Could not complete request</p>')
        response = ttagPost("/find/ttag", {'ttag_id': ttag_id})
        if 'result' in response and response['result'] == 'OK':
            if loggedin:
                loggedin_user = data['_id']
                from webapp.views.user import getUserFollowers
                response['data']['followers'] = getUserFollowers(loggedin_user)
            servertime = datetime.datetime.fromtimestamp(
                int(response['time']) / 1000)
            context = {
                'pagetitle': 'ttagit - Flagged Ttag',
                'request': request,
                'ttag': response['data']['ttag'],
                'servertime': servertime,
                'appendCode': appendCode
            }
            thereturn = render_to_response(
                'ttag_show.html',
                context,
                context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #10
0
ファイル: signup.py プロジェクト: ttagit/website
def privacyView(request):
    try :
        loggedin, data = ttagServiceAuth(request)
        return render_to_response('privacy.html', locals(), context_instance=RequestContext(request))
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #11
0
def userSettingsView(request):
    try :
        authed, data = ttagServiceAuth(request)
        if authed:
            if request.method != "POST":
                formdata = {'gender':'','google_map_address':'','pro_description':''}
                for key in data :
                    formdata[key] = data[key]
            else :
                formdata = request.POST
            form = SettingsForm(formdata)
            context = dict()
            context['form'] = form
            context['data'] = data
            #localprint(request, data)
            context['loggedin'] = True
            context['loggedin_user'] = data['_id']
            context['request'] = request
            context['pagetitle'] = "ttagit - User Settings Page"
            return render_to_response('user_settings_details.html', context, context_instance=RequestContext(request))
        else:
            ## user is not logged in
            return HttpResponseRedirect(paths.HTTPS+request.get_host()+'/index/')
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #12
0
ファイル: ttag.py プロジェクト: ttagit/website
def ttagRemove(request, ttag_id):
    try:
        thereturn = loginscreen(request)
        authed, user = ttagServiceAuth(request)
        if authed:
            if request.method == 'POST':
                response = ttagPost(
                    '/user-data/remove-ttag', {
                        'ttag_id': ttag_id,
                        'user_id': user['_id'],
                        'access_token': request.COOKIES['access_token']
                    })
                location = request.POST['location']
                if request.is_ajax():
                    thereturn = HttpResponse(
                        mark_safe(
                            '<article class="deleted">Ttag deleted</article>'))
                else:
                    thereturn = HttpResponseRedirect(location)
            else:
                location = request.META[
                    'HTTP_REFERER'] if 'location' not in request.GET else request.GET[
                        'location']
                user_name = user['user_name']
                thereturn = render_to_response(
                    'partial_ttag_confirmdelete.html',
                    locals(),
                    context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #13
0
ファイル: spraycan.py プロジェクト: ttagit/website
def url(request,
        location=None,
        start_time=None,
        partial='spraycan.html',
        renderJSON=False,
        thetemplate=None,
        user_name=None,
        location_type='URL',
        payload={},
        allowPublic=False,
        to_time=INFINITE_TIME):
    if location == None and 'location_type' in request.GET:
        location_type = request.GET['location_type']
    if location == None:
        location = request.GET.get('location', "")
        renderJSON = (request.is_ajax())
    if start_time == None:
        start_time = START_TIME if 'start_time' not in request.GET else request.GET[
            'start_time']
    if 'to_time' in request.GET:
        to_time = request.GET['to_time']
    thereturn = loginscreen(request)
    if not request.is_ajax():
        theredirect = "http://www.ttagit.com" if 'location' not in request.GET else request.GET[
            'location']
        thereturn = HttpResponseRedirect(theredirect)
    loggedin, data = ttagServiceAuth(request)
    if data != None:
        data['loggedin'] = loggedin
    if loggedin or allowPublic:
        thereturn = buildURL(request, data, location, location_type, user_name,
                             start_time, renderJSON, partial, thetemplate,
                             payload, to_time)
    return thereturn
コード例 #14
0
ファイル: hubold.py プロジェクト: ttagit/website
def updateHub(request,data_type,data_value):
    hub_id = data_value
    authed, user = ttagServiceAuth(request)
    if authed: 
        access_token = request.COOKIES['access_token']
        user_id = user["_id"]
        if 'hub_name' in request.POST and 'hub_desc' in request.POST:
            hub_name = request.POST["hub_name"]
            hub_desc = request.POST["hub_desc"]
            response = ttagUpdateHub(user_id, access_token, hub_id,hub_name, hub_desc,"true", "0")
            if response["result"] == "OK":
                hub = response["data"]["hub"]
                return render_to_response('hub/hub_update.html', locals(), context_instance=RequestContext(request))
            else:
                hub = response["data"]["hub"]
                return render_to_response('hub/hub_update.html', locals(), context_instance=RequestContext(request))
        else:
            response = ttagGetHubByHubId(hub_id)    
            if response["result"] == "OK":
                hub = response["data"]["hub"]
                return render_to_response('hub/hub_update.html', locals(), context_instance=RequestContext(request))
            else:
                return HttpResponse(response["msg"])
                
    else:
        
        return HttpResponse("Invalid request")
コード例 #15
0
ファイル: user.py プロジェクト: ttagit/website
def userDelete(request):
    try :
        response = loginscreen(request)
        loggedin, data = ttagServiceAuth(request)
        if loggedin :
            access_token = request.COOKIES['access_token']
            if request.method == 'GET' :
                pagetitle = 'TTAGIT - User Account Delete Request Confirmation'
                showPopup = True
                response = render_to_response('user_confirmdelete.html' if not request.is_ajax() else 'partial_user_confirmdelete.html', locals(), context_instance=RequestContext(request))
            else :
                json_obj = ttagServiceAccountDelete(access_token)
                if json_obj['result'] == 'OK' :
                    response = custompopup(request,'<p>Your Acccount was deleted</p>', reverse('index-page'))
                    request.COOKIES['access_token'] = ''
                else :
                    response = custompopup(request,'<p>Your Account was not deleted</p>')
            return response
#        only during development!!!
#        elif 'user_name' in request.GET :
#            ttagPost('/delete-user',{'user_name':request.GET['user_name']})
#            response = HttpResponse('Your Account was deleted')
#        elif 'email' in request.GET :
#            ttagPost('/delete-user',{'email':request.GET['email']})
#            response = HttpResponse('Your Account was deleted')
        return response
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #16
0
ファイル: marketing.py プロジェクト: ttagit/website
def thankyou(request):
    try :
        from paypal.standard.pdt.views import pdt
        loggedin, data = ttagServiceAuth(request)
        return pdt(request, template='marketing_thankyou.html', context=locals())
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #17
0
def privacyView(request):
    try:
        loggedin, data = ttagServiceAuth(request)
        return render_to_response('privacy.html',
                                  locals(),
                                  context_instance=RequestContext(request))
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #18
0
ファイル: user.py プロジェクト: ttagit/website
def userFavorite(request):
    try:
        authed, user = ttagServiceAuth(request)
        thereturn = loginscreen(request)
        if authed and 'favorite_id' in request.POST:
            thereturn = custompopup(request,
                                    '<p>Could not complete request</p>')
            form = Favorite(request.POST)
            if form.is_valid():
                access_token = request.COOKIES['access_token']
                faves = ttagRequestLists(user['_id'])
                id = ''
                if faves['data']['favorites']:
                    for item in faves['data']['favorites']:
                        if 'favorite_id' in item and item[
                                'favorite_id'] == form.getFavorite_Id(
                                ) and item[
                                    'favorite_type'] == form.getFavorite_Type(
                                    ):
                            id = item['_id']
                            break
                postData = {
                    'access_token': access_token,
                    'user_id': user['_id'],
                    'type': form.getFavorite_Type()
                }
                postURL = "/action/favorite"
                if len(id) == 0:
                    postData['favorite_id'] = form.getFavorite_Id()
                    postData['values'] = {
                        'title': form.getFavorite_Title(),
                        'category': form.getFavorite_Category(),
                        'description': form.getFavorite_Description()
                    }
                else:
                    postData['id'] = id
                    postURL = "/action/unfavorite"
                response = ttagPost(postURL, postData)
                if request.is_ajax():
                    thereturn = render_to_response(
                        "follow_ajax.html", {
                            'request': request,
                            'response': response,
                            'id': id
                        },
                        context_instance=RequestContext(request))
                else:
                    thereturn = HttpResponseRedirect(
                        request.META['HTTP_REFERER'])
            else:
                thereturn = custompopup(request,
                                        '<p>' + str(form.errors) + '</p>')
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #19
0
ファイル: user.py プロジェクト: ttagit/website
def userFollow(request, user_name):
    try:
        authed, user = ttagServiceAuth(request)
        thereturn = loginscreen(request)
        if authed:
            thereturn = custompopup(request,
                                    '<p>Could not complete request</p>')
            access_token = request.COOKIES['access_token']
            location = request.META[
                'HTTP_REFERER'] if 'location' not in request.POST else request.POST[
                    'location']
            followers = ttagRequestFollowers(user['_id'])
            found = False
            follower_id = 0
            if 'data' in followers and 'users' in followers[
                    'data'] and followers['data']['users'] != None:
                for follower in followers['data']['users']:
                    if follower['user_name'] == str(user_name):
                        found = True
                        follower_id = follower['user_id']
                        break
            if found:
                response = ttagPost(
                    "/follow/delete", {
                        'access_token': access_token,
                        'user_id': user['_id'],
                        'follower_id': follower_id,
                        'followee_id': user['_id']
                    })
            else:
                f_user = ttagRequestUserProfile(user_name)
                follower_id = f_user['data']['_id']
                response = ttagPost(
                    "/follow/create", {
                        'access_token': access_token,
                        'user_id': user['_id'],
                        'follower_id': follower_id,
                        'followee_id': user['_id']
                    })
                if response["result"] == "OK":
                    from webapp.views.email import notifyOfUserFollowing
                    # send reply notification
                    notifyOfUserFollowing(request, follower_id, user["_id"])
            response['found'] = found
            # localprint(request, response)
            if request.is_ajax():
                thereturn = render_to_response(
                    'partial_user_follow.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                thereturn = HttpResponseRedirect(location)
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #20
0
ファイル: marketing.py プロジェクト: ttagit/website
def thankyou(request):
    try:
        from paypal.standard.pdt.views import pdt
        loggedin, data = ttagServiceAuth(request)
        return pdt(request,
                   template='marketing_thankyou.html',
                   context=locals())
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #21
0
def userAvatarUpload(request, isAndroid=False):
    try :
        authed, data = ttagServiceAuth(request)
        if authed and request.method == 'POST' :
            aToken = request.COOKIES['access_token']
            formdata = {'gender':'','google_map_address':'','pro_description':''}
            if len(str(request.POST.get('avatar_src',""))) > 0 and len(str(request.POST.get('avatar_name',""))) > 0 and len(str(request.POST.get('avatar_type',""))) > 0 :
                files = {}
                from django.core.files.uploadedfile import SimpleUploadedFile
                import base64
                files['avatar_upload'] = SimpleUploadedFile(request.POST['avatar_name'],base64.b64decode(mark_safe(request.POST['avatar_src'])),request.POST['avatar_type'])
            else :
                files = request.FILES
            for key in data :
                formdata[key] = data[key]
            upload = UploadFileForm(request.POST, files)
            statusmsg = "User Avatar update successful!"
            print request.POST
            if 'avatar_upload' not in request.POST and 'avatar_src' not in request.POST and len(str(request.POST.get('avatar_url',''))) > 0 :
                upload = SettingsAvatarForm(request.POST)
                if upload.is_valid() :
                    avatar_url = upload.clean_AvatarURL()
            if not upload.is_valid() :
                statusmsg = ''.join(["User Avatar update failed: ",upload.errors.as_text().replace('\r','').replace('\n','')])
                svcResp = {'result':'ERROR','msg':statusmsg}
            else :
                from website.settings import MEDIA_URL
                if 'avatar_delete' in request.POST or 'avatar_upload' in request.POST :
                    avatar_url = ''
                if 'avatar_upload' in files :
                    avatar_url = ''.join([MEDIA_URL,handleUploadedAvatar(files['avatar_upload'], data['user_name'], aToken)])
                if 'avatar_url' in locals() and avatar_url != data['avatar_url'] :
                    svcResp = ttagServiceAvatarChange(aToken,avatar_url)
                    if svcResp.get('result',"OK") == 'OK' :
                        svcResp['data'], data['avatar_url'] = {'filename':avatar_url}, avatar_url
                    else :
                        statusmsg = ''.join(["User Avatar update failed: ",svcResp['msg']])
                    svcResp['msg'] = statusmsg
                else :
                    svcResp = {'result':'OK','msg':'Nothing changed'}
            svcResp = mark_safe(simplejson.dumps(svcResp))
            form = SettingsForm(formdata)
            context = {'request':request,'loggedin':True,'data':data,'form':form,'settings_message':statusmsg, 'location':'Settings', 'svcResp':svcResp}
            ajax_page = 'user_avataruploaded.html' if not isAndroid else 'android_avataruploaded.html'
            page = ajax_page if ( request.is_ajax() or isAndroid ) else 'home_settings.html'
            thereturn = render_to_response(page,context,context_instance=RequestContext(request))
            if request.is_ajax() and not isAndroid and 'avatar_url' in locals() and len(str(avatar_url)) > 0 :
                jsonReturn = simplejson.dumps({'userAvatar':mark_safe('<img data-dj-view="userAvatar" src="'+avatar_url+'" alt="" />'),'userAvatarForm':mark_safe(thereturn.content)})
                thereturn = render_to_response('ajax_ttag_create.html',locals(),context_instance=RequestContext(request))
            return thereturn
        else :
            return loginscreen(request)
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #22
0
ファイル: user.py プロジェクト: ttagit/website
def userProfileView(request, user_name='', view_type='', page='', time='', userdetails='', pagetitle='ttagit - User Profile Page', pagetemplate='user_profile.html', partial=None, hideMiniSpraycan=False):
    try :
        authed, data = ttagServiceAuth(request)
        follow = -1
        loggedin_user = '' if not authed else data['_id']
        if user_name != '' :
            if request.COOKIES.has_key('access_token'):
                response = ttagRequestUserProfileWithAccessToken(user_name,request.COOKIES['access_token'])
            else:
                response = ttagRequestUserProfile(user_name)
            if 'data' in response and response['data']['is_activated'] and not response['data']['is_deleted'] :
                data = response['data']
                if 'follow' in response :
                    follow = response['follow']
                if loggedin_user == data['_id'] :
                    follow = -1
            else :
                return HttpResponseRedirect(reverse('home-page'))
        elif data != None and 'user_name' in data :
            user_name = data['user_name']
        if not data or data == None :
            return HttpResponseRedirect(reverse('home-page'))
        response = ttagRequestCount(data['_id'])
        if 'counts' in response :
            counts = response['counts']
            servertime = response['time']
            counts['tags'] = counts['ttags']
            counts['following'] = counts['followees']
        else :
            counts = {'tags':0,'replies':0,'followers':0,'following':0}
            import time
            servertime = int(time.mktime(datetime.datetime.now().timetuple())*1000)
        if view_type not in ['tags','replies','following','followers','finds','favorites'] :
            view_type = 'tags'
        if partial is not None :
            return render_to_response(partial,locals(),context_instance=RequestContext(request))
        if not page or page == '' :
            page = 1
        page = int(page)
        if not time or time == '' :
            time = 0
        time = int(time)
        more = True if counts[view_type] > PROFILE_ITEM_ROWS * page and time == 0 else False
        if userdetails == '' :
            userdetails = getUserDetails(request, data, user_name, data['_id'], loggedin_user, view_type, page, time, more)
        if request.is_ajax() :
            return HttpResponse(userdetails)
        context = {'view_type': view_type, 'data': data, 'counts': counts, 'pagetitle': pagetitle, 'request': request, 'loggedin': False, 'details': userdetails, 'page': page, 'servertime': servertime,'follow':follow, 'showfollow': True, 'hideMiniSpraycan': hideMiniSpraycan}
        if authed :
            context['loggedin'] = True
        return render_to_response(pagetemplate, context, context_instance=RequestContext(request))
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #23
0
def homeView(request):
    """Show the homepage, handling whether or not the user is logged in"""
    try:
        authed, data = ttagServiceAuth(request)
        if not authed:
            return indexView(request)
        # logged in homepage defaults to dashboard
        from webapp.views.user import userWallView
        return userWallView(request, data['user_name'])
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #24
0
ファイル: home.py プロジェクト: ttagit/website
def homeView(request):
    """Show the homepage, handling whether or not the user is logged in"""
    try :
        authed, data = ttagServiceAuth(request)
        if not authed: 
            return indexView(request)
        # logged in homepage defaults to dashboard
        from webapp.views.user import userWallView
        return userWallView(request, data['user_name'])
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #25
0
ファイル: signup.py プロジェクト: ttagit/website
def eulaView(request):
    try :
        form = EulaForm()
        loggedin, data = ttagServiceAuth(request)
        if (request.method == 'POST'):
            form = EulaForm(request.POST)         # bound form
            if form.is_valid():
                return HttpResponseRedirect(paths.HTTPS+request.get_host()+'/signupmail/')
        return render_to_response('eula.html', locals(), context_instance=RequestContext(request))
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #26
0
ファイル: newsletter.py プロジェクト: ttagit/website
def join(request):
    try:
        thereturn = HttpResponse(
            mark_safe('<p>Sorry, we were not able to handle your request</p>'))
        showPopup = True
        if request.method == 'GET':
            loggedin, data = ttagServiceAuth(request)
            if request.is_ajax():
                thereturn = render_to_response(
                    'partial_newsletter_joinform.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                thereturn = render_to_response(
                    'newsletter_joinform.html',
                    locals(),
                    context_instance=RequestContext(request))
        else:
            form = Newsletter(request.POST)
            if form.is_valid():
                news = ttagPost(
                    '/socialnetwork/save-email', {
                        'email': form.clean_Email(),
                        'ip_address': request.META['REMOTE_ADDR']
                    })
                # send email notification
                from webapp.views.email import notifyOfNewsletterSuscribe
                notifyOfNewsletterSuscribe(request, form.clean_Email())
                if request.is_ajax():
                    thereturn = render_to_response(
                        'partial_newsletter_joinform.html',
                        locals(),
                        context_instance=RequestContext(request))
                else:
                    thereturn = render_to_response(
                        'newsletter_joinform.html',
                        locals(),
                        context_instance=RequestContext(request))
            elif request.is_ajax():
                thereturn = render_to_response(
                    'partial_newsletter_joinform.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                thereturn = render_to_response(
                    'newsletter_joinform.html',
                    locals(),
                    context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #27
0
ファイル: help.py プロジェクト: ttagit/website
def viewHelp(request, thelayout, activeTab, pagename, pagetitle, suform=None, signinform=None ):
    try :
        loggedin, user = ttagServiceAuth(request)
        if loggedin and thelayout == 'base_help.html' :
            thelayout = 'base_helpempty.html'
        thereturn = render_to_response(pagename, locals(), context_instance=RequestContext(request))
        if loggedin and not request.is_ajax() and thelayout != 'base_android.html' :
            from webapp.views.user import userProfileView
            return userProfileView(request, userdetails=mark_safe(thereturn.content), pagetitle=pagetitle, pagetemplate='user_help.html')
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #28
0
ファイル: marketing.py プロジェクト: ttagit/website
def upload(request):
    try :
        thereturn = HttpResponse('You are not authorized to view this area of the website')
        loggedin, data = ttagServiceAuth(request)
        if loggedin and request.method == 'POST' and 'avatar_upload' in request.FILES :
            upload = UploadFileForm(request.POST, request.FILES)
            avatar_url = ''
            if upload.is_valid() :
                avatar_url = ''.join([paths.AD_URL,handleUploadedAvatar(request.FILES['avatar_upload'], data['user_name'], request.COOKIES['access_token'], paths.AD_ROOT)])
            thereturn = render_to_response('marketing_avatar.html',locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #29
0
ファイル: hubold.py プロジェクト: ttagit/website
def findHubsGeneral(request):

    authed, data = ttagServiceAuth(request)
    joined_hubs = []
    block_title = ""
    if authed:
        response_count = ttagRequestCount(data['_id'])
        counts = response_count['counts']
        access_token = request.COOKIES['access_token']
        user_id = data["_id"]
        user_name = data["user_name"]

        if request.method == 'POST' and request.POST[
                'find_method'] == 'general':
            response = ttagGetHubsByName(request.POST['query'])
            if response["result"] == 'OK':
                hubs = response['data']['hubs']

                logined_and_different = False
                joined_hubs = ttagGetJoinedHubsByUserName(
                    user_name)["data"]["hubs"]
                for hub in response["data"]["hubs"]:

                    if hub["creater_id"] == user_id:
                        hub["owner"] = True
                    else:
                        hub["owner"] = False

                    hub["joined"] = False
                    for joined_hub in joined_hubs:
                        #print "Joined Hub:" + hub["hub_name"]+":" + joined_hub["_id"] + "======" + hub["_id"]+":"+hub["hub_name"]
                        if joined_hub["_id"] == hub["_id"]:
                            hub["joined"] = True
                            break

                thereturn = render_to_response(
                    'hub/find_hubs_general.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                return HttpResponse(response["msg"])
        else:
            #context = {'hubs': response["data"]["hubs"],"user_id":user_id,"joined_hubs":joined_hubs,"logined_and_different":logined_and_different}
            thereturn = render_to_response(
                'hub/find_hubs_general.html',
                locals(),
                context_instance=RequestContext(request))
        return thereturn
    else:
        return HttpResponseRedirect('/')
コード例 #30
0
ファイル: hubold.py プロジェクト: ttagit/website
def createHub(request):
    authed, data = ttagServiceAuth(request)
    if authed: 
        #response = ttagRequestCount(data['_id'])
        access_token = request.COOKIES['access_token']
        user_id = data["_id"]
        if 'hub_name' in request.POST and 'hub_desc' in request.POST:
            hub_name = request.POST["hub_name"]
            hub_desc = request.POST["hub_desc"]
            response = ttagCreateHub(user_id, access_token, hub_name, hub_desc,"true", "0")
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
    else:
        
        return HttpResponse("Invalid request")
コード例 #31
0
ファイル: spraycan.py プロジェクト: ttagit/website
def location(request, ttag_id):
    try :
        thereturn = HttpResponse(mark_safe('<p>This section of the website is currently under construction. Check back soon!</p>'));
        start_time = '0' if 'start_time' not in request.GET else request.GET['start_time']
        location_type = 'geo'
        loggedin, data = ttagServiceAuth(request)
        if loggedin :
            response = ttagPost('/ttag/get',{'ttag_id':ttag_id,'search_on':'ttag'})
            localprint(request,response)
            
        return thereturn;
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #32
0
ファイル: user.py プロジェクト: ttagit/website
def get_logged_in_user_with_access_token(request, access_token):
	authed, data = ttagServiceAuth(request, access_token)
	if authed:
		user_registry.logged_in_user = user = User(data)
		user_registry.logged_in_user.is_current_user = user_registry.logged_in_user["is_current_user"] = True
		user_registry.logged_in_user.is_logged_in = user_registry.logged_in_user['is_logged_in'] = True
		user_registry.users_by_name[user.user_name] = user
		user_registry.users_by_id[user.user_id] = user
	else:
		user = user_registry.logged_in_user
		if user:
			user.logged_in_user = user["logged_in_user"] = False
			user_registry.logged_in_user = user = None
	return user
コード例 #33
0
def eulaView(request):
    try:
        form = EulaForm()
        loggedin, data = ttagServiceAuth(request)
        if (request.method == 'POST'):
            form = EulaForm(request.POST)  # bound form
            if form.is_valid():
                return HttpResponseRedirect(paths.HTTPS + request.get_host() +
                                            '/signupmail/')
        return render_to_response('eula.html',
                                  locals(),
                                  context_instance=RequestContext(request))
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #34
0
ファイル: hubold.py プロジェクト: ttagit/website
def createHub(request):
    authed, data = ttagServiceAuth(request)
    if authed:
        #response = ttagRequestCount(data['_id'])
        access_token = request.COOKIES['access_token']
        user_id = data["_id"]
        if 'hub_name' in request.POST and 'hub_desc' in request.POST:
            hub_name = request.POST["hub_name"]
            hub_desc = request.POST["hub_desc"]
            response = ttagCreateHub(user_id, access_token, hub_name, hub_desc,
                                     "true", "0")
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
    else:

        return HttpResponse("Invalid request")
コード例 #35
0
ファイル: hubold.py プロジェクト: ttagit/website
def updateHubSingleMembers(request,data_type,data_value, sub_data_type, sub_data_value):
    
    authed, user = ttagServiceAuth(request)
    thereturn = HttpResponse('{"response":"ERROR", "msg":"Could not complete request"}')
    if authed and 'hub_user' in request.POST:
        user_id = user['_id']
        access_token= request.COOKIES['access_token']
        hub_user_list = request.POST.getlist('hub_user')
        response = ttagUpdateHubUsers(user_id, access_token, hub_user_list)
        if response.result == "OK":
            thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+'/hub/'+ data_type+'/' + data_value+'/members')
        else:
            thereturn = HttpResponse(response.msg)
            
    return thereturn
コード例 #36
0
ファイル: spraycan.py プロジェクト: ttagit/website
def hash(request):
    location = request.GET['location']
    start_time = '0' if 'start_time' not in request.GET else request.GET[
        'start_time']
    location_type = 'hashtag'
    thereturn = loginscreen(request)
    loggedin, data = ttagServiceAuth(request)
    if loggedin:
        ttags = ttagPost(
            "/find/hashtag", {
                'hashtag': str(location),
                'items_per_page': '10000',
                'page_number': '0'
            })
        localprint(request, ttags)
        if ttags['result'] == 'OK':
            import datetime
            response = {
                'time': ttags['time'],
                'data': {
                    'founder': {
                        'location_type': 'hashtag',
                        'location': location
                    },
                    'favorite':
                    False,
                    'ttags': [] if ttags['data']['ttags'] == None else
                    ttags['data']['ttags'],
                    'spams': [] if 'spams' not in ttags['data']
                    or ttags['data']['spams'] == None
                    or 'ttag_list' not in ttags['data']['spams']
                    or ttags['data']['spams']['ttag_list'] == None else
                    ttags['data']['spams']['ttag_list'],
                    'thumbups': [] if 'thumbups' not in ttags['data']
                    or ttags['data']['thumbups'] == None
                    or 'ttag_list' not in ttags['data']['thumbups']
                    or ttags['data']['thumbups']['ttag_list'] == None else
                    ttags['data']['thumbups']['ttag_list']
                }
            }
            loggedin_user = data['_id']
            servertime = datetime.datetime.fromtimestamp(
                int(ttags['time']) / 1000)
            thereturn = render_to_response(
                "spraycan.html",
                locals(),
                context_instance=RequestContext(request))
    return thereturn
コード例 #37
0
ファイル: user.py プロジェクト: ttagit/website
def get_logged_in_user_with_access_token(request, access_token):
    authed, data = ttagServiceAuth(request, access_token)
    if authed:
        user_registry.logged_in_user = user = User(data)
        user_registry.logged_in_user.is_current_user = user_registry.logged_in_user[
            "is_current_user"] = True
        user_registry.logged_in_user.is_logged_in = user_registry.logged_in_user[
            'is_logged_in'] = True
        user_registry.users_by_name[user.user_name] = user
        user_registry.users_by_id[user.user_id] = user
    else:
        user = user_registry.logged_in_user
        if user:
            user.logged_in_user = user["logged_in_user"] = False
            user_registry.logged_in_user = user = None
    return user
コード例 #38
0
ファイル: spraycan.py プロジェクト: ttagit/website
def toggle(request,feed_auto):
    try :
        loggedin, data = ttagServiceAuth(request)
        if loggedin and ( feed_auto == '1' or feed_auto == '0' ) :
            request.session['spraycanAuto'] = ( feed_auto == '1' )
        if request.is_ajax() :
            if 'location' in request.GET :
                location = request.GET['location']
            if 'start_time' in request.GET :
                response = {'time':request.GET['start_time']}
            thereturn = render_to_response('partial_spraycan_feed.html',locals(),context_instance=RequestContext(request))
        else :
            thereturn = url(request, request.GET['location'], 0)
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #39
0
ファイル: hubold.py プロジェクト: ttagit/website
def deleteHub(request, data_type, data_value):
    hub_id = data_value
    authed, user = ttagServiceAuth(request)
    if authed:
        access_token = request.COOKIES['access_token']
        user_id = user["_id"]

        response = ttagDeleteHub(user_id, access_token, hub_id)
        if response["result"] == "OK":
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
            #return HttpResponse("Success")
        else:
            return HttpResponse(response["msg"])

    else:

        return HttpResponse("Invalid request")
コード例 #40
0
ファイル: hubold.py プロジェクト: ttagit/website
def deleteHub(request,data_type,data_value):
    hub_id = data_value
    authed, user = ttagServiceAuth(request)
    if authed: 
        access_token = request.COOKIES['access_token']
        user_id = user["_id"]
        
        response = ttagDeleteHub(user_id, access_token, hub_id)    
        if response["result"] == "OK":
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
            #return HttpResponse("Success")
        else:
            return HttpResponse(response["msg"])
                
    else:
        
        return HttpResponse("Invalid request")
コード例 #41
0
ファイル: hubold.py プロジェクト: ttagit/website
def updateHubMembers(request, data_type, data_value):

    authed, user = ttagServiceAuth(request)
    thereturn = HttpResponse(
        '{"response":"ERROR", "msg":"Could not complete request"}')
    if authed and 'hub_user' in request.POST:
        user_id = user['_id']
        access_token = request.COOKIES['access_token']
        hub_user_list = request.POST.getlist('hub_user')
        response = ttagUpdateHubUsers(user_id, access_token, hub_user_list)
        if response.result == "OK":
            thereturn = HttpResponseRedirect(paths.HTTPS + request.get_host() +
                                             '/hub/' + data_type + '/' +
                                             data_value + '/members')
        else:
            thereturn = HttpResponse(response.msg)

    return thereturn
コード例 #42
0
ファイル: ttag.py プロジェクト: ttagit/website
def ttagDelete(request, ttag_id):
    try:
        thereturn = loginscreen(request)
        authed, user = ttagServiceAuth(request)
        if authed:
            response = ttagPost(
                "/ttag/delete",
                {"ttag_id": ttag_id, "user_id": user["_id"], "access_token": request.COOKIES["access_token"]},
            )
            location = request.META["HTTP_REFERER"] if "location" not in request.GET else request.GET["location"]
            if request.is_ajax():
                thereturn = HttpResponse(mark_safe('<article class="deleted">Ttag deleted</article>'))
            else:
                thereturn = HttpResponseRedirect(location)
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #43
0
ファイル: hubold.py プロジェクト: ttagit/website
def JoinedHub(request, data_type, data_value):
    loggedin, data = ttagServiceAuth(request)
    response_count = ttagRequestCount(data['_id'])
    counts = response_count['counts']
    
    if loggedin:
        if data_type == 'id':
            response_joined = ttagGetJoinedHubsByHubUserId(data_value)
        elif data_type == 'name':
            response_joined = ttagGetJoinedHubsByUserName(data_value)
            
        if response_joined["result"] == "OK":
            hubs = response_joined["data"]["hubs"]
            return render_to_response('hub/user_hubs.html', locals(), context_instance=RequestContext(request))
        else:
            return HttpResponse(response_joined.msg)
    else:
        return HttpResponseRedirect('/')
コード例 #44
0
ファイル: ttag.py プロジェクト: ttagit/website
def ttagShowOriginal(request, ttag_id, parent_id):
    try:
        thereturn = loginscreen(request)
        loggedin, data = ttagServiceAuth(request)
        if loggedin:
            thereturn = custompopup(
                request,
                '<p>There was a problem retrieving the original Tag</p>')
            response = ttagPost(
                '/ttag/get', {
                    'access_token': request.COOKIES['access_token'],
                    'user_id': data['_id'],
                    'ttag_id': parent_id,
                    'search_on': 'ttag'
                })
            loggedin_user = data['_id']
            from webapp.views.user import getUserFollowers
            if 'result' in response and response['result'] == 'OK':
                response['data']['followers'] = getUserFollowers(loggedin_user)
                servertime = datetime.datetime.fromtimestamp(
                    int(response['time']) / 1000)
                ttag = response['data']['ttag']
                child = ttagPost(
                    '/ttag/get', {
                        'access_token': request.COOKIES['access_token'],
                        'user_id': data['_id'],
                        'ttag_id': ttag_id,
                        'search_on': 'ttag'
                    })
                if 'result' in child and child[
                        'result'] == 'OK' and 'data' in child and child[
                            'data'] != None:
                    reply = child['data']['ttag']
                    child['data']['followers'] = response['data']['followers']
                    thereturn = render_to_response(
                        'ttag_showoriginal.html',
                        locals(),
                        context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #45
0
def contactView(request, department='general'):
    try:
        loggedin, data = ttagServiceAuth(request)
        departments = {
            'general': '*****@*****.**',
            'dev': '*****@*****.**',
            'privacy': '*****@*****.**'
        }
        form = Contact(
            initial={'department': department},
            auto_id=False,
            label_suffix=':') if request.method != 'POST' else Contact(
                request.POST, auto_id=False, label_suffix=':')
        formname = 'frmContact'
        theReturn = render_to_response(
            'contact.html', locals(), context_instance=RequestContext(request))
        if request.method == 'POST':
            if form.is_valid():
                from django.core.urlresolvers import reverse
                message = render_to_response(
                    'contact_mail.html',
                    locals(),
                    context_instance=RequestContext(request))
                subject = 'Ttagit.com User Comment'
                email_message = mark_safe(message.content)
                to_address = departments[form.getDepartment()]
                send_mail(subject,
                          email_message,
                          FROM_ADDRESS, [to_address],
                          fail_silently=True)
                theReturn = HttpResponseRedirect(paths.HTTPS +
                                                 request.get_host() +
                                                 reverse('thankyou'))
            elif request.is_ajax():
                theReturn = render_to_response(
                    'ajax_signin.html',
                    locals(),
                    context_instance=RequestContext(request))
        return theReturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #46
0
ファイル: home.py プロジェクト: ttagit/website
def activityView(request, page=1, time=0):
    """Show a logged in user the tag stream from their followers"""
    try :
        from webapp.views.user import PROFILE_ITEM_ROWS as ACTIVITY_ITEM_ROWS
        loggedin, data = ttagServiceAuth(request)
        if not loggedin: 
            # TODO: Replace this with a 'please log in' page
            return indexView(request)
        
        if not page or page == '' :
            page = 1
        page = int(page)
        if not time or time == '' :
            time = 0
        time = int(time)
        response = ttagPost('/user-data/get-following-ttags',{'access_token':request.COOKIES['access_token'],'user_id':data['_id'],'start_time':time,'items_per_page':ACTIVITY_ITEM_ROWS,'page_number':page-1})
        followers = []
        respFollowers = ttagRequestFollowers(data['_id'])
        if 'data' in respFollowers and 'users' in respFollowers['data'] and respFollowers['data']['users'] != None :
            followers = [follower['user_name'] for follower in respFollowers['data']['users']]
        response['data']['followers'] = followers
        # localprint(request,response)
        follow = -1
        servertime = datetime.datetime.fromtimestamp(int(response['time'])/1000)
        location = "Activity"
        loggedin_user = data['_id']
        more = True if response['data']['total_count'] > ACTIVITY_ITEM_ROWS * page and time == 0 else False
        if request.is_ajax() :
            theextend = "base_ajax.html" if ( request.is_ajax() and page > 1 ) else "partial_home_dashboard.html"
            userpanel = render_to_response("partial_home_stream.html",locals(),context_instance=RequestContext(request))
            if ( page > 1 ) :
                thereturn = userpanel
            else :
                userdetails = render_to_response("partial_user_details.html",locals(),context_instance=RequestContext(request))
                jsonReturn = simplejson.dumps({"context":mark_safe(userdetails.content),"results":mark_safe(userpanel.content)})
                thereturn = HttpResponse(mark_safe(jsonReturn))
        else :
            thereturn = render_to_response("home_stream.html",locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #47
0
ファイル: notification.py プロジェクト: ttagit/website
def handle(request, notification_id):
    try :
        thereturn = loginscreen(request)
        authed, user = ttagServiceAuth(request)
        if authed :
            thereturn = custompopup(request, '<p>It looks like you\'ve already clicked on this notice, try <a href="'+reverse('notification-page',args=('1',))+'">reloading the notifications?</a></p>')
            notifications = ttagPost("/notification/get",{'access_token': request.COOKIES['access_token'], '_id': notification_id})
            if notifications['result'] == 'OK' and 'data' in notifications :
                notice = notifications['data']
                if notice['notification_type'] == 'FOLLOW_ME' :
                    thereturn = redirect('user-profile',notice['notification_data']['value']['followee_name'],'','','')
                elif notice['notification_type'] == 'POST_ON_HUB_WALL' :
                    thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+reverse('hub-wall',args=('id/',notice['notification_data']['value']['hub_id'])))
                elif notice['notification_type'] == 'POST_ON_USER_WALL' :
                    thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+reverse('user-wall', args=(user['user_name'],)))
                elif notice['notification_type'] == 'REPLY_TTAG' or notice['notification_type'] == 'TTAG_FOLLOW' :
                    if 'ttag_location' not in notice['notification_data']['value'] :
                        ttag = ttagPost('/ttag/get',{'access_token': request.COOKIES['access_token'], 'user_id': user['_id'], 'ttag_id': notice['notification_data']['value']['ttag_id'], 'search_on': 'ttag'})
                        notice['notification_data']['value']['ttag_location'] = ttag['data']['ttag']['location']
                    if 'ttag_location_type' in notice['notification_data']['value'] :
                        if notice['notification_data']['value']['ttag_location_type'] == 'wall' :
                            thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+notice['notification_data']['value']['ttag_location'].replace(hosts.ROOT_HOST,""))
                        elif notice['notification_data']['value']['ttag_location_type'] == 'HUB' :
                            thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+reverse('hub-wall', args=('id/',notice['notification_data']['value']['ttag_location'].split('#')[0])))
                        return thereturn
                    elif not request.is_ajax() :
                        import urllib
                        thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+'/spraycan/url/?location='+urllib.quote_plus(notice['notification_data']['value']['ttag_location']))
                    else :
                        from webapp.views import spraycan
                        request.GET = request.GET.copy()
                        request.GET.update({'location':notice['notification_data']['value']['ttag_location']})
                        thereturn = spraycan.url(request)
                elif notice['notification_type'] in ['JOIN_HUB','QUIT_HUB'] :
                    thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+reverse('hub-members',args=('id/',notice['notification_data']['value']['hub_id'])))
                else :
                    thereturn = HttpResponseRedirect(paths.HTTPS+request.get_host()+reverse('notification-page',args=('1',)))
                delete = ttagPost("/notification/delete",{'access_token':request.COOKIES['access_token'],'notifications':[notification_id]})
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
コード例 #48
0
ファイル: hubold.py プロジェクト: ttagit/website
def findHubsGeneral(request):

    authed, data = ttagServiceAuth(request)
    joined_hubs = []
    block_title = ""
    if authed:
        response_count = ttagRequestCount(data['_id'])
        counts = response_count['counts']
        access_token = request.COOKIES['access_token']
        user_id = data["_id"]
        user_name = data["user_name"]
           
        if request.method == 'POST' and request.POST['find_method'] == 'general':
            response = ttagGetHubsByName(request.POST['query'])
            if response["result"] == 'OK':
                hubs = response['data']['hubs']
                
                logined_and_different = False
                joined_hubs = ttagGetJoinedHubsByUserName(user_name)["data"]["hubs"]
                for hub in response["data"]["hubs"]:
                    
                    if hub["creater_id"] == user_id:
                        hub["owner"] = True
                    else:
                        hub["owner"] = False
                    
                    hub["joined"] = False
                    for joined_hub in joined_hubs:
                        #print "Joined Hub:" + hub["hub_name"]+":" + joined_hub["_id"] + "======" + hub["_id"]+":"+hub["hub_name"]
                        if joined_hub["_id"] == hub["_id"]:
                            hub["joined"] = True
                            break
                
                thereturn = render_to_response('hub/find_hubs_general.html', locals(), context_instance=RequestContext(request))
            else:
                return  HttpResponse(response["msg"])
        else:
            #context = {'hubs': response["data"]["hubs"],"user_id":user_id,"joined_hubs":joined_hubs,"logined_and_different":logined_and_different}
            thereturn = render_to_response('hub/find_hubs_general.html', locals(), context_instance=RequestContext(request))
        return thereturn                
    else:
        return HttpResponseRedirect('/')
コード例 #49
0
ファイル: hubold.py プロジェクト: ttagit/website
def JoinedHub(request, data_type, data_value):
    loggedin, data = ttagServiceAuth(request)
    response_count = ttagRequestCount(data['_id'])
    counts = response_count['counts']

    if loggedin:
        if data_type == 'id':
            response_joined = ttagGetJoinedHubsByHubUserId(data_value)
        elif data_type == 'name':
            response_joined = ttagGetJoinedHubsByUserName(data_value)

        if response_joined["result"] == "OK":
            hubs = response_joined["data"]["hubs"]
            return render_to_response('hub/user_hubs.html',
                                      locals(),
                                      context_instance=RequestContext(request))
        else:
            return HttpResponse(response_joined.msg)
    else:
        return HttpResponseRedirect('/')
コード例 #50
0
ファイル: spraycan.py プロジェクト: ttagit/website
def toggle(request, feed_auto):
    try:
        loggedin, data = ttagServiceAuth(request)
        if loggedin and (feed_auto == '1' or feed_auto == '0'):
            request.session['spraycanAuto'] = (feed_auto == '1')
        if request.is_ajax():
            if 'location' in request.GET:
                location = request.GET['location']
            if 'start_time' in request.GET:
                response = {'time': request.GET['start_time']}
            thereturn = render_to_response(
                'partial_spraycan_feed.html',
                locals(),
                context_instance=RequestContext(request))
        else:
            thereturn = url(request, request.GET['location'], 0)
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #51
0
ファイル: marketing.py プロジェクト: ttagit/website
def view(request):
    try:
        thereturn = HttpResponse(
            'You are not authorized to view this area of the website')
        loggedin, data = ttagServiceAuth(request)
        if loggedin:
            usertemplate = 'base_marketing.html'
            follow = -1
            hidebadges = True
            hidefooter = True
            hideproinfo = True
            user_id = data["_id"]
            angularapp = "ttagitMarketing"
            paypal_dict = {
                "business":
                settings.PAYPAL_RECEIVER_EMAIL,
                "custom":
                user_id,
                "item_number":
                request.COOKIES['access_token'],
                "item_name":
                "Ttagit Ad Credits",
                "notify_url":
                paths.HTTPS + request.get_host() +
                "/3f2cf0fe3d994fb8dfe6d8f9g2h5",
                "return_url":
                paths.HTTPS + request.get_host() +
                reverse('marketing-thankyou'),
                "cancel_return":
                paths.HTTPS + request.get_host() + reverse('marketing'),
            }
            form = PayPalPaymentsForm(initial=paypal_dict)
            formaction = conf.POSTBACK_ENDPOINT if not debug.DEBUG else conf.SANDBOX_POSTBACK_ENDPOINT
            thereturn = render_to_response(
                'marketing_details.html',
                locals(),
                context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #52
0
ファイル: spraycan.py プロジェクト: ttagit/website
def location(request, ttag_id):
    try:
        thereturn = HttpResponse(
            mark_safe(
                '<p>This section of the website is currently under construction. Check back soon!</p>'
            ))
        start_time = '0' if 'start_time' not in request.GET else request.GET[
            'start_time']
        location_type = 'geo'
        loggedin, data = ttagServiceAuth(request)
        if loggedin:
            response = ttagPost('/ttag/get', {
                'ttag_id': ttag_id,
                'search_on': 'ttag'
            })
            localprint(request, response)

        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #53
0
ファイル: hubold.py プロジェクト: ttagit/website
def getHubTags(request, data_type, data_value):
    loggedin, data = ttagServiceAuth(request)
    response_count = ttagRequestCount(data['_id'])
    counts = response_count['counts']

    if data_type == "id":

        hub_response = ttagGetHubByHubId(data_value)

        if hub_response["result"] == "OK":
            hub = hub_response["data"]["hub"]
            from_time = 0 if 'from_time' not in request.POST else request.POST[
                'from_time']
            to_time = 4116171410000 if 'to_time' not in request.POST else request.POST[
                'to_time']
            items_per_page = 10000 if 'items_per_page' not in request.POST else request.POST[
                'items_per_page']
            page_number = 0 if 'page_number' not in request.POST else request.POST[
                'page_number']
            response = ttagGetHubTtags(data_value, from_time, to_time,
                                       items_per_page, page_number)
        else:
            return HttpResponse(hub_response["msg"])
    else:
        return HttpResponse("Invalid data type")

    if response["result"] == "OK":
        ttags = response["data"]["hub_ttags"]
        spraycan = True
        loggedin_user = data['_id']
        servertime = datetime.datetime.fromtimestamp(
            int(response['time']) / 1000)

        thereturn = render_to_response(
            'hub/hub_ttags.html',
            locals(),
            context_instance=RequestContext(request))
        return thereturn
    else:
        return HttpResponse(response["msg"])
コード例 #54
0
ファイル: marketing.py プロジェクト: ttagit/website
def mock(request, service_action):
    try:
        thereturn = HttpResponse(
            'You are not authorized to view this area of the website')
        loggedin, data = ttagServiceAuth(request)

        if service_action == "user-ads/get-statistic-data":
            json_path = "../static/javascript/mockdata/user-ads.json"
        elif service_action == "ads/user-id-for-ads-full":
            json_path = "../static/javascript/mockdata/adsList.json"
        elif service_action == "ads/create-pro-market-ads":
            json_path = "../static/javascript/mockdata/adsList.json"
        elif service_action == "ads/update-ads-full":
            json_path = "../static/javascript/mockdata/adsList.json"
        elif service_action == "ads/activate-ads":
            json_path = "../static/javascript/mockdata/adsList.json"
        elif service_action == "ads/deactivate-ads":
            json_path = "../static/javascript/mockdata/deactivatedAdsList.json"
        elif service_action == "ads/delete-pro-market-ads":
            json_path = "../static/javascript/mockdata/deletedAdsList.json"
        elif service_action == "user-ads/get-data":
            json_path = "../static/javascript/mockdata/user-ads-budget.json"
        elif service_action == "user-ads/upsert-bid":
            json_path = "../static/javascript/mockdata/user-ads-budget_update.json"

        json_path = os.path.join(FILE_PATH, json_path)

        if json_path:
            json_data = open(json_path)
            json_obj = json.load(json_data)
            json_string = json.dumps(json_obj)
            json_data.close()

        if loggedin and debug.DEBUG and json_string:
            thereturn = HttpResponse(json_string)
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #55
0
ファイル: user.py プロジェクト: ttagit/website
def userDelete(request):
    try:
        response = loginscreen(request)
        loggedin, data = ttagServiceAuth(request)
        if loggedin:
            access_token = request.COOKIES['access_token']
            if request.method == 'GET':
                pagetitle = 'TTAGIT - User Account Delete Request Confirmation'
                showPopup = True
                response = render_to_response(
                    'user_confirmdelete.html' if not request.is_ajax() else
                    'partial_user_confirmdelete.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                json_obj = ttagServiceAccountDelete(access_token)
                if json_obj['result'] == 'OK':
                    response = custompopup(request,
                                           '<p>Your Acccount was deleted</p>',
                                           reverse('index-page'))
                    request.COOKIES['access_token'] = ''
                else:
                    response = custompopup(
                        request, '<p>Your Account was not deleted</p>')
            return response


#        only during development!!!
#        elif 'user_name' in request.GET :
#            ttagPost('/delete-user',{'user_name':request.GET['user_name']})
#            response = HttpResponse('Your Account was deleted')
#        elif 'email' in request.GET :
#            ttagPost('/delete-user',{'email':request.GET['email']})
#            response = HttpResponse('Your Account was deleted')
        return response
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #56
0
ファイル: ttag.py プロジェクト: ttagit/website
def ttagThumbup(request, ttag_id):
    try:
        authed, user = ttagServiceAuth(request)
        thereturn = custompopup(request, "<p>Could not complete request</p>")
        if authed:
            ttag = ttagPost(
                '/ttag/get', {
                    'access_token': request.COOKIES['access_token'],
                    'user_id': user['_id'],
                    'ttag_id': ttag_id,
                    'search_on': 'ttag'
                })
            if ttag['result'] == 'OK':
                location = request.META[
                    'HTTP_REFERER'] if 'location' not in request.POST else request.POST[
                        'location']
                ttaglocation = ttag['data']['ttag']['location']
                response = ttagPost(
                    "/action/thumbup", {
                        'access_token': request.COOKIES['access_token'],
                        'user_id': user['_id'],
                        'location': ttaglocation,
                        'ttag_id': ttag_id
                    })
                if request.is_ajax():
                    ttag = ttag['data']['ttag']
                    ttag['metadatas']['thumbup_count'] = ttag['metadatas'][
                        'thumbup_count'] + 1
                    thereturn = render_to_response(
                        'partial_ttag_thumbup.html',
                        locals(),
                        context_instance=RequestContext(request))
                else:
                    thereturn = HttpResponseRedirect(location)
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
コード例 #57
0
ファイル: hubold.py プロジェクト: ttagit/website
def updateHub(request, data_type, data_value):
    hub_id = data_value
    authed, user = ttagServiceAuth(request)
    if authed:
        access_token = request.COOKIES['access_token']
        user_id = user["_id"]
        if 'hub_name' in request.POST and 'hub_desc' in request.POST:
            hub_name = request.POST["hub_name"]
            hub_desc = request.POST["hub_desc"]
            response = ttagUpdateHub(user_id, access_token, hub_id, hub_name,
                                     hub_desc, "true", "0")
            if response["result"] == "OK":
                hub = response["data"]["hub"]
                return render_to_response(
                    'hub/hub_update.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                hub = response["data"]["hub"]
                return render_to_response(
                    'hub/hub_update.html',
                    locals(),
                    context_instance=RequestContext(request))
        else:
            response = ttagGetHubByHubId(hub_id)
            if response["result"] == "OK":
                hub = response["data"]["hub"]
                return render_to_response(
                    'hub/hub_update.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                return HttpResponse(response["msg"])

    else:

        return HttpResponse("Invalid request")
コード例 #58
0
ファイル: hubold.py プロジェクト: ttagit/website
def findHubs(request):
    authed, data = ttagServiceAuth(request)
    response = ttagRequestCount(data['_id'])
    counts = response['counts']
    if authed:
        access_token = request.COOKIES['access_token']
        user_id = data["_id"]
        if 'hub_name' in request.POST and 'hub_desc' in request.POST:
            hub_name = request.POST["hub_name"]
            hub_desc = request.POST["hub_desc"]
            response = ttagCreateHub(user_id, access_token, hub_name, hub_desc,
                                     "true", "0")
            if response["result"] == "OK":
                #context = {"status":"created","hub":response["data"]["hub"]}
                status = "created"
                hub = response["data"]["hub"]
                return render_to_response(
                    'hub/hub_create.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                status = "error"
                error_msg = response["msg"]
                #context = {"status":"error","hub_name":hub_name,"hub_desc":hub_desc,"error_msg":response["msg"]}
                return render_to_response(
                    'hub/hub_create.html',
                    locals(),
                    context_instance=RequestContext(request))
        else:
            #context = {"status":"new"}
            status = "new"
            return render_to_response('hub/hub_create.html',
                                      locals(),
                                      context_instance=RequestContext(request))
    else:

        return HttpResponse("Invalid request")