示例#1
0
文件: userhub.py 项目: ttagit/website
def create(request, user_name=''):
    try:
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, user_name)
        if loggedin:
            user_name = user['user_name']
            if not request.POST:
                thereturn = render_to_response(
                    'partial_user_createhub.html',
                    locals(),
                    context_instance=RequestContext(request))
            else:
                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(loggedin_user,
                                             request.COOKIES['access_token'],
                                             hub_name, hub_desc, "", "",
                                             "true", "0")
                    if request.is_ajax():
                        thereturn = render_to_response(
                            'partial_user_hubcreated.html',
                            locals(),
                            context_instance=RequestContext(request))
                    else:
                        from django.core.urlresolvers import reverse
                        thereturn = HttpResponseRedirect(
                            reverse('userhub-created', args=(user_name)))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
示例#2
0
文件: userhub.py 项目: ttagit/website
def search(request, user_name=''):
    try:
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, user_name)
        if loggedin:
            user_name = user['user_name']
            if not request.POST:
                thereturn = render_to_response(
                    'partial_user_searchhub.html',
                    locals(),
                    context_instance=RequestContext(request))
            elif 'query' in request.POST and len(request.POST['query']) > 0:
                response = ttagGetHubsByName(request.POST['query'])
                if response['result'] == 'OK':
                    response['data']['hubs'] = processRawHubs(
                        response['data']['hubs'], request)
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(
                        user['user_name'])
                    thereturn = render_to_response(
                        'partial_userhub_searchresults.html',
                        locals(),
                        context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
示例#3
0
文件: userhub.py 项目: ttagit/website
def listCreated(request, user_name):
    try :
        thereturn = custompopup(request,'<p>Sorry, we were unable to display this page.</p>')
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, user_name)
        logged_in_user = get_logged_in_user(request)
        request_user = get_user_by_name(request, user_name)
        if request_user != False :
            hubs = get_hubs_by_user(request, request_user)
            if len(hubs) == 0 :
                if loggedin and user_name == user['user_name'] :
                    thereturn = render_to_response('partial_user_nocreatedhubsmyself.html',locals(),context_instance=RequestContext(request))
                else :
                    thereturn = render_to_response('partial_user_nocreatedhubs.html',locals(),context_instance=RequestContext(request))
            else :
                response = {'data': {'hubs': hubs }}
                if loggedin :
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(user['user_name'])
                    if user_name == user['user_name'] :
                        response['data']['createdhubs'] = [hub.hub_id for hub in response['data']['hubs']]
                thereturn = render_to_response('partial_user_createdhubs.html',locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
示例#4
0
文件: userhub.py 项目: ttagit/website
def delete(request, data_type, data_value):
    try :
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, '')
        if loggedin :
            user_name = user['user_name']
            if data_type == 'id' :
                hub_id = data_value
            respHub = ttagGetHubByHubId(hub_id)
            #print respHub
            if respHub['result'] == 'OK' and respHub['data']['hub']['user']['user_id'] == loggedin_user :
                if not request.POST :
                    hub = respHub['data']['hub']
                    thereturn = render_to_response('partial_userhub_confirmdelete.html',locals(),context_instance=RequestContext(request))
                else :
                    if 'hub_id' in locals() :
                        response = ttagDeleteHub(loggedin_user, request.COOKIES['access_token'], hub_id)    
                        if request.is_ajax() :
                            thereturn = HttpResponse(mark_safe('<article class="deleted">Hub deleted</article>'))
                        else :
                            thereturn = HttpResponseRedirect(request.META['HTTP_REFERER'])
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
示例#5
0
文件: home.py 项目: ttagit/website
def settingsView(request, popup=False):
    """Show the user settings dashboard page"""
    try :
        thereturn = loginscreen(request)
        from webapp.views.user import getUserVariables
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, '')
        if loggedin: 
            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)
            response = ttagRequestCount(data['_id'])
            if popup != False :
                showPopup = True
                popupPartial = "partial_"+popup+"_popup.html"
            pagetitle = "ttagit - User Settings Page"
            location = "Settings"
            if request.is_ajax() :
                from website.localsettings.paths import S3TATIC_URL
                userpanel = render_to_response("partial_home_settings.html",locals(),context_instance=RequestContext(request))
                userdetails = render_to_response("partial_user_details.html",locals(),context_instance=RequestContext(request))
                head = render_to_response("djview_head_resources.html",{'headScripts':mark_safe('<script type="text/javascript" src="'+S3TATIC_URL+'scripts/passwordstrength.js"></script><script type="text/javascript" src="'+S3TATIC_URL+'scripts/settings.js"></script>')},context_instance=RequestContext(request))
                jsonReturn = simplejson.dumps({"context":mark_safe(userdetails.content),"results":mark_safe(userpanel.content),'head':mark_safe(head.content)})
                thereturn = HttpResponse(mark_safe(jsonReturn))
            else :
                thereturn = render_to_response('home_settings.html', locals(), context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
示例#6
0
文件: userhub.py 项目: ttagit/website
def search(request, user_name=''):
    try :
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, user_name)
        if loggedin :
            user_name = user['user_name']
            if not request.POST :
                thereturn = render_to_response('partial_user_searchhub.html',locals(),context_instance=RequestContext(request))
            elif 'query' in request.POST and len(request.POST['query']) > 0 :
                response = ttagGetHubsByName(request.POST['query'])
                if response['result'] == 'OK' :
                    response['data']['hubs'] = processRawHubs(response['data']['hubs'], request)
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(user['user_name'])
                    thereturn = render_to_response('partial_userhub_searchresults.html',locals(),context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
示例#7
0
def page(request, page):
    try :
        from webapp.views.user import PROFILE_ITEM_ROWS as ITEMS_PER_ROW
        thereturn = loginscreen(request)
        hubs = {}
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, '')
        if loggedin :
            notifications = ttagPost("/notification/get-all", {'access_token': request.COOKIES['access_token']})
            for notice in notifications['data'] :
                if notice['notification_type'] == 'REPLY_TTAG' :
                    if 'ttag_location_type' in notice['notification_data']['value'] :
                        if notice['notification_data']['value']['ttag_location_type'] == 'wall' :
                            notice['notification_data']['value']['ttag_title'] = notice['notification_data']['value']['ttag_title'].replace(data['full_name']+"'s Wall",'your Wall')
                        elif notice['notification_data']['value']['ttag_location_type'] == 'HUB' :
                            hub_id = notice['notification_data']['value']['ttag_location'].split('#')[0]
                            if hub_id not in hubs :
                                hubdata = ttagGetHubByHubId(hub_id)
                                hubs[hub_id] = hubdata
                            else :
                                hubdata = hubs[hub_id]
                            if hubdata['result'] == 'OK' :
                                notice['notification_data']['value']['ttag_title'] = hubdata['data']['hub']['hub_name']
            response = {'notifications':notifications['data']}
            page = int(page)
            next = True if page > 1 else False
            more = True if page * 15 < len(notifications['data']) else False
            location = 'Notifications'
            if next and request.is_ajax() :
                thereturn = render_to_response("partial_notifications_notices.html",locals(),context_instance=RequestContext(request))
            elif request.is_ajax() :
                userpanel = render_to_response("partial_notifications_details.html",locals(),context_instance=RequestContext(request))
                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('notifications_details.html', locals(), context_instance=RequestContext(request))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
