Beispiel #1
0
def signup():
    username = request.forms.get('username').strip().lower()

    # make sure username was passed
    if username:

        # check if username exists
        user = User().get_user_by_username(graph_db, username)
        if user:

            # user found, show message
            return template(
                'public/templates/home/index.html',
                layout=homelayout,
                title="Home",
                error='The username ' + username +
                ' already exists. Please use a different username.')
        else:

            # save user
            User().save_user(graph_db, username)
            redirect("/msg?u=" + username)

    # otherwise send back
    else:
        return template('public/templates/home/index.html',
                        layout=homelayout,
                        title="Home",
                        error="Please enter a username.")
Beispiel #2
0
def login():
    # make sure username was passed
    username = request.forms.get('username').strip().lower()

    if username:

        # look for username
        user = User().get_user_by_username(graph_db, username)
        if user:
            # user found, set cookie and redirect
            response.set_cookie(graphstoryUserAuthKey,
                                user["username"],
                                path="/")
            redirect("/social")

        else:
            # otherwise send back with not found message
            return template("public/templates/home/index.html",
                            layout=homelayout,
                            title="Home",
                            error="The username you entered was not found.")
    # otherwise send back
    else:
        return template('public/templates/home/index.html',
                        layout=homelayout,
                        title="Home",
                        error="Please enter a username.")
Beispiel #3
0
def location():
    # get user location
    userlocations = UserLocation().get_user_location(
        graph_db, request.get_cookie(graphstoryUserAuthKey))

    distance = request.query.get('distance')

    # was distances provided
    if distance:

        # use first location
        ul = userlocations[0]

        productNodeId = request.query.get('productNodeId')

        # test for productNodeId
        if productNodeId:

            pnid = int(productNodeId)
            # get locations that have product
            locations = Location().locations_within_distance_with_product(
                graph_db,
                UserLocation().get_lq(ul, distance), pnid, ul)
            productNode = graph_db.node(pnid)
            return template('public/templates/graphs/location/index.html',
                            layout=applayout,
                            title="Location",
                            productTitle=productNode["title"],
                            locations=locations,
                            mappedUserLocation=userlocations)
        # no product provided
        else:
            # get locations
            locations = Location().locations_within_distance(
                graph_db,
                UserLocation().get_lq(ul, distance), ul, "business")
            return template('public/templates/graphs/location/index.html',
                            layout=applayout,
                            title="Location",
                            locations=locations,
                            mappedUserLocation=userlocations)

    # return search template for locations
    else:
        return template('public/templates/graphs/location/index.html',
                        layout=applayout,
                        title="Location",
                        mappedUserLocation=userlocations)
Beispiel #4
0
def msg():
    username = request.query.u
    # personalize with the username
    return template('public/templates/home/message.html',
                    layout=homelayout,
                    title="Thank You!",
                    msg="Thank you, " + username + " !")
Beispiel #5
0
def interest():
    # get the user's tags
    userTags = Tag().user_tags(graph_db,
                               request.get_cookie(graphstoryUserAuthKey))
    # get the tags of user's friends
    tagsInNetwork = Tag().tags_in_network(
        graph_db, request.get_cookie(graphstoryUserAuthKey))

    # if the user's content was requested
    if request.query.get('userscontent') == "true":
        contents = Content().get_user_content_with_tag(
            graph_db, request.get_cookie(graphstoryUserAuthKey),
            request.query.get('tag'))
    # if the user's friends' content was requested
    else:
        contents = Content().get_following_content_with_tag(
            graph_db, request.get_cookie(graphstoryUserAuthKey),
            request.query.get('tag'))

    return template('public/templates/graphs/interest/index.html',
                    layout=applayout,
                    userTags=userTags,
                    tagsInNetwork=tagsInNetwork,
                    contents=contents,
                    title="Interest")
Beispiel #6
0
def user():
    user = User().get_user_by_username(
        graph_db, request.get_cookie(graphstoryUserAuthKey))
    return template('public/templates/graphs/social/user.html',
                    layout=applayout,
                    user=user.get_properties(),
                    title="User Settings")
Beispiel #7
0
def viewpost(contentId):
    statusupdate = Content().get_status_update(
        graph_db, request.get_cookie(graphstoryUserAuthKey), contentId)

    return template('public/templates/graphs/social/post.html',
                    layout=applayout,
                    content=statusupdate,
                    title=statusupdate[0].title)
