예제 #1
0
def checked(request, itemname):

    if request.user.is_authenticated == False:
        return redirect('items:login')

    url = random_server()

    response_url = checks.check(itemname, request.user.username,
                                request.POST['check'], request.user.username,
                                url)

    resp = finder_saw.find(itemname, 'ubuntu', url)

    nc_add = finder_wal.query(resp[itemname].c_addr, 'ubuntu', url)
    user_profile = _deserialize_key(nc_add)
    nc_add = user_profile.name
    user_profile = finder_wal.query(nc_add, 'ubuntu', url)
    user_profile = _deserialize_key(user_profile)
    resp[itemname].c_addr = nc_add
    #get the checks list
    checks_list = checks.item_checks_list(resp[itemname].check,
                                          user_profile.profile)
    #hist goes through transactions in BC, so returns in human readble form
    hist = his.item_history(itemname, url)
    requested_user = request.user.username
    context = {
        'resp': resp,
        'hist': hist,
        "checks_list": checks_list,
        'requested_user': requested_user
    }
    return render(request, 'items/detail.html', context)
예제 #2
0
def detail(request, itemname):

    if request.user.is_authenticated == False:
        return redirect('items:login')
    url = random_server()

    #find item uses state list
    # finding the details of itemname in the state database
    resp = finder_saw.find(itemname, 'ubuntu', url)

    # nc_add is the human readable name
    nc_add = finder_wal.query(resp[itemname].c_addr, 'ubuntu', url)
    # breaking apart the string with commas
    user_profile = _deserialize_key(nc_add)

    nc_add = user_profile.name

    # finding the profile

    user_profile = finder_wal.query(nc_add, 'ubuntu', url)
    user_profile = _deserialize_key(user_profile)
    resp[itemname].c_addr = nc_add
    #get the checks list
    checks_list = checks.item_checks_list(check_status=resp[itemname].check,
                                          profile=user_profile.profile)
    #hist goes through transactions in block chain, so returns in human readble form

    #serialized make that into an item history class with all the attributes so that django
    #will not complain
    #we can do the serializtion and breaking up stuff in the his.py

    # looks through all the transactions to find history
    hist = his.item_history(itemname, url)
    requested_user = request.user.username

    # submit button is only shown in the current address of the item is the same as the current user of the page.
    context = {
        'resp': resp,
        'hist': hist,
        "checks_list": checks_list,
        'requested_user': requested_user
    }

    return render(request, 'items/detail.html', context)
예제 #3
0
def map(request):

    if request.user.is_authenticated == False:
        return redirect('items:login')

    url = random_server()
    #GeoLocations of users Probably change this entire charade to some other file ????
    locations = {
        'admin': {
            'lat': 42.34,
            'longi': -71.55
        },
        'Larry@lab': {
            'lat': 42.34,
            'longi': -71.64
        },
        'Mike@manufacturing': {
            'lat': 42.342,
            'longi': -71.52
        },
        'Susan@sterilization': {
            'lat': 42.339,
            'longi': -71.53
        },
        'Quinn@quality': {
            'lat': 42.39,
            'longi': -71.54
        }
    }

    response = querying.query_all_items(url)
    resp = {}
    usersdata = {}
    for s in response:
        name, checks, c_add, prev_add = response[s].decode().split(",")
        try:
            nc_add = finder_wal.query(c_add, 'ubuntu', url)
            nc_add = _deserialize_key(nc_add).name
            resp[name] = Item(name, checks, nc_add, prev_add)

            try:
                usersdata[nc_add].iheld += 1
            except:
                usersdata[nc_add] = userinfo(nc_add,
                                             float(locations[nc_add]['lat']),
                                             float(locations[nc_add]['longi']))
        except:
            pass

    context = {'resp': resp, 'usersdata': usersdata}
    return render(request, 'items/map.html', context)
예제 #4
0
def send(request, itemname):

    if request.user.is_authenticated == False:
        return redirect('items:login')
    url = random_server()

    send_saw.snd(itemname, forwarding.from_user(request.user.username),
                 request.user.username, url)

    #find item uses state list
    resp = finder_saw.find(itemname, 'ubuntu', url)

    #######VERY IMPOSRTANT CHANGE TO BE APPLIED HERE TOOO
    nc_add = finder_wal.query(resp[itemname].c_addr, 'ubuntu', url)
    user_profile = _deserialize_key(nc_add)
    nc_add = user_profile.name
    user_profile = finder_wal.query(nc_add, 'ubuntu', url)
    user_profile = _deserialize_key(user_profile)
    resp[itemname].c_addr = nc_add
    #get the checks list
    checks_list = checks.item_checks_list(check_status=resp[itemname].check,
                                          profile=user_profile.profile)
    #hist goes through transactions in block chain, so returns in human readble form

    #serialized make that into an item history class with all the attributes so that django
    #will not complain
    #we can do the serializtion and breaking up stuff in the his.py
    hist = his.item_history(itemname, url)
    requested_user = request.user.username

    context = {
        'resp': resp,
        'hist': hist,
        "checks_list": checks_list,
        'requested_user': requested_user,
        'sent_to': forwarding.from_user(request.user.username)
    }
    return render(request, 'items/send.html', context)
예제 #5
0
def user_detail(request, username):

    if request.user.is_authenticated == False:
        return redirect('items:login')

    url = random_server()

    if not request.GET.get('q'):
        resp = querying.query_user_held(username, url)
        #returns from state table all the datas with c_add as username
    else:
        resp = querying.query_possible_items(request.GET.get("q"), url)
        #takes care of search form

    for name, item_obj in resp.items():
        #finding out human name of the public key holder
        ######HERE TOOOO
        nc_add = finder_wal.query(item_obj.c_addr, request.user.username, url)
        nc_add = _deserialize_key(nc_add).name
        resp[name].c_addr = nc_add

    context = {'resp': resp, 'username': username}

    return render(request, 'items/user-detail.html', context)