示例#8
0
文件: userhub.py 项目: ttagit/website
def listCreated(request, user_name):
    try:
        thereturn = custompopup(
            request, '<p>Sorry, we were unable to display this page.</p>')
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, user_name)
        logged_in_user = get_logged_in_user(request)
        request_user = get_user_by_name(request, user_name)
        if request_user != False:
            hubs = get_hubs_by_user(request, request_user)
            if len(hubs) == 0:
                if loggedin and user_name == user['user_name']:
                    thereturn = render_to_response(
                        'partial_user_nocreatedhubsmyself.html',
                        locals(),
                        context_instance=RequestContext(request))
                else:
                    thereturn = render_to_response(
                        'partial_user_nocreatedhubs.html',
                        locals(),
                        context_instance=RequestContext(request))
            else:
                response = {'data': {'hubs': hubs}}
                if loggedin:
                    from webapp.views.user import getUserHubs
                    response['data']['joinedhubs'] = getUserHubs(
                        user['user_name'])
                    if user_name == user['user_name']:
                        response['data']['createdhubs'] = [
                            hub.hub_id for hub in response['data']['hubs']
                        ]
                thereturn = render_to_response(
                    'partial_user_createdhubs.html',
                    locals(),
                    context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
示例#9
0
文件: userhub.py 项目: ttagit/website
def create(request, user_name=''):
    try :
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(request, user_name)
        if loggedin :
            user_name = user['user_name']
            if not request.POST :
                thereturn = render_to_response('partial_user_createhub.html',locals(),context_instance=RequestContext(request))
            else :
                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(loggedin_user, request.COOKIES['access_token'], hub_name, hub_desc, "", "", "true", "0")
                    if request.is_ajax() :
                        thereturn = render_to_response('partial_user_hubcreated.html',locals(),context_instance=RequestContext(request))
                    else :
                        from django.core.urlresolvers import reverse
                        thereturn = HttpResponseRedirect(reverse('userhub-created', args=(user_name)))
        return thereturn
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
示例#10
0
文件: userhub.py 项目: ttagit/website
def delete(request, data_type, data_value):
    try:
        thereturn = loginscreen(request)
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, '')
        if loggedin:
            user_name = user['user_name']
            if data_type == 'id':
                hub_id = data_value
            respHub = ttagGetHubByHubId(hub_id)
            #print respHub
            if respHub['result'] == 'OK' and respHub['data']['hub']['user'][
                    'user_id'] == loggedin_user:
                if not request.POST:
                    hub = respHub['data']['hub']
                    thereturn = render_to_response(
                        'partial_userhub_confirmdelete.html',
                        locals(),
                        context_instance=RequestContext(request))
                else:
                    if 'hub_id' in locals():
                        response = ttagDeleteHub(
                            loggedin_user, request.COOKIES['access_token'],
                            hub_id)
                        if request.is_ajax():
                            thereturn = HttpResponse(
                                mark_safe(
                                    '<article class="deleted">Hub deleted</article>'
                                ))
                        else:
                            thereturn = HttpResponseRedirect(
                                request.META['HTTP_REFERER'])
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
示例#11
0
def page(request, page):
    try:
        from webapp.views.user import PROFILE_ITEM_ROWS as ITEMS_PER_ROW
        thereturn = loginscreen(request)
        hubs = {}
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, '')
        if loggedin:
            notifications = ttagPost(
                "/notification/get-all",
                {'access_token': request.COOKIES['access_token']})
            for notice in notifications['data']:
                if notice['notification_type'] == 'REPLY_TTAG':
                    if 'ttag_location_type' in notice['notification_data'][
                            'value']:
                        if notice['notification_data']['value'][
                                'ttag_location_type'] == 'wall':
                            notice['notification_data']['value'][
                                'ttag_title'] = notice['notification_data'][
                                    'value']['ttag_title'].replace(
                                        data['full_name'] + "'s Wall",
                                        'your Wall')
                        elif notice['notification_data']['value'][
                                'ttag_location_type'] == 'HUB':
                            hub_id = notice['notification_data']['value'][
                                'ttag_location'].split('#')[0]
                            if hub_id not in hubs:
                                hubdata = ttagGetHubByHubId(hub_id)
                                hubs[hub_id] = hubdata
                            else:
                                hubdata = hubs[hub_id]
                            if hubdata['result'] == 'OK':
                                notice['notification_data']['value'][
                                    'ttag_title'] = hubdata['data']['hub'][
                                        'hub_name']
            response = {'notifications': notifications['data']}
            page = int(page)
            next = True if page > 1 else False
            more = True if page * 15 < len(notifications['data']) else False
            location = 'Notifications'
            if next and request.is_ajax():
                thereturn = render_to_response(
                    "partial_notifications_notices.html",
                    locals(),
                    context_instance=RequestContext(request))
            elif request.is_ajax():
                userpanel = render_to_response(
                    "partial_notifications_details.html",
                    locals(),
                    context_instance=RequestContext(request))
                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(
                    'notifications_details.html',
                    locals(),
                    context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
示例#12
0
def settingsView(request, popup=False):
    """Show the user settings dashboard page"""
    try:
        thereturn = loginscreen(request)
        from webapp.views.user import getUserVariables
        loggedin, user, loggedin_user, follow, data = getUserVariables(
            request, '')
        if loggedin:
            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)
            response = ttagRequestCount(data['_id'])
            if popup != False:
                showPopup = True
                popupPartial = "partial_" + popup + "_popup.html"
            pagetitle = "ttagit - User Settings Page"
            location = "Settings"
            if request.is_ajax():
                from website.localsettings.paths import S3TATIC_URL
                userpanel = render_to_response(
                    "partial_home_settings.html",
                    locals(),
                    context_instance=RequestContext(request))
                userdetails = render_to_response(
                    "partial_user_details.html",
                    locals(),
                    context_instance=RequestContext(request))
                head = render_to_response("djview_head_resources.html", {
                    'headScripts':
                    mark_safe(
                        '<script type="text/javascript" src="' + S3TATIC_URL +
                        'scripts/passwordstrength.js"></script><script type="text/javascript" src="'
                        + S3TATIC_URL + 'scripts/settings.js"></script>')
                },
                                          context_instance=RequestContext(
                                              request))
                jsonReturn = simplejson.dumps({
                    "context":
                    mark_safe(userdetails.content),
                    "results":
                    mark_safe(userpanel.content),
                    'head':
                    mark_safe(head.content)
                })
                thereturn = HttpResponse(mark_safe(jsonReturn))
            else:
                thereturn = render_to_response(
                    'home_settings.html',
                    locals(),
                    context_instance=RequestContext(request))
        return thereturn
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)