Beispiel #8
0
def friends():
    following = User().following(graph_db,
                                 request.get_cookie(graphstoryUserAuthKey))

    return template('public/templates/graphs/social/friends.html',
                    following=following,
                    layout=applayout,
                    title="Friends")
Beispiel #9
0
def friends_purchase_tag_similarity():
    # get result set
    result = Purchase().friends_purchase_tag_similarity(
        graph_db, request.get_cookie(graphstoryUserAuthKey))
    return template(
        'public/templates/graphs/intent/index.html',
        layout=applayout,
        title="Products Purchased by Friends and Matches User's Tags",
        mappedProductUserPurchaseList=result)
Beispiel #10
0
def friends_purchase_by_product():
    # get or use default product title
    producttitle = request.query.producttitle or 'Star Wars Mimobot Thumb Drives'
    # get result set
    result = Purchase().friends_purchase_by_product(
        graph_db, request.get_cookie(graphstoryUserAuthKey), producttitle)
    return template('public/templates/graphs/intent/index.html',
                    layout=applayout,
                    title="Specific Products Purchased by Friends",
                    mappedProductUserPurchaseList=result,
                    producttitle=producttitle)
Beispiel #11
0
def index():
    # was tag supplied, then get product matches based on specific tag
    if request.query.get('tag'):
        usersWithMatchingTags = Product(
        ).get_products_has_specific_tag_and_user_uses_specific_tag(
            graph_db, request.query.get('tag'))
    # otherwise return all product matches as long as at least one tag matches against the users
    else:
        usersWithMatchingTags = Product(
        ).get_products_has_a_tag_and_user_uses_a_matching_tag(graph_db)

    return template('public/templates/graphs/consumption/console.html',
                    layout=applayout,
                    usersWithMatchingTags=usersWithMatchingTags,
                    title="Consumption Console")
Beispiel #12
0
def consumption():
    products = Product().get_products(graph_db, 0)
    next = True
    nextPageUrl = "/consumption/10"

    productTrail = Product().get_product_trail(
        graph_db, request.cookies[graphstoryUserAuthKey])

    return template('public/templates/graphs/consumption/index.html',
                    layout=applayout,
                    products=products,
                    productTrail=productTrail,
                    next=next,
                    nextPageUrl=nextPageUrl,
                    title="Consumption")
Beispiel #13
0
def social():
    contents = Content().get_content(graph_db,
                                     request.get_cookie(graphstoryUserAuthKey),
                                     0)

    if len(contents) > 3:
        morecontent = True
        contents = contents[0:3]
    else:
        morecontent = False

    return template('public/templates/graphs/social/posts.html',
                    layout=applayout,
                    contents=contents,
                    morecontent=morecontent,
                    title="Social")
Beispiel #14
0
def index(pagenum):
    curpage = int(pagenum)

    # get products for this page
    products = Product().get_products(graph_db, curpage)

    # bump the page total
    next = True
    curpage = curpage + 10

    # set the next GET route
    nextPageUrl = "/consumption/" + str(curpage)

    return template('public/templates/graphs/consumption/product-list.html',
                    products=products,
                    next=next,
                    nextPageUrl=nextPageUrl)
Beispiel #15
0
def friends_purchase_tag_similarity_and_proximity_to_location():
    # get user location
    userlocations = UserLocation().get_user_location(
        graph_db, request.get_cookie(graphstoryUserAuthKey))
    # use first location
    ul = userlocations[0]

    # get result set
    result = Purchase(
    ).friends_purchase_tag_similarity_and_proximity_to_location(
        graph_db, request.get_cookie(graphstoryUserAuthKey),
        UserLocation().get_lq_distance_set(ul))

    return template(
        'public/templates/graphs/intent/index.html',
        layout=applayout,
        title="Products Purchased by Friends Nearby and Matches User's Tags",
        mappedProductUserPurchaseList=result,
        mappedUserLocation=userlocations)
Beispiel #16
0
 def test_template_shortcut(self):
     result = template('start {{var}} end', var='middle')
     self.assertEqual(u'start middle end', result)
Beispiel #17
0
def index():
    return template("public/templates/home/index.html",
                    layout=homelayout,
                    title="Home")